btlqql opened a new pull request, #4300:
URL: https://github.com/apache/rocketmq-dashboard/pull/4300
## What is the purpose of the change
Fixes #4299.
`K8sCertService.createCert` passed `k8sId`, `cluster` and `issuer` straight
from the request into the
stored entity, while `updateCert` sends the same three fields through
`normalizeOptionalIdentity`
(trim, reject blank with `400 Certificate <field> cannot be blank`). A
whitespace-only `issuer` was
therefore 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.java`
- `createCert` normalises `k8sId` and `cluster` with
`normalizeOptionalIdentity`, the helper the
update path already uses.
- `issuer` is normalised the same way when the create carries no
`certPem`; a supplied certificate
still 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.java`
- New `createCertShouldRejectBlankIdentityFields`, mirroring the existing
`updateCertShouldRejectBlankIdentityFields`.
- New `createCertShouldTrimIdentityFieldsLikeUpdateDoes`.
## Verification
Red, before the fix (`mvn -o -f server/pom.xml test
-Dtest=K8sCertServiceTest`):
```
[ERROR] Tests run: 20, Failures: 2, Errors: 0, Skipped: 0, Time elapsed:
1.845 s <<< FAILURE! -- in
org.apache.rocketmq.studio.cluster.k8s.K8sCertServiceTest
Expecting actual throwable to be an instance of:
but was:
but was: " new-tls-cert "
[ERROR] K8sCertServiceTest.createCertShouldRejectBlankIdentityFields:214
Expecting actual throwable to be an instance of:
but was:
[ERROR]
K8sCertServiceTest.createCertShouldTrimIdentityFieldsLikeUpdateDoes:234
[ERROR] Tests run: 20, Failures: 2, Errors: 0, Skipped: 0
[INFO] BUILD FAILURE
```
Green, after the fix (`mvn -o -f server/pom.xml test
-Dtest=K8sCertServiceTest,K8sCertControllerTest`):
```
[INFO] Tests run: 11, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:
6.850 s -- in org.apache.rocketmq.studio.cluster.k8s.K8sCertControllerTest
[INFO] Tests run: 20, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:
0.723 s -- in org.apache.rocketmq.studio.cluster.k8s.K8sCertServiceTest
[INFO] Tests run: 31, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS
```
`K8sCertControllerTest` (11 tests) is included because it drives the
create/update endpoints end to end
and 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]