Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate certificates at runtime for runner test #3527

Merged
merged 3 commits into from
Jan 11, 2024
Merged

Generate certificates at runtime for runner test #3527

merged 3 commits into from
Jan 11, 2024

Conversation

joanlopez
Copy link
Contributor

@joanlopez joanlopez commented Jan 10, 2024

What?

It modifies the TestVUIntegrationClientCerts test on runner_test.go in order to generate certificates at runtime, instead of using pre-generated ones.

Why?

This test is currently failing when runtime.GOOS == "darwin", because it expects the "certificate signed by unknown authority" error but it gets "certificate is not standards compliant" instead, because the pre-generated certificate has a validity of 1000 years since 2022, and that's not considered standards compliant by Apple.

So, instead of having a pre-generated certificate that expires every year (so we'd need to update it every year), this makes the test to generate the required certificates at runtime (so always up to date), which also seems to be fine for MacOS.

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (make lint) and all checks pass.
  • I have run tests locally (make tests) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Related PR(s)/Issue(s)

I think it fixes #2578, cause with this I no longer see errors on MacOS.

@joanlopez joanlopez self-assigned this Jan 10, 2024
@joanlopez joanlopez requested a review from a team as a code owner January 10, 2024 16:08
@joanlopez joanlopez requested review from codebien and removed request for a team January 10, 2024 16:08
@@ -937,7 +945,6 @@ func GenerateTLSCertificate(t *testing.T, host string, notBefore time.Time, vali
NotAfter: notAfter,

KeyUsage: keyUsage,
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Beyond the new logic to have support for CA cert & key (if parent == nil { ... }), this is the only line from the original method that I have modified (removed), because with this line the test doesn't work (because the generated cert cannot be used to sign later) and without it everything works as expected, so 👌🏻

js/runner_test.go Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Jan 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (65b2f27) 72.55% compared to head (3d01523) 72.50%.

❗ Current head 3d01523 differs from pull request most recent head d8427ae. Consider uploading reports for the commit d8427ae to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3527      +/-   ##
==========================================
- Coverage   72.55%   72.50%   -0.05%     
==========================================
  Files         276      274       -2     
  Lines       20840    20835       -5     
==========================================
- Hits        15120    15107      -13     
- Misses       4758     4762       +4     
- Partials      962      966       +4     
Flag Coverage Δ
ubuntu 72.50% <ø> (ø)
windows ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mstoykov mstoykov added this to the v0.49.0 milestone Jan 10, 2024
@joanlopez joanlopez merged commit aa27c61 into grafana:master Jan 11, 2024
22 checks passed
@joanlopez joanlopez mentioned this pull request Jan 18, 2024
5 tasks
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.

Tests fail on macos with go 1.18
4 participants