[#12299] feat(server-common): CI-enforced tests for server-side HTTPS and mTLS - #12389
Conversation
…enerate.sh script to generate new certificates and keystores for testing. This is needed for the server-side HTTPS implementation. Note certificates are TEST ONLY and last 10 years. They are not valid for production use.
- Added missing license to README.md (rat passes) - Created TestTlsServerUtils.java to hold reusable utility methods for starting the Jetty server with optional client authentication for mTLS support. - Added TestHttpsServerAuthentication.java to test the Jetty server for TLS/mTLS support as well as standard http (Fufills all 7 requested tests). - Modified build.gradle.kts to include test + fixture publishing from server-common via test artifacts. Gradlew command to execute tests: ./gradlew :server-common:test --tests "org.apache.gravitino.server.web.TestHttpsServerAuthentication"
Bugbot (Cursor) on behalf of NevinAutomated Bugbot review of this PR ( Result: no bugs found. Scope checked: TLS/mTLS handshake tests, fixture layout, Local verification also green:
Nevin |
nevzheng
left a comment
There was a problem hiding this comment.
Overall
LGTM — thanks for a clean M1.
praise: Spec (#12299) followed closely, good style, and the seven handshake tests pin the right P0 CUJs. Keep shipping milestones like this and the TLS epic lands soon.
note (non-blocking): I did a deeper dive for other CUJs we might be missing against the shipped server HTTPS/mTLS path and didn’t find anything I’d classify as immediately actionable for this PR. We can iterate later if a gap shows up in M2+.
@roryqi PTAL
|
Could u avoid uploading the binary files? You should generate them in the tests instead of uploading them into the repo. Repo should manage the text files instead of binary files. Although they are not large, it still isn't a good practice. |
Code Coverage Report
Files
|
@roryqi I recommend just submitting the binary files as is. We do not need a more complex scheme to manage key files at this time. We have other concerns to address. The principle I’d like to highlight here is to keep things as simple as they need to be. If we ask for a change to generate key files every time that isn’t required we just delay the project without a product requirement that we need to satisfy. In my experience, storing test, artifacts alongside tests like this is perfectly normal. can you elaborate on your concerns? |
|
Thanks for the explanation. My concern is mainly about long-term maintainability. Binary fixtures are hard to review, diff, and version over time. If a certificate needs to be updated later, reviewers cannot easily tell what changed or whether the generated content still matches the documented intent. I agree that committing the binary files is simpler for this PR, but I do not think it is a good practice for this repo. Since the PR already includes a regeneration script and README, I would prefer that we keep the source/configuration for generating the certificates in the repo and generate the binary artifacts during the test/setup process instead of committing them directly. |
Hi @roryqi, I see what you mean, as in you can't easily read a binary file as a reviewer. I'm assuming it's probably from a security standpoint of the repo that you don't want to accept an unreadable file from a PR. I think the simplest fix, if you are willing to keep a binary implementation, would be to accept my PR without the trustores and submit your own pr after inspecting my regen script and running it on your end, then uploading the result. Before I had decided to use a stable fixture, I had attempted to implement generating a runtime trust store, but I had inquired if it was necessary after realizing it would take me some more time to research and learn what a good method would be. As of right now, I wouldn't recommend generating the test trust stores at runtime by trying to implement my regen script, as you would need to import X.509 api's, which would introduce a large dependency. I would also avoid using a bouncyhouse implementation too, simply because I think it would be possible to avoid adding any dependency at all if we use the JDK's keytool, which I'm already using to create the licenses for tests. Using keytool, I could implement generating a runtime trust store within my Util file pretty cleanly since it's already getting published and available across different test classes. The only downside is the fact that it would theoretically slow down tests, as they would need to be generated at least once per test class. I'm currently going to start working on M2 in the meantime, but if you'd like me to try the keytool approach, I could make the change. |
|
Thanks for the explanation. I do not think accepting the binary fixtures is the right direction here. This repo is maintained collaboratively by many people, so test assets should be reviewable and maintainable by future contributors, not only by the original author. For certificates/truststores, the important part is not just whether the current files work, but whether future reviewers can understand and verify how they were produced and what changed when they are regenerated. I am fine with using the JDK So my preference is:
Could you please try the |
|
@roryqi @Octavi00 Logging my recommendation so the decision is clear. I would approve this PR as-is, merge it, and move on. On the binary fixtures: I do not think generating them at test setup adds enough value to justify reworking this PR. The maintainability concerns (provenance, regeneration, inspectability) are already addressed by If we still want automated generation, please do it as a follow-up PR. That keeps this M1 diff focused and avoids delaying work that has already been blocked for a long time. Part of our responsibility as reviewers is to keep work moving. Prefer comments that make the change materially better — favor approving once a CL clearly improves the system, even if it is not perfect, and balance the importance of the suggestion against the need to make forward progress. For me, runtime fixture generation does not clear that bar relative to the delay cost on this milestone. |
|
OK, thanks for the recommendation. Since you are shepherding this issue, I will respect your judgment as much as possible. In general, I prefer to make a PR as complete as reasonably possible, especially because community contributors may not always be able to follow up later. That said, I still think my concern about committing binary test fixtures is valid from a long-term maintainability and reviewability perspective. However, to avoid blocking this work and to let you move it forward in the way you think is most practical, I am willing to compromise on this point for this PR. Let's merge this PR as-is, but we should optimize this in a follow-up PR by generating the keystore/truststore artifacts from reviewable source/configuration instead of committing the generated binaries. |
[Subtask] M1: CI-enforced tests for server-side HTTPS and mTLS
#12299
What changes were proposed in this pull request?
Fix: #12299
Does this PR introduce any user-facing change?
No user facing changes
How was this patch tested?
Ran:
./gradlew rat
Passed
./gradlew :server-common:test --tests "org.apache.gravitino.server.web.TestHttpsServerAuthentication"
Passed