Repository navigation
certs: add unit tests and guard empty hosts in CreateSignedServingPair - #3944
sebrandon1 wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @sebrandon1. Thanks for your PR. I'm waiting for a operator-framework member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
pkg/controller/certs backs OLM's serving certificate rotation but had no test coverage. Add table-driven unit tests covering GenerateCA, CreateSignedServingPair, VerifyCert, Active, ToPEM, PEMToCert, PEMSHA256, and the CertGeneratorFunc adapter. CreateSignedServingPair indexed hosts[0] without a length check, so an empty hosts slice panicked. Return an error instead, following the same panic-to-error conversion as operator-framework#3904 and operator-framework#3899.
99851e9 to
a224987
Compare
Summary
pkg/controller/certs(previously zero coverage):GenerateCA,CreateSignedServingPair,VerifyCert,Active,ToPEM,PEMToCert,PEMSHA256, and theCertGeneratorFuncadapter.CreateSignedServingPairagainst an emptyhostsslice:CommonName: hosts[0]indexed without a length check and panicked with index out of range; it now returns an error.Motivation
pkg/controller/certsbacks OLM's serving certificate rotation and the CA bundles for its webhooks, but had no tests. Every function in the package is pure crypto, so it can be covered without cluster fixtures.The empty-hosts guard follows the panic-to-error conversions in #3904 and #3899: the sole caller (
pkg/controller/install/certresources.go:30) consumes it through thecerts.CertGeneratorinterface and already handles errors, so a bad input now surfaces as a reconciliation error instead of a crash.Testing
go test ./pkg/controller/certs/... -race -count=1— 16 tests passgo vet ./pkg/controller/certs/...,gofmt -l pkg/controller/certs/— cleanNo behavior change for any input that previously succeeded; the only new path is the empty-hosts error return.
Summary by CodeRabbit
Bug Fixes
Tests