-
Notifications
You must be signed in to change notification settings - Fork 7
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
fix(windows-agent): Generate test certificates dynamically #398
Conversation
This certificate has an expiry date, which is not very convenient for tests.
This way we prevent test coupling.
a1bea40
to
f504541
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor nitpick IMHO that worths debating, but this is exactly what we needed for the tests. Thanks for looking at it!
@@ -108,18 +134,15 @@ func TestConnect(t *testing.T) { | |||
landscapeAgentUID: tc.uid, | |||
} | |||
|
|||
out, err := os.ReadFile(filepath.Join(golden.TestFixturePath(t), "landscape.conf")) | |||
in, err := os.ReadFile(filepath.Join(golden.TestFixturePath(t), "landscape.conf")) | |||
if errors.Is(err, os.ErrNotExist) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we reverse the logic? Like:
- set default
- load override if exists (so changing to err == nil). I agree that we then silence require.NoError for any other kinds of error and fallback to default config. I’m happy to have counter-arguments, but I still find loading default and then overriding being way more logical (I had to reread twice) :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, default then override is the Go way :)
SerialNumber: big.NewInt(1), | ||
Subject: pkix.Name{ | ||
CommonName: "CanonicalGroupLimited", | ||
Country: []string{"US"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UK? :p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually based it on what we use in the app manifest 😅:
Although I think we could set it to Narnia and it'd still work 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Narnia
Thanks for letting me once again feel old :p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's from the 1950's, you're not that old!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last typo to fix and you can rebase/merge!
We were modifying the fixtures too much: - find and replace for certificate - appending the hostagent URL section This meant that the config in the fixture bore little similarity to the one being used in the end. I switched to templates for the sake of clarity. Now the fixtures look much more like the final config.
31f6489
to
48e3800
Compare
Applied suggestion and did some squashing. |
The certificates used in Landscape tests had an expiration date, which I did not notice. This expiration date has arrived and the tests are now failing.
This PR fixes this by generating the certificate dynamically in every test run.
UDENG-1719