Repository navigation
Respect user-defined security protocol for additional Kafka listeners - #12108
SamuelAdigos wants to merge 1 commit into
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
| Layer / File(s) | Summary |
|---|---|
Preserve configured listener protocol modules/kafka/src/main/java/org/testcontainers/kafka/KafkaHelper.java, modules/kafka/src/test/java/org/testcontainers/kafka/ConfluentKafkaContainerTest.java |
resolveListeners checks for a trimmed, case-insensitive mapping for the generated protocol before adding a PLAINTEXT entry. The integration test configures TC-0 as SASL_PLAINTEXT with PLAIN authentication and checks functionality through the proxy. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers: eddumelendez
Merge Risk: 
Minimal · previous review 3de32
-
Additional Kafka listeners now keep the security protocol the user configured, and the default is unchanged when none is set. No merge-blocking risk was found.
Pre-merge checks | 
4 | 
1
-
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
-
✨ Finishing Touches: 💡 1
-
🛠️ Fix failing CI checks: 💡
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
`KafkaHelper` always appended `TC-<n>:PLAINTEXT` to `KAFKA_LISTENER_SECURITY_PROTOCOL_MAP` for listeners registered via `withListener(...)`, even when the user had already mapped that listener (e.g. `TC-0:SASL_PLAINTEXT`). Kafka then used `PLAINTEXT`, so additional listeners could not be secured. The default mapping is now only added when no mapping exists for the listener, matched case-insensitively as Kafka normalises listener names. Fixes testcontainers#10035
3de32b4 to
034990c
Compare
Fixes #10035
When a listener is registered via
withListener(...),KafkaHelperalways appendedTC-<n>:PLAINTEXTtoKAFKA_LISTENER_SECURITY_PROTOCOL_MAP, even if the user had already mapped that listener (e.g.TC-0:SASL_PLAINTEXT).The map then contained the listener twice and Kafka used
PLAINTEXT, so additional listeners could not be securedwithout overriding
configure().The default
TC-<n>:PLAINTEXTmapping is now only added when the user has not configured one for that listener(matched case-insensitively, as Kafka normalises listener names). Default behaviour is unchanged.
This applies to both
org.testcontainers.kafka.KafkaContainerandConfluentKafkaContainer; the deprecatedorg.testcontainers.containers.KafkaContaineris left untouched.Tests
ConfluentKafkaContainerTest.shouldKeepSecurityProtocolConfiguredForListener: mapsTC-0toSASL_PLAINTEXTand produces/consumes through that listener with SASL/PLAIN (fails before the fix).
./gradlew :testcontainers-kafka:checkplus spotless/checkstyle/japicmp.testMatrixlocally; remaining failures are environment-related (arm64 host, Rancher Desktop)and reproduce on
main.Summary by CodeRabbit