-
-
Notifications
You must be signed in to change notification settings - Fork 628
Refactor CA unittests to focus on top-level IssueCertificate #8422
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
base: main
Are you sure you want to change the base?
Conversation
bf14a88
to
31c238e
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.
Generally looks good! A few small tweaks.
You say in the PR description the vast majority of tests now test IssueCertificate instead of the unexported functions. But I see some tests of the unexported functions do remain - is there a pattern to which ones had to stay?
None of the old tests had to stay. The pattern is that I left the ones which felt like they would provide a barrier against misuse of the helper functions in the brief period before the helpers are deleted. I'd be happy to delete those extra tests in this PR if you think it's appropriate to do so; it would make #8424 even cleaner. |
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'm okay with landing this as-is. That said:
The pattern is that I left the ones which felt like they would provide a barrier against misuse of the helper functions in the brief period before the helpers are deleted. I'd be happy to delete those extra tests in this PR if you think it's appropriate to do so;
I think deleting the extra tests in this PR makes sense. We've replaced low-level tests with tests of the publicly visible functionality, which I think is generally good. The exception of course is when an internal-only function is factored out because it makes a particularly good target for narrowly targeted unittesting. But that doesn't apply here; these internal helper functions are a matter of RPC structure, not optimizing for testability.
There's a wacky world out there somewhere in which between this change and the subsequent change landing, someone tries to add another call to issueCertificateForPrecertificate somewhere bad.
Hopefully in such a world we'd also be adding new tests of the top-level functionality that suffice to cover the new calls. :D
Fair enough, done! I do think it is good to keep the follow-up PR wholly focused on code changes, not test changes. It makes this PR's diff slightly harder to review, but going through it commit-by-commit should still be easy enough. |
Rewrite the vast majority of the CA unittests so that they test the exported functions (NewCertificateAuthorityImpl and IssueCertificate) rather than the non-exported helper functions (issuePrecertificate and issueCertificateForPrecertificate). This makes the tests more robust to future refactoring of the CA code itself, and will increase confidence in the correctness of those refactors.
Part of #8390