Repository navigation
Conversation
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
This PR aligns K8sCertService.createCert with updateCert by applying normalizeOptionalIdentity() to k8sId, cluster, and issuer fields on create. Previously, whitespace-only values were silently accepted and stored padded on create, but rejected on update — an asymmetry that could make certificates unfindable by identity.
The certificateSupplied extraction is a clean refactor, and the issuer handling is correct: when a PEM cert is provided, the issuer is derived from the cert itself, so the caller-provided value is irrelevant.
Comprehensive tests cover both blank rejection and whitespace trimming for all three identity fields. LGTM.
Automated review by github-manager-bot
|
Whole-suite comparison, added for completeness ( The two added tests are the new ones; the failing ids are identical on both sides and unrelated to this |
createCert stored k8sId, cluster and issuer verbatim, so a whitespace-only issuer was accepted and padded identities were persisted, while updateCert trims them and rejects a blank value. (cherry picked from commit 891344f)
891344f to
5a6d582
Compare
What is the purpose of the change
Fixes #4299.
K8sCertService.createCertpassedk8sId,clusterandissuerstraight from the request into thestored entity, while
updateCertsends the same three fields throughnormalizeOptionalIdentity(trim, reject blank with
400 Certificate <field> cannot be blank). A whitespace-onlyissuerwastherefore accepted and stored padded on create, and could not be reproduced through update.
Brief changelog
server/src/main/java/org/apache/rocketmq/studio/cluster/k8s/K8sCertService.javacreateCertnormalisesk8sIdandclusterwithnormalizeOptionalIdentity, the helper theupdate path already uses.
issueris normalised the same way when the create carries nocertPem; a supplied certificatestill overrides the submitted issuer/SAN with its parsed values, so the upload flow is unchanged.
server/src/test/java/org/apache/rocketmq/studio/cluster/k8s/K8sCertServiceTest.javacreateCertShouldRejectBlankIdentityFields, mirroring the existingupdateCertShouldRejectBlankIdentityFields.createCertShouldTrimIdentityFieldsLikeUpdateDoes.Verification
Red, before the fix (
mvn -o -f server/pom.xml test -Dtest=K8sCertServiceTest):Green, after the fix (
mvn -o -f server/pom.xml test -Dtest=K8sCertServiceTest,K8sCertControllerTest):K8sCertControllerTest(11 tests) is included because it drives the create/update endpoints end to endand confirms the certificate-upload path is unaffected.
AI disclosure
Drafted with AI assistance (analysis, patch and test authoring); the red and green Maven output above
was executed and observed locally on Windows, JDK 21.