Skip to content

Commit

Permalink
Merge pull request quarkusio#38004 from ozangunalp/fix_kafka_sasl_ely…
Browse files Browse the repository at this point in the history
…tron

Avoid integration-tests/kafka-sasl-elytron to modify test resources
  • Loading branch information
gsmet authored Jan 3, 2024
2 parents 2a07962 + 04d4a2c commit c770f23
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ quarkus.log.category.\"org.apache.zookeeper\".level=WARN

mp.messaging.connector.smallrye-kafka.security.protocol=SASL_PLAINTEXT
mp.messaging.connector.smallrye-kafka.sasl.mechanism=GSSAPI
mp.messaging.connector.smallrye-kafka.sasl.jaas.config=com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true debug=true serviceName="kafka" keyTab="src/test/resources/client.keytab" principal="client/[email protected]";
mp.messaging.connector.smallrye-kafka.sasl.jaas.config=com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true debug=true serviceName="kafka" keyTab="target/client.keytab" principal="client/[email protected]";
mp.messaging.connector.smallrye-kafka.sasl.kerberos.service.name=kafka
mp.messaging.connector.smallrye-kafka.ssl.endpoint.identification.algorithm=https

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.Map;

import org.jboss.logging.Logger;
import org.testcontainers.containers.BindMode;
import org.testcontainers.utility.MountableFile;

import io.quarkus.it.kafka.containers.KerberosContainer;
Expand Down Expand Up @@ -39,9 +38,10 @@ public Map<String, String> start() {
c -> String.format("SASL_PLAINTEXT://%s:%s", c.getHost(), c.getMappedPort(KAFKA_PORT)))
.withPort(KAFKA_PORT)
.withServerProperties(MountableFile.forClasspathResource("kafkaServer.properties"))
.withCopyFileToContainer(MountableFile.forClasspathResource("krb5KafkaBroker.conf"), "/etc/krb5.conf")
.withFileSystemBind("src/test/resources/kafkabroker.keytab", "/opt/kafka/config/kafkabroker.keytab",
BindMode.READ_ONLY);
.withCopyFileToContainer(MountableFile.forClasspathResource("krb5KafkaBroker.conf"),
"/etc/krb5.conf")
.withCopyFileToContainer(MountableFile.forHostPath("target/kafkabroker.keytab"),
"/opt/kafka/config/kafkabroker.keytab");
kafka.start();
log.info(kafka.getLogs());
properties.put("kafka.bootstrap.servers", kafka.getBootstrapServers());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.time.Duration;
import java.util.stream.Collectors;

import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.wait.strategy.Wait;
Expand All @@ -21,21 +20,23 @@ public KerberosContainer(String dockerImageName) {
withEnv("KRB5_KDC", "localhost");
withEnv("KRB5_PASS", "mypass");
withExposedPorts(749, 464, 88);
withFileSystemBind("src/test/resources/kafkabroker.keytab", "/tmp/keytab/kafkabroker.keytab", BindMode.READ_WRITE);
withFileSystemBind("src/test/resources/client.keytab", "/tmp/keytab/client.keytab", BindMode.READ_WRITE);
waitingFor(Wait.forLogMessage("Principal \"admin/[email protected]\" created.*", 1));
waitingFor(Wait.forListeningPorts(88));
withNetwork(Network.SHARED);
withNetworkAliases("kerberos");
}

public void createTestPrincipals() {
try {
ExecResult lsResult = execInContainer("kadmin.local", "-q", "addprinc -randkey kafka/[email protected]");
ExecResult lsResult = execInContainer("kadmin.local", "-q",
"addprinc -randkey kafka/[email protected]");
lsResult = execInContainer("kadmin.local", "-q",
"ktadd -norandkey -k /tmp/keytab/kafkabroker.keytab kafka/[email protected]");
lsResult = execInContainer("kadmin.local", "-q", "addprinc -randkey client/[email protected]");
"ktadd -norandkey -k /kafkabroker.keytab kafka/[email protected]");
lsResult = execInContainer("kadmin.local", "-q",
"ktadd -norandkey -k /tmp/keytab/client.keytab client/[email protected]");
"addprinc -randkey client/[email protected]");
lsResult = execInContainer("kadmin.local", "-q",
"ktadd -norandkey -k /client.keytab client/[email protected]");
copyFileFromContainer("/kafkabroker.keytab", "target/kafkabroker.keytab");
copyFileFromContainer("/client.keytab", "target/client.keytab");
} catch (Exception e) {
e.printStackTrace();
}
Expand Down

0 comments on commit c770f23

Please sign in to comment.