KEYCLOAK-1678 Fixed app-server containers' handling.
This commit is contained in:
parent
3a51b3530d
commit
58084d5ee5
7 changed files with 225 additions and 135 deletions
|
@ -4,7 +4,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import org.jboss.arquillian.container.spi.Container;
|
import org.jboss.arquillian.container.spi.event.container.BeforeDeploy;
|
||||||
import org.jboss.arquillian.container.test.api.ContainerController;
|
import org.jboss.arquillian.container.test.api.ContainerController;
|
||||||
import org.jboss.arquillian.core.api.Instance;
|
import org.jboss.arquillian.core.api.Instance;
|
||||||
import org.jboss.arquillian.core.api.InstanceProducer;
|
import org.jboss.arquillian.core.api.InstanceProducer;
|
||||||
|
@ -34,16 +34,15 @@ public class AppServerTestEnricher {
|
||||||
private InstanceProducer<TestContext> testContextProducer;
|
private InstanceProducer<TestContext> testContextProducer;
|
||||||
private TestContext testContext;
|
private TestContext testContext;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private Instance<ContainerController> containerController;
|
|
||||||
|
|
||||||
public static String getAppServerQualifier(Class testClass) {
|
public static String getAppServerQualifier(Class testClass) {
|
||||||
Class<? extends AuthServerTestEnricher> annotatedClass = getNearestSuperclassWithAnnotation(testClass, AppServerContainer.class);
|
Class<? extends AuthServerTestEnricher> annotatedClass = getNearestSuperclassWithAnnotation(testClass, AppServerContainer.class);
|
||||||
|
|
||||||
String appServerQ = (annotatedClass == null ? null
|
String appServerQ = (annotatedClass == null ? null
|
||||||
: annotatedClass.getAnnotation(AppServerContainer.class).value());
|
: annotatedClass.getAnnotation(AppServerContainer.class).value());
|
||||||
|
|
||||||
return appServerQ;
|
return appServerQ == null || appServerQ.isEmpty()
|
||||||
|
? getAuthServerQualifier() // app server == auth server
|
||||||
|
: appServerQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getAppServerContextRoot() {
|
public static String getAppServerContextRoot() {
|
||||||
|
@ -60,12 +59,26 @@ public class AppServerTestEnricher {
|
||||||
: "http://localhost:" + (httpPort + clusterPortOffset);
|
: "http://localhost:" + (httpPort + clusterPortOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ContainerInfo initializeAppServerInfo(Container appServerContainer) {
|
public void updateTestContextWithAppServerInfo(@Observes(precedence = 1) BeforeClass event) {
|
||||||
return initializeAppServerInfo(appServerContainer, 0);
|
testContext = testContextProducer.get();
|
||||||
|
String appServerQualifier = getAppServerQualifier(testContext.getTestClass());
|
||||||
|
for (ContainerInfo container : testContext.getSuiteContext().getContainers()) {
|
||||||
|
if (container.getQualifier().equals(appServerQualifier)) {
|
||||||
|
testContext.setAppServerInfo(updateWithAppServerInfo(container));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// validate app server
|
||||||
|
if (appServerQualifier != null && testContext.getAppServerInfo() == null) {
|
||||||
|
throw new RuntimeException(String.format("No app server container matching '%s' was activated. Check if defined and enabled in arquillian.xml.", appServerQualifier));
|
||||||
|
}
|
||||||
|
log.info("\n\n" + testContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ContainerInfo initializeAppServerInfo(Container appServerContainer, int clusterPortOffset) {
|
private ContainerInfo updateWithAppServerInfo(ContainerInfo appServerInfo) {
|
||||||
ContainerInfo appServerInfo = new ContainerInfo(appServerContainer);
|
return updateWithAppServerInfo(appServerInfo, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ContainerInfo updateWithAppServerInfo(ContainerInfo appServerInfo, int clusterPortOffset) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String appServerContextRootStr = isRelative(testContext.getTestClass())
|
String appServerContextRootStr = isRelative(testContext.getTestClass())
|
||||||
|
@ -80,67 +93,74 @@ public class AppServerTestEnricher {
|
||||||
return appServerInfo;
|
return appServerInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTestContextWithAppServerInfo(@Observes BeforeClass event) {
|
@Inject
|
||||||
testContext = testContextProducer.get();
|
private Instance<ContainerController> containerConrollerInstance;
|
||||||
String appServerQualifier = getAppServerQualifier(testContext.getTestClass());
|
|
||||||
for (Container container : testContext.getSuiteContext().getArquillianContainers()) {
|
|
||||||
if (container.getContainerConfiguration().getContainerName().equals(appServerQualifier)) {
|
|
||||||
testContext.setAppServerInfo(initializeAppServerInfo(container));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// validate app server
|
|
||||||
if (appServerQualifier != null && testContext.getAppServerInfo() == null) {
|
|
||||||
throw new RuntimeException(String.format("No app server container matching '%s' was activated. Check if defined and enabled in arquillian.xml.", appServerQualifier));
|
|
||||||
}
|
|
||||||
log.info("\n\n" + testContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startAppServer(@Observes(precedence = -1) BeforeClass event) throws MalformedURLException, InterruptedException, IOException {
|
public void startAppServer(@Observes(precedence = -1) BeforeClass event) throws MalformedURLException, InterruptedException, IOException {
|
||||||
ContainerController controller = containerController.get();
|
|
||||||
if (testContext.isAdapterTest()) {
|
if (testContext.isAdapterTest()) {
|
||||||
String appServerQualifier = testContext.getAppServerInfo().getQualifier();
|
ContainerController controller = containerConrollerInstance.get();
|
||||||
if (!controller.isStarted(appServerQualifier)) {
|
if (!controller.isStarted(testContext.getAppServerInfo().getQualifier())) {
|
||||||
controller.start(appServerQualifier);
|
controller.start(testContext.getAppServerInfo().getQualifier());
|
||||||
}
|
}
|
||||||
log.info("\n\n\nAPP SERVER STARTED\n\n\n");
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void installAdapterLibs(@Observes BeforeDeploy event) {
|
||||||
|
log.info("BEFORE DEPLOY");
|
||||||
|
if (testContext.isAdapterTest()) {
|
||||||
// install adapter libs on JBoss-based container via CLI
|
// install adapter libs on JBoss-based container via CLI
|
||||||
// if (testContext.getAppServerInfo().isJBossBased()) {
|
if (testContext.getAppServerInfo().isJBossBased()) {
|
||||||
installAdapterLibsUsingJBossCLIClient(testContext.getAppServerInfo());
|
try {
|
||||||
// }
|
installAdapterLibsUsingJBossCLIClient(testContext.getAppServerInfo());
|
||||||
|
} catch (InterruptedException | IOException ex) {
|
||||||
|
throw new RuntimeException("Failed to install adapter libs.", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void installAdapterLibsUsingJBossCLIClient(ContainerInfo appServerInfo) throws InterruptedException, IOException {
|
private void installAdapterLibsUsingJBossCLIClient(ContainerInfo appServerInfo) throws InterruptedException, IOException {
|
||||||
|
if (!appServerInfo.isAdapterLibsInstalled()) {
|
||||||
log.info("Installing adapter via CLI client");
|
|
||||||
|
|
||||||
if (!appServerInfo.isJBossBased()) {
|
|
||||||
throw new IllegalArgumentException("App server must be JBoss-based to run jboss-cli-client.");
|
|
||||||
}
|
|
||||||
|
|
||||||
String jbossHomePath = appServerInfo.getProperties().get("jbossHome");
|
if (!appServerInfo.isJBossBased()) {
|
||||||
|
throw new IllegalArgumentException("App server must be JBoss-based to run jboss-cli-client.");
|
||||||
|
}
|
||||||
|
|
||||||
File bin = new File(jbossHomePath + "/bin");
|
String jbossHomePath = appServerInfo.getProperties().get("jbossHome");
|
||||||
String command = "java -jar " + jbossHomePath + "/bin/client/jboss-cli-client.jar";
|
|
||||||
String adapterScript = "adapter-install.cli";
|
|
||||||
String samlAdapterScript = "adapter-install-saml.cli";
|
|
||||||
String managementPort = appServerInfo.getProperties().get("managementPort");
|
|
||||||
|
|
||||||
String controllerArg = " --controller=localhost:" + managementPort;
|
File bin = new File(jbossHomePath + "/bin");
|
||||||
if (new File(bin, adapterScript).exists()) {
|
|
||||||
log.info("Installing adapter to app server via cli script");
|
File clientJar = new File(jbossHomePath + "/bin/client/jboss-cli-client.jar");
|
||||||
execCommand(command + " --connect --file=" + adapterScript + controllerArg, bin);
|
if (!clientJar.exists()) {
|
||||||
}
|
clientJar = new File(jbossHomePath + "/bin/client/jboss-client.jar"); // AS7
|
||||||
if (new File(bin, samlAdapterScript).exists()) {
|
}
|
||||||
log.info("Installing saml adapter to app server via cli script");
|
if (!clientJar.exists()) {
|
||||||
execCommand(command + " --connect --file=" + samlAdapterScript + controllerArg, bin);
|
throw new IOException("JBoss CLI client JAR not found.");
|
||||||
}
|
}
|
||||||
if (new File(bin, adapterScript).exists() || new File(bin, samlAdapterScript).exists()) {
|
|
||||||
log.info("Restarting container");
|
String command = "java -jar " + clientJar.getAbsolutePath();
|
||||||
execCommand(command + " --connect --command=reload" + controllerArg, bin);
|
String adapterScript = "adapter-install.cli";
|
||||||
log.info("Container restarted");
|
String samlAdapterScript = "adapter-install-saml.cli";
|
||||||
pause(5000);
|
String managementPort = appServerInfo.getProperties().get("managementPort");
|
||||||
LogChecker.checkJBossServerLog(jbossHomePath);
|
|
||||||
|
String controllerArg = " --controller=localhost:" + managementPort;
|
||||||
|
if (new File(bin, adapterScript).exists()) {
|
||||||
|
log.info("Installing adapter to app server via cli script");
|
||||||
|
execCommand(command + " --connect --file=" + adapterScript + controllerArg, bin);
|
||||||
|
}
|
||||||
|
if (new File(bin, samlAdapterScript).exists()) {
|
||||||
|
log.info("Installing saml adapter to app server via cli script");
|
||||||
|
execCommand(command + " --connect --file=" + samlAdapterScript + controllerArg, bin);
|
||||||
|
}
|
||||||
|
if (new File(bin, adapterScript).exists() || new File(bin, samlAdapterScript).exists()) {
|
||||||
|
log.info("Restarting container");
|
||||||
|
execCommand(command + " --connect --command=reload" + controllerArg, bin);
|
||||||
|
log.info("Container restarted");
|
||||||
|
pause(5000);
|
||||||
|
LogChecker.checkJBossServerLog(jbossHomePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
appServerInfo.setAdapterLibsInstalled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,8 @@ package org.keycloak.testsuite.arquillian;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jboss.arquillian.container.spi.Container;
|
import org.jboss.arquillian.container.spi.Container;
|
||||||
import org.jboss.arquillian.container.spi.ContainerRegistry;
|
import org.jboss.arquillian.container.spi.ContainerRegistry;
|
||||||
|
@ -44,79 +45,87 @@ import org.keycloak.testsuite.util.LogChecker;
|
||||||
* @author vramik
|
* @author vramik
|
||||||
*/
|
*/
|
||||||
public class AuthServerTestEnricher {
|
public class AuthServerTestEnricher {
|
||||||
|
|
||||||
protected final Logger log = Logger.getLogger(this.getClass());
|
protected final Logger log = Logger.getLogger(this.getClass());
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Instance<ContainerRegistry> containerRegistry;
|
private Instance<ContainerRegistry> containerRegistry;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Instance<ContainerController> containerController;
|
private Instance<ContainerController> containerController;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Event<StartContainer> startContainerEvent;
|
private Event<StartContainer> startContainerEvent;
|
||||||
|
|
||||||
private static final String AUTH_SERVER_CONTAINER_PROPERTY = "auth.server.container";
|
private static final String AUTH_SERVER_CONTAINER_PROPERTY = "auth.server.container";
|
||||||
private static final String AUTH_SERVER_CONTAINER_DEFAULT = "auth-server-undertow";
|
private static final String AUTH_SERVER_CONTAINER_DEFAULT = "auth-server-undertow";
|
||||||
|
|
||||||
private static final String MIGRATED_AUTH_SERVER_CONTAINER_PROPERTY = "migrated.auth.server.container";
|
private static final String MIGRATED_AUTH_SERVER_CONTAINER_PROPERTY = "migrated.auth.server.container";
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@SuiteScoped
|
@SuiteScoped
|
||||||
private InstanceProducer<SuiteContext> suiteContextProducer;
|
private InstanceProducer<SuiteContext> suiteContextProducer;
|
||||||
private SuiteContext suiteContext;
|
private SuiteContext suiteContext;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ClassScoped
|
@ClassScoped
|
||||||
private InstanceProducer<TestContext> testContextProducer;
|
private InstanceProducer<TestContext> testContextProducer;
|
||||||
|
|
||||||
public static String getAuthServerQualifier() {
|
public static String getAuthServerQualifier() {
|
||||||
return System.getProperty(AUTH_SERVER_CONTAINER_PROPERTY, AUTH_SERVER_CONTAINER_DEFAULT);
|
return System.getProperty(AUTH_SERVER_CONTAINER_PROPERTY, AUTH_SERVER_CONTAINER_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getMigratedAuthServerQualifier() {
|
public static String getMigratedAuthServerQualifier() {
|
||||||
return System.getProperty(MIGRATED_AUTH_SERVER_CONTAINER_PROPERTY); // == null if migration not enabled
|
return System.getProperty(MIGRATED_AUTH_SERVER_CONTAINER_PROPERTY); // == null if migration not enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getAuthServerContextRoot() {
|
public static String getAuthServerContextRoot() {
|
||||||
return getAuthServerContextRoot(0);
|
return getAuthServerContextRoot(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getAuthServerContextRoot(int clusterPortOffset) {
|
public static String getAuthServerContextRoot(int clusterPortOffset) {
|
||||||
int httpPort = Integer.parseInt(System.getProperty("auth.server.http.port")); // property must be set
|
int httpPort = Integer.parseInt(System.getProperty("auth.server.http.port")); // property must be set
|
||||||
int httpsPort = Integer.parseInt(System.getProperty("auth.server.https.port")); // property must be set
|
int httpsPort = Integer.parseInt(System.getProperty("auth.server.https.port")); // property must be set
|
||||||
boolean sslRequired = Boolean.parseBoolean(System.getProperty("auth.server.ssl.required"));
|
boolean sslRequired = Boolean.parseBoolean(System.getProperty("auth.server.ssl.required"));
|
||||||
|
|
||||||
return sslRequired
|
return sslRequired
|
||||||
? "https://localhost:" + (httpsPort + clusterPortOffset)
|
? "https://localhost:" + (httpsPort + clusterPortOffset)
|
||||||
: "http://localhost:" + (httpPort + clusterPortOffset);
|
: "http://localhost:" + (httpPort + clusterPortOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initializeSuiteContext(@Observes(precedence = 2) BeforeSuite event) {
|
public void initializeSuiteContext(@Observes(precedence = 2) BeforeSuite event) {
|
||||||
suiteContext = new SuiteContext(new ArrayList<>(containerRegistry.get().getContainers()));
|
|
||||||
|
Set<ContainerInfo> containers = new LinkedHashSet<>();
|
||||||
|
for (Container c : containerRegistry.get().getContainers()) {
|
||||||
|
containers.add(new ContainerInfo(c));
|
||||||
|
}
|
||||||
|
|
||||||
|
suiteContext = new SuiteContext(containers);
|
||||||
|
|
||||||
String authServerQualifier = getAuthServerQualifier();
|
String authServerQualifier = getAuthServerQualifier();
|
||||||
String migratedAuthServerQualifier = getMigratedAuthServerQualifier();
|
String migratedAuthServerQualifier = getMigratedAuthServerQualifier();
|
||||||
|
|
||||||
// init authServerInfo and authServerBackendsInfo
|
// init authServerInfo and authServerBackendsInfo
|
||||||
if (authServerQualifier.startsWith("auth-server-")) {
|
if (authServerQualifier.startsWith("auth-server-")) {
|
||||||
|
|
||||||
boolean authServerCluster = authServerQualifier.endsWith("-cluster");
|
boolean authServerCluster = authServerQualifier.endsWith("-cluster");
|
||||||
|
|
||||||
String authServerType = authServerQualifier.replaceAll("^auth-server-", "").replaceAll("-cluster$", "");
|
String authServerType = authServerQualifier.replaceAll("^auth-server-", "").replaceAll("-cluster$", "");
|
||||||
String authServerFrontend = authServerCluster
|
String authServerFrontend = authServerCluster
|
||||||
? "auth-server-" + authServerType + "-balancer" // in cluster mode the load-balancer container serves as auth server frontend
|
? "auth-server-" + authServerType + "-balancer" // in cluster mode the load-balancer container serves as auth server frontend
|
||||||
: authServerQualifier; // single-node mode
|
: authServerQualifier; // single-node mode
|
||||||
String authServerBackend = "auth-server-" + authServerType + "-backend";
|
String authServerBackend = "auth-server-" + authServerType + "-backend";
|
||||||
int backends = 0;
|
int backends = 0;
|
||||||
for (Container container : suiteContext.getArquillianContainers()) {
|
for (ContainerInfo container : suiteContext.getContainers()) {
|
||||||
// frontend
|
// frontend
|
||||||
if (container.getContainerConfiguration().getContainerName().equals(authServerFrontend)) {
|
if (container.getQualifier().equals(authServerFrontend)) {
|
||||||
suiteContext.setAuthServerInfo(initializeAuthServerInfo(container));
|
updateWithAuthServerInfo(container);
|
||||||
|
suiteContext.setAuthServerInfo(container);
|
||||||
}
|
}
|
||||||
// backends
|
// backends
|
||||||
if (container.getContainerConfiguration().getContainerName().startsWith(authServerBackend)) {
|
if (container.getQualifier().startsWith(authServerBackend)) {
|
||||||
suiteContext.getAuthServerBackendsInfo().add(initializeAuthServerInfo(container, ++backends));
|
updateWithAuthServerInfo(container, ++backends);
|
||||||
|
suiteContext.getAuthServerBackendsInfo().add(container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,18 +136,19 @@ public class AuthServerTestEnricher {
|
||||||
if (authServerCluster && !suiteContext.getAuthServerBackendsInfo().isEmpty()) {
|
if (authServerCluster && !suiteContext.getAuthServerBackendsInfo().isEmpty()) {
|
||||||
throw new RuntimeException(String.format("No cluster backend nodes activated. Containers matching '%sN' need to be enabled in arquillian.xml.", authServerBackend));
|
throw new RuntimeException(String.format("No cluster backend nodes activated. Containers matching '%sN' need to be enabled in arquillian.xml.", authServerBackend));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException(String.format("Value of %s should start with 'auth-server-' prefix.", AUTH_SERVER_CONTAINER_PROPERTY));
|
throw new IllegalArgumentException(String.format("Value of %s should start with 'auth-server-' prefix.", AUTH_SERVER_CONTAINER_PROPERTY));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (migratedAuthServerQualifier != null) {
|
if (migratedAuthServerQualifier != null) {
|
||||||
// init migratedAuthServerInfo
|
// init migratedAuthServerInfo
|
||||||
if (migratedAuthServerQualifier.startsWith("migrated-auth-server-")) {
|
if (migratedAuthServerQualifier.startsWith("migrated-auth-server-")) {
|
||||||
for (Container container : suiteContext.getArquillianContainers()) {
|
for (ContainerInfo container : suiteContext.getContainers()) {
|
||||||
// migrated auth server
|
// migrated auth server
|
||||||
if (container.getContainerConfiguration().getContainerName().equals(migratedAuthServerQualifier)) {
|
if (container.getQualifier().equals(migratedAuthServerQualifier)) {
|
||||||
suiteContext.setMigratedAuthServerInfo(initializeAuthServerInfo(container));
|
updateWithAuthServerInfo(container);
|
||||||
|
suiteContext.setMigratedAuthServerInfo(container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -150,22 +160,16 @@ public class AuthServerTestEnricher {
|
||||||
+ "A container matching '%s' needs to be enabled in arquillian.xml.", migratedAuthServerQualifier));
|
+ "A container matching '%s' needs to be enabled in arquillian.xml.", migratedAuthServerQualifier));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suiteContextProducer.set(suiteContext);
|
suiteContextProducer.set(suiteContext);
|
||||||
log.info("\n\n" + suiteContext);
|
log.info("\n\n" + suiteContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initializeTestContext(@Observes(precedence = 1) BeforeClass event) {
|
private ContainerInfo updateWithAuthServerInfo(ContainerInfo authServerInfo) {
|
||||||
TestContext testContext = new TestContext(suiteContext, event.getTestClass().getJavaClass());
|
return updateWithAuthServerInfo(authServerInfo, 0);
|
||||||
testContextProducer.set(testContext);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ContainerInfo initializeAuthServerInfo(Container authServerContainer) {
|
private ContainerInfo updateWithAuthServerInfo(ContainerInfo authServerInfo, int clusterPortOffset) {
|
||||||
return initializeAuthServerInfo(authServerContainer, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ContainerInfo initializeAuthServerInfo(Container authServerContainer, int clusterPortOffset) {
|
|
||||||
ContainerInfo authServerInfo = new ContainerInfo(authServerContainer);
|
|
||||||
try {
|
try {
|
||||||
authServerInfo.setContextRoot(new URL(getAuthServerContextRoot(clusterPortOffset)));
|
authServerInfo.setContextRoot(new URL(getAuthServerContextRoot(clusterPortOffset)));
|
||||||
} catch (MalformedURLException ex) {
|
} catch (MalformedURLException ex) {
|
||||||
|
@ -173,20 +177,20 @@ public class AuthServerTestEnricher {
|
||||||
}
|
}
|
||||||
return authServerInfo;
|
return authServerInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startMigratedContainer(@Observes(precedence = 2) StartSuiteContainers event) {
|
public void startMigratedContainer(@Observes(precedence = 2) StartSuiteContainers event) {
|
||||||
if (suiteContext.isAuthServerMigrationEnabled()) {
|
if (suiteContext.isAuthServerMigrationEnabled()) {
|
||||||
log.info("\n\n### Starting keycloak " + System.getProperty("version", "- previous") + " ###\n");
|
log.info("\n\n### Starting keycloak " + System.getProperty("version", "- previous") + " ###\n");
|
||||||
startContainerEvent.fire(new StartContainer(suiteContext.getMigratedAuthServerInfo().getArquillianContainer()));
|
startContainerEvent.fire(new StartContainer(suiteContext.getMigratedAuthServerInfo().getArquillianContainer()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopMigratedContainer(@Observes(precedence = 1) StartSuiteContainers event) {
|
public void stopMigratedContainer(@Observes(precedence = 1) StartSuiteContainers event) {
|
||||||
if (suiteContext.isAuthServerMigrationEnabled()) {
|
if (suiteContext.isAuthServerMigrationEnabled()) {
|
||||||
containerController.get().stop(suiteContext.getAuthServerInfo().getQualifier());
|
containerController.get().stop(suiteContext.getAuthServerInfo().getQualifier());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkServerLogs(@Observes(precedence = -1) BeforeSuite event) throws IOException, InterruptedException {
|
public void checkServerLogs(@Observes(precedence = -1) BeforeSuite event) throws IOException, InterruptedException {
|
||||||
boolean checkLog = System.getProperty("auth.server.log.check", "true").equals("true");
|
boolean checkLog = System.getProperty("auth.server.log.check", "true").equals("true");
|
||||||
if (checkLog && suiteContext.getAuthServerInfo().isJBossBased()) {
|
if (checkLog && suiteContext.getAuthServerInfo().isJBossBased()) {
|
||||||
|
@ -194,5 +198,10 @@ public class AuthServerTestEnricher {
|
||||||
LogChecker.checkJBossServerLog(jbossHomePath);
|
LogChecker.checkJBossServerLog(jbossHomePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void initializeTestContext(@Observes(precedence = 2) BeforeClass event) {
|
||||||
|
TestContext testContext = new TestContext(suiteContext, event.getTestClass().getJavaClass());
|
||||||
|
testContextProducer.set(testContext);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.keycloak.testsuite.arquillian;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import org.jboss.arquillian.container.spi.Container;
|
import org.jboss.arquillian.container.spi.Container;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,6 +13,7 @@ public class ContainerInfo {
|
||||||
|
|
||||||
private URL contextRoot;
|
private URL contextRoot;
|
||||||
private Container arquillianContainer;
|
private Container arquillianContainer;
|
||||||
|
private boolean adapterLibsInstalled;
|
||||||
|
|
||||||
public ContainerInfo(Container arquillianContainer) {
|
public ContainerInfo(Container arquillianContainer) {
|
||||||
if (arquillianContainer == null) {
|
if (arquillianContainer == null) {
|
||||||
|
@ -41,15 +43,15 @@ public class ContainerInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAS7() {
|
public boolean isAS7() {
|
||||||
return getQualifier().contains("as7");
|
return getQualifier().toLowerCase().contains("as7");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWildfly() {
|
public boolean isWildfly() {
|
||||||
return getQualifier().contains("Wildfly");
|
return getQualifier().toLowerCase().contains("wildfly");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEAP() {
|
public boolean isEAP() {
|
||||||
return getQualifier().contains("eap");
|
return getQualifier().toLowerCase().contains("eap");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isJBossBased() {
|
public boolean isJBossBased() {
|
||||||
|
@ -61,4 +63,33 @@ public class ContainerInfo {
|
||||||
return getQualifier();
|
return getQualifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAdapterLibsInstalled() {
|
||||||
|
return adapterLibsInstalled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdapterLibsInstalled(boolean adapterLibsInstalled) {
|
||||||
|
this.adapterLibsInstalled = adapterLibsInstalled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int hash = 7;
|
||||||
|
hash = 97 * hash + Objects.hashCode(this.arquillianContainer);
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final ContainerInfo other = (ContainerInfo) obj;
|
||||||
|
return Objects.equals(
|
||||||
|
this.arquillianContainer.getContainerConfiguration().getContainerName(),
|
||||||
|
other.arquillianContainer.getContainerConfiguration().getContainerName());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.jboss.arquillian.container.spi.Container;
|
import java.util.Set;
|
||||||
import static org.keycloak.testsuite.util.MailServerConfiguration.*;
|
import static org.keycloak.testsuite.util.MailServerConfiguration.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,7 +29,7 @@ import static org.keycloak.testsuite.util.MailServerConfiguration.*;
|
||||||
*/
|
*/
|
||||||
public final class SuiteContext {
|
public final class SuiteContext {
|
||||||
|
|
||||||
private final List<Container> arquillianContainers;
|
private final Set<ContainerInfo> container;
|
||||||
|
|
||||||
private ContainerInfo authServerInfo;
|
private ContainerInfo authServerInfo;
|
||||||
private final List<ContainerInfo> authServerBackendsInfo = new ArrayList<>();
|
private final List<ContainerInfo> authServerBackendsInfo = new ArrayList<>();
|
||||||
|
@ -39,8 +39,8 @@ public final class SuiteContext {
|
||||||
private boolean adminPasswordUpdated;
|
private boolean adminPasswordUpdated;
|
||||||
private final Map<String, String> smtpServer = new HashMap<>();
|
private final Map<String, String> smtpServer = new HashMap<>();
|
||||||
|
|
||||||
public SuiteContext(List<Container> arquillianContainers) {
|
public SuiteContext(Set<ContainerInfo> arquillianContainers) {
|
||||||
this.arquillianContainers = arquillianContainers;
|
this.container = arquillianContainers;
|
||||||
this.adminPasswordUpdated = false;
|
this.adminPasswordUpdated = false;
|
||||||
smtpServer.put("from", FROM);
|
smtpServer.put("from", FROM);
|
||||||
smtpServer.put("host", HOST);
|
smtpServer.put("host", HOST);
|
||||||
|
@ -87,8 +87,8 @@ public final class SuiteContext {
|
||||||
return migratedAuthServerInfo != null;
|
return migratedAuthServerInfo != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Container> getArquillianContainers() {
|
public Set<ContainerInfo> getContainers() {
|
||||||
return arquillianContainers;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,7 +25,6 @@ import org.keycloak.representations.idm.ClientRepresentation;
|
||||||
import org.keycloak.representations.idm.RealmRepresentation;
|
import org.keycloak.representations.idm.RealmRepresentation;
|
||||||
import org.keycloak.testsuite.AbstractAuthTest;
|
import org.keycloak.testsuite.AbstractAuthTest;
|
||||||
import org.keycloak.testsuite.adapter.page.AppServerContextRoot;
|
import org.keycloak.testsuite.adapter.page.AppServerContextRoot;
|
||||||
import org.keycloak.testsuite.arquillian.AuthServerTestEnricher;
|
|
||||||
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
|
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
|
@ -286,13 +286,6 @@
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
<profile>
|
|
||||||
<id>auth-server-wildfly</id>
|
|
||||||
<modules>
|
|
||||||
<module>wildfly-relative</module>
|
|
||||||
</modules>
|
|
||||||
</profile>
|
|
||||||
|
|
||||||
<profile>
|
<profile>
|
||||||
<id>app-server-eap6</id>
|
<id>app-server-eap6</id>
|
||||||
<modules>
|
<modules>
|
||||||
|
@ -311,6 +304,12 @@
|
||||||
<module>wildfly</module>
|
<module>wildfly</module>
|
||||||
</modules>
|
</modules>
|
||||||
</profile>
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>app-server-wildfly-relative</id>
|
||||||
|
<modules>
|
||||||
|
<module>wildfly-relative</module>
|
||||||
|
</modules>
|
||||||
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
<id>app-server-wildfly8</id>
|
<id>app-server-wildfly8</id>
|
||||||
<modules>
|
<modules>
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!--
|
<!--
|
||||||
~ Copyright 2016 Red Hat, Inc. and/or its affiliates
|
~ Copyright 2016 Red Hat, Inc. and/or its affiliates
|
||||||
~ and other contributors as indicated by the @author tags.
|
~ and other contributors as indicated by the @author tags.
|
||||||
~
|
~
|
||||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
~ you may not use this file except in compliance with the License.
|
~ you may not use this file except in compliance with the License.
|
||||||
~ You may obtain a copy of the License at
|
~ You may obtain a copy of the License at
|
||||||
~
|
~
|
||||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
~
|
~
|
||||||
~ Unless required by applicable law or agreed to in writing, software
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
~ See the License for the specific language governing permissions and
|
~ See the License for the specific language governing permissions and
|
||||||
~ limitations under the License.
|
~ limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
@ -54,7 +54,39 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-enforcer-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>enforce-auth-server-wildfly-profile</id>
|
||||||
|
<goals>
|
||||||
|
<goal>enforce</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<rules>
|
||||||
|
<requireActiveProfile>
|
||||||
|
<profiles>auth-server-wildfly</profiles>
|
||||||
|
</requireActiveProfile>
|
||||||
|
</rules>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
|
||||||
|
<profile>
|
||||||
|
<id>auth-server-wildfly</id>
|
||||||
|
<!--dummy profile for the enforcer plugin to work-->
|
||||||
|
</profile>
|
||||||
|
|
||||||
<profile>
|
<profile>
|
||||||
<id>adapter-libs-bundled</id>
|
<id>adapter-libs-bundled</id>
|
||||||
<activation>
|
<activation>
|
||||||
|
|
Loading…
Reference in a new issue