Skip to content

Conversation

aarongable
Copy link
Contributor

@aarongable aarongable commented Oct 1, 2025

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

@aarongable aarongable force-pushed the issue-certificate-tests branch from bf14a88 to 31c238e Compare October 2, 2025 00:17
@aarongable aarongable marked this pull request as ready for review October 2, 2025 17:32
@aarongable aarongable requested a review from a team as a code owner October 2, 2025 17:32
@aarongable aarongable requested a review from jprenken October 2, 2025 17:32
jprenken
jprenken previously approved these changes Oct 3, 2025
@jprenken jprenken requested a review from jsha October 3, 2025 03:25
Copy link
Contributor

@jsha jsha left a 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?

@aarongable
Copy link
Contributor Author

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.

jsha
jsha previously approved these changes Oct 3, 2025
Copy link
Contributor

@jsha jsha left a 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

@aarongable
Copy link
Contributor Author

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.

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.

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