chia7712 commented on code in PR #17671:
URL: https://github.com/apache/kafka/pull/17671#discussion_r1905506205
##########
test-common/src/main/java/org/apache/kafka/common/test/KafkaClusterTestKit.java:
##########
@@ -602,6 +637,13 @@ public void close() throws Exception {
waitForAllFutures(futureEntries);
futureEntries.clear();
Utils.delete(baseDirectory);
+ jaasFile.ifPresent(f -> {
+ try {
Review Comment:
To enhance readability, we should explore alternatives to nested try-catch
blocks, even if it involves using a more traditional coding style. for example:
`if (jaasFile.isPresent()) Utils.delete(jaasFile.get());`
##########
test-common/src/main/java/org/apache/kafka/common/test/JaasUtils.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.common.test;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import javax.security.auth.login.Configuration;
+
+public class JaasUtils {
+ public record JaasSection(String contextName, List<JaasModule> modules) {
+ @Override
+ public String toString() {
+ return String.format(
+ "%s {%n %s%n};%n",
+ contextName,
+
modules.stream().map(Object::toString).collect(Collectors.joining("\n "))
+ );
+ }
+ }
+
+ public static final String KAFKA_SERVER_CONTEXT_NAME = "KafkaServer";
+
+ public static final String KAFKA_PLAIN_USER1 = "plain-user1";
+ public static final String KAFKA_PLAIN_USER1_PASSWORD =
"plain-user1-secret";
+ public static final String KAFKA_PLAIN_ADMIN = "plain-admin";
+ public static final String KAFKA_PLAIN_ADMIN_PASSWORD =
"plain-admin-secret";
+
+ public static File writeJaasContextsToFile(Map<String, JaasSection>
jaasSections) throws IOException {
Review Comment:
It seems we don't use the `key`, so maybe we can change the collection from
Map to Set?
##########
test-common/test-common-api/src/test/java/org/apache/kafka/common/test/api/ClusterTestExtensionsTest.java:
##########
@@ -331,4 +344,111 @@ public void testControllerListenerName(ClusterInstance
cluster) throws Execution
assertEquals(1,
admin.describeMetadataQuorum().quorumInfo().get().nodes().size());
}
}
+
+ @ClusterTest(
+ types = {Type.KRAFT, Type.CO_KRAFT},
+ brokerSecurityProtocol = SecurityProtocol.SASL_PLAINTEXT,
+ controllerSecurityProtocol = SecurityProtocol.SASL_PLAINTEXT,
Review Comment:
Do we support the `SASL_PLAINTEXT` on controller? If not, could you please
remove this config and open a jira for it?
--
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]