diff --git a/testsuite/integration-arquillian/servers/wildfly/pom.xml b/testsuite/integration-arquillian/servers/wildfly/pom.xml index 361073713e..634688bcc4 100644 --- a/testsuite/integration-arquillian/servers/wildfly/pom.xml +++ b/testsuite/integration-arquillian/servers/wildfly/pom.xml @@ -209,31 +209,6 @@ - - org.codehaus.mojo - xml-maven-plugin - - - configure-adapter-subsystem - process-resources - - transform - - - - - ${keycloak.server.home}/standalone/configuration - - standalone.xml - - src/main/xslt/standalone.xsl - ${keycloak.server.home}/standalone/configuration - - - - - - diff --git a/testsuite/integration-arquillian/servers/wildfly/src/main/xslt/standalone.xsl b/testsuite/integration-arquillian/servers/wildfly/src/main/xslt/standalone.xsl deleted file mode 100644 index f711ed93b3..0000000000 --- a/testsuite/integration-arquillian/servers/wildfly/src/main/xslt/standalone.xsl +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/testsuite/integration-arquillian/tests/adapters/as7/pom.xml b/testsuite/integration-arquillian/tests/adapters/as7/pom.xml index 135c1bf180..b63ae88213 100644 --- a/testsuite/integration-arquillian/tests/adapters/as7/pom.xml +++ b/testsuite/integration-arquillian/tests/adapters/as7/pom.xml @@ -40,6 +40,11 @@ keycloak-as7-adapter-dist zip + + org.keycloak + keycloak-saml-as7-adapter-dist + zip + @@ -77,6 +82,13 @@ zip ${adapter.libs.as7} + + org.keycloak + keycloak-saml-as7-adapter-dist + ${project.version} + zip + ${adapter.libs.as7} + diff --git a/testsuite/integration-arquillian/tests/adapters/eap6/pom.xml b/testsuite/integration-arquillian/tests/adapters/eap6/pom.xml index b9075cffa4..cc82d36128 100644 --- a/testsuite/integration-arquillian/tests/adapters/eap6/pom.xml +++ b/testsuite/integration-arquillian/tests/adapters/eap6/pom.xml @@ -40,6 +40,11 @@ keycloak-eap6-adapter-dist zip + + org.keycloak + keycloak-saml-eap6-adapter-dist + zip + @@ -67,7 +72,7 @@ maven-dependency-plugin - unpack-eap6-with-adapter + unpack-eap6-with-adapters generate-resources unpack @@ -88,6 +93,13 @@ zip ${adapter.libs.eap6} + + org.keycloak + keycloak-saml-eap6-adapter-dist + ${version.adapter.dist} + zip + ${adapter.libs.eap6} + diff --git a/testsuite/integration-arquillian/tests/adapters/pom.xml b/testsuite/integration-arquillian/tests/adapters/pom.xml index 5e215fb809..c5f2f7b44d 100644 --- a/testsuite/integration-arquillian/tests/adapters/pom.xml +++ b/testsuite/integration-arquillian/tests/adapters/pom.xml @@ -23,6 +23,7 @@ - src/main/xslt/arquillian.xsl + false @@ -50,6 +51,24 @@ + + unpack-add-user-json + generate-resources + + unpack + + + + + org.keycloak.testsuite + integration-arquillian-tests-base + ${project.version} + test-jar + **/keycloak-add-user.json + + + + @@ -108,6 +127,31 @@ + + org.apache.maven.plugins + maven-resources-plugin + + + copy-admin-user-json-file + process-test-resources + + copy-resources + + + ${jboss.server.config.dir} + + + ${project.build.directory}/dependency + + keycloak-add-user.json + + true + + + + + + diff --git a/testsuite/integration-arquillian/tests/adapters/wildfly/pom.xml b/testsuite/integration-arquillian/tests/adapters/wildfly/pom.xml index 46224891cb..7551f65e62 100644 --- a/testsuite/integration-arquillian/tests/adapters/wildfly/pom.xml +++ b/testsuite/integration-arquillian/tests/adapters/wildfly/pom.xml @@ -31,6 +31,11 @@ keycloak-wildfly-adapter-dist zip + + org.keycloak + keycloak-saml-wildfly-adapter-dist + zip + @@ -68,6 +73,13 @@ zip ${adapter.libs.wildfly} + + org.keycloak + keycloak-saml-wildfly-adapter-dist + ${project.version} + zip + ${adapter.libs.wildfly} + @@ -77,7 +89,6 @@ org.apache.maven.plugins maven-surefire-plugin - 2.18.1 true @@ -145,20 +156,20 @@ copy-resources - ${app.server.wildfly.home}/standalone/configuration - - - src/main/keystore - - adapter.jks - keycloak.truststore - - - - + ${app.server.wildfly.home}/standalone/configuration + + + src/main/keystore + + adapter.jks + keycloak.truststore + + + + jks truststore - + diff --git a/testsuite/integration-arquillian/tests/base/pom.xml b/testsuite/integration-arquillian/tests/base/pom.xml index c1e5e9c189..c0ed48ba2f 100644 --- a/testsuite/integration-arquillian/tests/base/pom.xml +++ b/testsuite/integration-arquillian/tests/base/pom.xml @@ -73,6 +73,13 @@ **/account/**/*Test.java + + no-client + + + **/client/**/*Test.java + + adapters-only diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/ContainersTestEnricher.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/ContainersTestEnricher.java index e6f3c153c1..2512d1c321 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/ContainersTestEnricher.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/ContainersTestEnricher.java @@ -23,7 +23,6 @@ import org.jboss.arquillian.core.api.annotation.Observes; import org.jboss.arquillian.test.spi.annotation.ClassScoped; import org.jboss.arquillian.test.spi.annotation.SuiteScoped; import org.jboss.arquillian.container.spi.event.container.AfterStart; -import org.jboss.arquillian.container.spi.event.container.BeforeStart; import org.jboss.arquillian.test.spi.event.suite.BeforeClass; import org.jboss.arquillian.test.spi.event.suite.BeforeSuite; import org.jboss.logging.Logger; @@ -35,6 +34,7 @@ import org.keycloak.testsuite.util.OAuthClient; import static org.keycloak.testsuite.auth.page.AuthRealm.ADMIN; import static org.keycloak.testsuite.auth.page.AuthRealm.MASTER; +import static org.keycloak.testsuite.util.WaitUtils.pause; /** * @@ -78,7 +78,10 @@ public class ContainersTestEnricher { private ContainerController controller; private LinkedList containers; + private String jbossHomePath; private final boolean migrationTests = System.getProperty("migration", "false").equals("true"); + private final boolean skipInstallAdapters = System.getProperty("skip.install.adapters", "false").equals("true"); + private boolean alreadyInstalled = false; private boolean alreadyStopped = false; private boolean init = false; @@ -110,16 +113,12 @@ public class ContainersTestEnricher { */ public void afterStart(@Observes AfterStart event) throws IOException, InterruptedException { Container container = containers.pollFirst(); - String jbossHomePath = null; if (isJBossBased(container)) { jbossHomePath = container.getContainerConfiguration().getContainerProperties().get("jbossHome"); log.debug("jbossHome: " + jbossHomePath + "\n"); - - if (System.getProperty("check.server.log", "true").equals("true")) { - checkServerLog(jbossHomePath); - } } + checkServerLog(jbossHomePath); if (migrationTests && !alreadyStopped) { log.info("\n\n### Stopping keycloak " + System.getProperty("version", "- previous") + " ###\n"); @@ -127,44 +126,52 @@ public class ContainersTestEnricher { log.info("\n\n### Starting keycloak current version ###\n"); alreadyStopped = true; } - - if (isJBossBased(container) && container.getName().startsWith("app-server")) { - log.info("Installing adapter to app server via cli script"); + + if (!alreadyInstalled && !skipInstallAdapters && isJBossBased(container)) { String jbossCliPath = jbossHomePath + "/bin/jboss-cli.sh"; - String scriptPathArg = "--file=" + jbossHomePath + "/bin/adapter-install.cli"; + String adapterScriptPathArg = "--file=" + jbossHomePath + "/bin/adapter-install.cli"; + String samlAdapterScriptPathArg = "--file=" + jbossHomePath + "/bin/adapter-install-saml.cli"; String managementPort = container.getContainerConfiguration().getContainerProperties().get("managementPort"); String controllerArg = "--controller=localhost:" + managementPort; - execCommand(new String[]{"/bin/sh", jbossCliPath, "--connect", scriptPathArg, controllerArg}); - log.debug("Restarting container"); + log.info("Installing adapter to app server via cli script"); + execCommand(new String[]{"/bin/sh", jbossCliPath, "--connect", adapterScriptPathArg, controllerArg}); + log.info("Installing saml adapter to app server via cli script"); + execCommand(new String[]{"/bin/sh", jbossCliPath, "--connect", samlAdapterScriptPathArg, controllerArg}); + log.info("Restarting container"); execCommand(new String[]{"/bin/sh", jbossCliPath, "--connect", "--command=:reload", controllerArg}); + pause(5000); + log.info("Container restarted"); + checkServerLog(jbossHomePath); + if (container.getName().startsWith("app-server")) { + alreadyInstalled = true; + } } } private void execCommand(String... command) throws IOException, InterruptedException { Process process = Runtime.getRuntime().exec(command); - printOutput(process.getInputStream()); - if (process.waitFor(10, TimeUnit.SECONDS)) { if (process.exitValue() != 0) { - log.error("Std Error:"); - printOutput(process.getErrorStream()); - throw new RuntimeException("Adapter installation failed."); + throw new RuntimeException("Adapter installation failed. Process exitValue: " + + process.exitValue() + "; \n" + getOutput(process.getErrorStream()) + + ""); } + log.debug("process.isAlive(): " + process.isAlive()); } else { - process.destroy(); + process.destroyForcibly(); throw new RuntimeException("Timeout after 10 seconds."); } } - private void printOutput(InputStream is) throws IOException { + private String getOutput(InputStream is) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder builder = new StringBuilder(); while (reader.ready()) { builder.append(reader.readLine()); } - log.info(builder); + return builder.toString(); } private boolean isJBossBased(Container container) { @@ -182,19 +189,22 @@ public class ContainersTestEnricher { * check server logs whether there are no ERRORs or SEVEREs */ private void checkServerLog(String jbossHomePath) throws IOException { - File serverLog = new File(jbossHomePath + "/standalone/log/server.log"); - String serverLogContent = FileUtils.readFileToString(serverLog); + if (jbossHomePath != null && System.getProperty("check.server.log", "true").equals("true")) { + File serverLog = new File(jbossHomePath + "/standalone/log/server.log"); + String serverLogContent = FileUtils.readFileToString(serverLog); - boolean containsError - = serverLogContent.contains("ERROR") - || serverLogContent.contains("SEVERE") - || serverLogContent.contains("Exception "); - //There is expected string "Exception" in server log: Adding provider - //singleton org.keycloak.services.resources.ModelExceptionMapper + boolean containsError + = serverLogContent.contains("ERROR") + || serverLogContent.contains("SEVERE") + || serverLogContent.contains("Exception "); + //There is expected string "Exception" in server log: Adding provider + //singleton org.keycloak.services.resources.ModelExceptionMapper - if (containsError) { - throw new RuntimeException(serverLog.getPath() + " contains ERROR."); - } + if (containsError) { + throw new RuntimeException(serverLog.getPath() + " contains ERROR."); + } + log.info(serverLog.getPath() + " doesn't contain Error"); + } } public void beforeSuite(@Observes BeforeSuite event) { diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/SuiteContext.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/SuiteContext.java index 589c316211..b99d6b3b45 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/SuiteContext.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/SuiteContext.java @@ -10,24 +10,14 @@ import static org.keycloak.testsuite.util.MailServerConfiguration.*; */ public final class SuiteContext { - private boolean adminPasswordUpdated; private final Map smtpServer = new HashMap<>(); public SuiteContext() { - this.adminPasswordUpdated = false; smtpServer.put("from", FROM); smtpServer.put("host", HOST); smtpServer.put("port", PORT); } - public boolean isAdminPasswordUpdated() { - return adminPasswordUpdated; - } - - public void setAdminPasswordUpdated(boolean adminPasswordUpdated) { - this.adminPasswordUpdated = adminPasswordUpdated; - } - public Map getSmtpServer() { return smtpServer; } diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AbstractKeycloakTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AbstractKeycloakTest.java index 13ec96e4d6..9400f77adf 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AbstractKeycloakTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AbstractKeycloakTest.java @@ -25,7 +25,6 @@ import org.keycloak.testsuite.util.OAuthClient; import org.openqa.selenium.WebDriver; import org.keycloak.testsuite.auth.page.AuthServer; import org.keycloak.testsuite.auth.page.AuthServerContextRoot; -import static org.keycloak.testsuite.util.URLAssert.*; import org.keycloak.testsuite.auth.page.AuthRealm; import static org.keycloak.testsuite.auth.page.AuthRealm.ADMIN; import static org.keycloak.testsuite.auth.page.AuthRealm.MASTER; @@ -90,12 +89,6 @@ public abstract class AbstractKeycloakTest { driverSettings(); - if (!suiteContext.isAdminPasswordUpdated()) { - log.debug("updating admin password"); - updateMasterAdminPassword(); - suiteContext.setAdminPasswordUpdated(true); - } - importTestRealms(); } @@ -106,13 +99,6 @@ public abstract class AbstractKeycloakTest { Timer.printStats(); } - private void updateMasterAdminPassword() { - welcomePage.navigateTo(); - if (!welcomePage.isPasswordSet()) { - welcomePage.setPassword("admin", "admin"); - } - } - public void deleteAllCookiesForMasterRealm() { masterRealmPage.navigateTo(); log.debug("deleting cookies in master realm"); diff --git a/testsuite/integration-arquillian/tests/base/src/test/resources/keycloak-add-user.json b/testsuite/integration-arquillian/tests/base/src/test/resources/keycloak-add-user.json index 635f144a8e..60c0f098d1 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/resources/keycloak-add-user.json +++ b/testsuite/integration-arquillian/tests/base/src/test/resources/keycloak-add-user.json @@ -5,12 +5,11 @@ "enabled" : true, "credentials" : [ { "type" : "password", - "hashedSaltedValue" : "6K5rvcPu3dXndZOhpzLAVbFtcdlUhbGCrUyV0NNzeS61IdhMpjH8Mf4y/Ag/vHZkw4Ayvtvb9/1iMNOzxR0M6g==", - "salt" : "/6M1jTMUB0uR8EOkksFn/A==", + "hashedSaltedValue" : "dqalJHLkWhUJZO/q6+z1fvXOohTcGCXcvoU8xCEyvTxGN4wmLx7DtyhKuefggh6Bkx1I2eBTEX4tiWggwyXMDw==", + "salt" : "3fBAt5GAGGxFrV9fznpZHQ==", "hashIterations" : 100000, "algorithm" : "pbkdf2" } ], "realmRoles" : [ "admin" ] - } ], - "identityFederationEnabled" : false + } ] } ] \ No newline at end of file diff --git a/testsuite/integration-arquillian/tests/pom.xml b/testsuite/integration-arquillian/tests/pom.xml index fbc4914bb4..d40218b741 100644 --- a/testsuite/integration-arquillian/tests/pom.xml +++ b/testsuite/integration-arquillian/tests/pom.xml @@ -41,6 +41,7 @@ 2.1.1 true true + true @@ -95,6 +96,7 @@ ${auth.server.ssl.required} ${startup.timeout.sec} ${project.build.directory}/undertow-configuration + ${skip.install.adapters} @@ -152,6 +154,7 @@ + org.apache.maven.plugins maven-resources-plugin @@ -416,6 +419,7 @@ 300 ${containers.home}/keycloak-${project.version} + ${keycloak.home}/standalone/configuration @@ -448,7 +452,7 @@ copy-resources - ${keycloak.home}/standalone/configuration + ${jboss.server.config.dir} src/test/resources @@ -512,6 +516,7 @@ 300 ${containers.home}/keycloak-${version.eap6.server.dist} + ${keycloak.home}/standalone/configuration @@ -570,7 +575,7 @@ copy-resources - ${keycloak.home}/standalone/configuration + ${jboss.server.config.dir} src/test/resources