Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kafka Oauth test bump Keycloak container version to 16.1.1 & leverage… #3619

Merged
merged 1 commit into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion integration-tests/kafka-oauth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.strimzi</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,24 @@
import java.util.Map;

import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
import org.apache.camel.quarkus.kafka.oauth.it.container.KafkaContainer;
import io.strimzi.test.container.StrimziKafkaContainer;
import org.apache.camel.quarkus.kafka.oauth.it.container.KeycloakContainer;
import org.jboss.logging.Logger;
import org.testcontainers.utility.MountableFile;

import static io.strimzi.test.container.StrimziKafkaContainer.KAFKA_PORT;

/**
* Inspired from https://github.com/quarkusio/quarkus/tree/main/integration-tests/kafka-oauth-keycloak/
*/
public class KafkaKeycloakTestResource implements QuarkusTestResourceLifecycleManager {

private static final Logger log = Logger.getLogger(KafkaKeycloakTestResource.class);
private KafkaContainer kafka;
private StrimziKafkaContainer kafka;
private KeycloakContainer keycloak;

@Override
public Map<String, String> start() {

Map<String, String> properties = new HashMap<>();

//Start keycloak container
Expand All @@ -45,10 +47,16 @@ public Map<String, String> start() {
keycloak.createHostsFile();

//Start kafka container
kafka = new KafkaContainer();
kafka.start();
log.info(kafka.getLogs());
properties.put("kafka.bootstrap.servers", kafka.getBootstrapServers());
this.kafka = new StrimziKafkaContainer("quay.io/strimzi/kafka:latest-kafka-3.0.0")
.withBrokerId(1)
.withKafkaConfigurationMap(Map.of("listener.security.protocol.map", "JWT:SASL_PLAINTEXT,BROKER1:PLAINTEXT"))
.withNetworkAliases("kafka")
.withServerProperties(MountableFile.forClasspathResource("kafkaServer.properties"))
.withBootstrapServers(
c -> String.format("JWT://%s:%s", c.getContainerIpAddress(), c.getMappedPort(KAFKA_PORT)));
this.kafka.start();
log.info(this.kafka.getLogs());
properties.put("kafka.bootstrap.servers", this.kafka.getBootstrapServers());
properties.put("camel.component.kafka.brokers", kafka.getBootstrapServers());

return properties;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.io.FileWriter;

import com.github.dockerjava.api.command.InspectContainerResponse;
import org.testcontainers.containers.FixedHostPortGenericContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.wait.strategy.Wait;
Expand All @@ -30,7 +29,7 @@
public class KeycloakContainer extends FixedHostPortGenericContainer<KeycloakContainer> {

public KeycloakContainer() {
super("quay.io/keycloak/keycloak:15.0.2");
super("quay.io/keycloak/keycloak:16.1.1");
withExposedPorts(8443);
withFixedExposedPort(8080, 8080);
withEnv("KEYCLOAK_USER", "admin");
Expand All @@ -41,27 +40,9 @@ public KeycloakContainer() {
waitingFor(Wait.forLogMessage(".*WFLYSRV0025.*", 1));
withNetwork(Network.SHARED);
withNetworkAliases("keycloak");
withCreateContainerCmdModifier(cmd -> {
cmd.withEntrypoint("");
cmd.withCmd("/bin/bash", "-c", "cd /opt/jboss/keycloak " +
"&& bin/jboss-cli.sh --file=ssl/keycloak-ssl.cli " +
"&& rm -rf standalone/configuration/standalone_xml_history/current " +
"&& cd .. " +
"&& /opt/jboss/tools/docker-entrypoint.sh -Dkeycloak.profile.feature.upload_scripts=enabled -b 0.0.0.0");
});
}

@Override
protected void containerIsStarting(InspectContainerResponse containerInfo, boolean reused) {
super.containerIsStarting(containerInfo);
copyFileToContainer(MountableFile.forClasspathResource("certificates/ca-truststore.p12"),
"/opt/jboss/keycloak/standalone/configuration/certs/ca-truststore.p12");
copyFileToContainer(MountableFile.forClasspathResource("certificates/keycloak.server.keystore.p12"),
"/opt/jboss/keycloak/standalone/configuration/certs/keycloak.server.keystore.p12");
copyFileToContainer(MountableFile.forClasspathResource("keycloak/scripts/keycloak-ssl.cli"),
"/opt/jboss/keycloak/ssl/keycloak-ssl.cli");
copyFileToContainer(MountableFile.forClasspathResource("keycloak/realms/kafka-authz-realm.json"),
withCopyFileToContainer(MountableFile.forClasspathResource("keycloak/realms/kafka-authz-realm.json"),
"/opt/jboss/keycloak/realms/kafka-authz-realm.json");
withCommand("-Dkeycloak.profile.feature.upload_scripts=enabled", "-b", "0.0.0.0");
}

public void createHostsFile() {
Expand Down

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.