Skip to content

Commit

Permalink
Merge pull request #23795 from ozangunalp/fix_keycloak_oauth_test_nat…
Browse files Browse the repository at this point in the history
…ive_22_1

Fix kafka-oauth-keycloak test on GraalVM 22.1
  • Loading branch information
gsmet authored Feb 22, 2022
2 parents e55757e + 300342d commit 88c108f
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
import java.security.AccessControlContext;
import java.security.AccessController;
import java.util.concurrent.TimeUnit;
import java.util.function.BooleanSupplier;

import javax.security.auth.AuthPermission;
import javax.security.auth.Subject;
import javax.security.auth.SubjectDomainCombiner;

import org.graalvm.home.Version;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

@TargetClass(className = "javax.security.auth.Subject")
@TargetClass(className = "javax.security.auth.Subject", onlyWith = Target_javax_security_auth_Subject.Graal22_0OrEarlier.class)
final class Target_javax_security_auth_Subject {

@Substitute
Expand Down Expand Up @@ -96,4 +99,16 @@ final static class SubjectHolder {
.expireAfterAccess(1, TimeUnit.SECONDS)
.build();
}

/**
* 22.1.0 => false
* 22.0.0.2 => true
* 21.3.0 => true
*/
public static final class Graal22_0OrEarlier implements BooleanSupplier {
@Override
public boolean getAsBoolean() {
return Version.getCurrent().compareTo(22, 1) < 0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.MountableFile;

import com.github.dockerjava.api.command.InspectContainerResponse;

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 @@ -23,27 +21,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.

0 comments on commit 88c108f

Please sign in to comment.