Skip to content

refactor: extract test cert generation into a shared helper#1569

Merged
linkvt merged 1 commit intokedacore:mainfrom
linkvt:extract-test-cert-helper
Apr 8, 2026
Merged

refactor: extract test cert generation into a shared helper#1569
linkvt merged 1 commit intokedacore:mainfrom
linkvt:extract-test-cert-helper

Conversation

@linkvt
Copy link
Copy Markdown
Contributor

@linkvt linkvt commented Apr 7, 2026

Move inline cert generation to pkg/testutil and use in-memory certs instead of file-based ones from Makefile.

Also improve the ServeContext tests by not requiring localhost:1234 to be available and using an unallocated port instead.

Checklist

  • Commits are signed with Developer Certificate of Origin (DCO)

@linkvt linkvt requested a review from a team as a code owner April 7, 2026 09:07
Copilot AI review requested due to automatic review settings April 7, 2026 09:07
@snyk-io
Copy link
Copy Markdown

snyk-io bot commented Apr 7, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors TLS test certificate generation into a shared Go helper and updates HTTP server/test code to use in-memory certs (reducing reliance on Makefile-generated files).

Changes:

  • Add pkg/testutil helpers to generate self-signed cert/key PEM and tls.Certificate in tests.
  • Refactor pkg/http server startup to serve from a provided listener (and adjust tests to use ephemeral ports + in-memory TLS).
  • Update Makefile and .gitignore so make test no longer depends on generating local cert files, while keeping legacy e2e cert targets.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/testutil/cert.go New shared test helper for self-signed TLS cert generation.
pkg/http/server.go Serve via net.Listener (Serve/ServeTLS) instead of ListenAndServe*.
pkg/http/server_test.go Switch tests to ephemeral listeners and testutil-generated certs.
interceptor/tls_config_test.go Replace duplicated cert PEM generator with testutil.GenerateCertPEM.
Makefile Remove test dependency on test-certs; keep legacy cert targets with TODOs.
.gitignore Stop ignoring *.crt/*.pem/... globally; ignore only /certs/ for legacy e2e.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@linkvt linkvt marked this pull request as draft April 7, 2026 09:15
@linkvt linkvt force-pushed the extract-test-cert-helper branch 3 times, most recently from 9d9dbd3 to b5a525e Compare April 7, 2026 09:43
@linkvt linkvt requested a review from Copilot April 7, 2026 09:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@linkvt linkvt force-pushed the extract-test-cert-helper branch from b5a525e to f020b36 Compare April 7, 2026 10:03
@linkvt linkvt marked this pull request as ready for review April 7, 2026 10:05
@linkvt linkvt enabled auto-merge (squash) April 8, 2026 06:49
@linkvt linkvt changed the title refactor: extract test cert generation into shared helper refactor: extract test cert generation into a shared helper Apr 8, 2026
@linkvt linkvt changed the title refactor: extract test cert generation into a shared helper WIP - refactor: extract test cert generation into a shared helper Apr 8, 2026
@linkvt linkvt changed the title WIP - refactor: extract test cert generation into a shared helper refactor: extract test cert generation into a shared helper Apr 8, 2026
Move inline cert generation to pkg/testutil and use in-memory
certs instead of file-based ones from Makefile.

Signed-off-by: Vincent Link <[email protected]>
@linkvt linkvt force-pushed the extract-test-cert-helper branch from f020b36 to df05201 Compare April 8, 2026 06:56
@keda-automation keda-automation requested a review from a team April 8, 2026 06:57
@linkvt
Copy link
Copy Markdown
Contributor Author

linkvt commented Apr 8, 2026

WIP seems to have some problems as indicated by issues in the WIP app repo, will probably replace it with the action and temporarily disable meanwhile.

@linkvt linkvt merged commit 79c9a35 into kedacore:main Apr 8, 2026
28 checks passed
@linkvt linkvt deleted the extract-test-cert-helper branch April 8, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants