From d9f79fae79952121de5dbcbe9d34b7a8e707569b Mon Sep 17 00:00:00 2001 From: vramik Date: Tue, 19 Jun 2018 12:18:11 +0200 Subject: [PATCH] KEYCLOAK-7510 Add Support for server specific ArchiveProcessor --- testsuite/integration-arquillian/pom.xml | 6 + .../servers/app-server/jboss/eap/pom.xml | 5 + .../eap/EAPAppServerArquillianExtension.java | 34 ++ .../EAPDeploymentArchiveProcessor.java | 70 ++++ ...boss.arquillian.core.spi.LoadableExtension | 1 + .../servers/app-server/jboss/eap6/pom.xml | 5 + .../eap/EAP6AppServerArquillianExtension.java | 34 ++ .../EAP6DeploymentArchiveProcessor.java | 81 +++++ ...boss.arquillian.core.spi.LoadableExtension | 1 + .../servers/app-server/jboss/wildfly/pom.xml | 5 + .../WildflyAppServerArquillianExtension.java | 34 ++ .../WildflyDeploymentArchiveProcessor.java | 70 ++++ ...boss.arquillian.core.spi.LoadableExtension | 1 + .../servers/app-server/undertow/pom.xml | 2 +- .../UndertowAppServerArquillianExtension.java | 7 +- .../UndertowDeploymentArchiveProcessor.java | 59 ++++ .../servers/auth-server/undertow/pom.xml | 2 +- .../integration-arquillian/servers/pom.xml | 11 - .../page/AngularCorsProductTestApp.java | 12 +- .../arquillian/AppServerTestEnricher.java | 4 + .../DeploymentArchiveProcessor.java | 143 +++----- .../testsuite/pages/AppServerWelcomePage.java | 4 +- .../testsuite/util/AdminClientUtil.java | 2 +- .../testsuite/util/LDAPTestConfiguration.java | 2 +- .../org/keycloak/testsuite/util/Timer.java | 2 +- .../AbstractSAMLAdapterClusteredTest.java | 2 +- .../adapter/AbstractServletsAdapterTest.java | 4 +- .../example/AbstractFuseAdminAdapterTest.java | 2 +- .../AbstractFuseExampleAdapterTest.java | 2 +- .../example/AbstractHawtioAdapterTest.java | 2 +- .../AbstractBaseServletAuthzAdapterTest.java | 4 +- .../AbstractPhotozExampleAdapterTest.java | 4 +- .../DefaultAuthzConfigAdapterTest.java | 2 +- .../ServletPolicyEnforcerTest.java | 2 +- .../example/cors/CorsExampleAdapterTest.java | 2 +- .../example/hal/ConsoleProtectionTest.java | 12 +- .../servlet/DemoFilterServletAdapterTest.java | 2 +- .../adapter/servlet/MultiTenancyTest.java | 2 +- .../servlet/OfflineServletsAdapterTest.java | 4 +- .../servlet/SAMLFilterServletAdapterTest.java | 4 +- ...rTest.java => SAMLServletAdapterTest.java} | 313 +++++++++--------- .../UndertowRelaviteUriAdapterTest.java | 2 +- .../ClaimInformationPointProviderTest.java | 2 +- .../authorization/EnforcerConfigTest.java | 2 +- .../admin/group/AbstractGroupTest.java | 2 +- .../broker/KcSamlIdPInitiatedSsoTest.java | 2 +- .../JsonFileImport198MigrationTest.java | 2 +- .../JsonFileImport255MigrationTest.java | 2 +- .../testsuite/saml/AbstractSamlTest.java | 2 +- .../testsuite/saml/BasicSamlTest.java | 4 +- .../saml/ConcurrentAuthnRequestTest.java | 7 +- .../testsuite/saml/SamlConsentTest.java | 5 +- .../adapter/RemoteSAMLAdapterTest.java | 4 +- .../performance/PerformanceMeasurement.java | 2 +- .../htmlunit/HtmlUnitLoginLogoutPerfTest.java | 2 +- .../HttpClientLoginLogoutPerfTest.java | 2 +- .../{servers => }/util/pom.xml | 18 +- .../utils}/annotation/UseServletFilter.java | 2 +- .../DeploymentArchiveProcessorUtils.java | 201 +++++++++++ .../KeycloakDependenciesResolver.java | 20 +- .../keycloak/testsuite/utils/io}/IOUtil.java | 4 +- .../utils/undertow/SimpleWebXmlParser.java | 0 .../undertow/UndertowDeployerHelper.java | 0 .../undertow/UndertowWarClassLoader.java | 0 64 files changed, 918 insertions(+), 329 deletions(-) create mode 100644 testsuite/integration-arquillian/servers/app-server/jboss/eap/src/main/java/org/keycloak/testsuite/arquillian/eap/EAPAppServerArquillianExtension.java create mode 100644 testsuite/integration-arquillian/servers/app-server/jboss/eap/src/main/java/org/keycloak/testsuite/arquillian/eap/container/EAPDeploymentArchiveProcessor.java create mode 100644 testsuite/integration-arquillian/servers/app-server/jboss/eap/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension create mode 100644 testsuite/integration-arquillian/servers/app-server/jboss/eap6/src/main/java/org/keycloak/testsuite/arquillian/eap/EAP6AppServerArquillianExtension.java create mode 100644 testsuite/integration-arquillian/servers/app-server/jboss/eap6/src/main/java/org/keycloak/testsuite/arquillian/eap/container/EAP6DeploymentArchiveProcessor.java create mode 100644 testsuite/integration-arquillian/servers/app-server/jboss/eap6/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension create mode 100644 testsuite/integration-arquillian/servers/app-server/jboss/wildfly/src/main/java/org/keycloak/testsuite/arquillian/wildfly/WildflyAppServerArquillianExtension.java create mode 100644 testsuite/integration-arquillian/servers/app-server/jboss/wildfly/src/main/java/org/keycloak/testsuite/arquillian/wildfly/container/WildflyDeploymentArchiveProcessor.java create mode 100644 testsuite/integration-arquillian/servers/app-server/jboss/wildfly/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension create mode 100644 testsuite/integration-arquillian/servers/app-server/undertow/src/main/java/org/keycloak/testsuite/arquillian/undertow/container/UndertowDeploymentArchiveProcessor.java rename testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/{SAMLServletsAdapterTest.java => SAMLServletAdapterTest.java} (91%) rename testsuite/integration-arquillian/{servers => }/util/pom.xml (68%) rename testsuite/integration-arquillian/{tests/base/src/main/java/org/keycloak/testsuite/arquillian => util/src/main/java/org/keycloak/testsuite/utils}/annotation/UseServletFilter.java (91%) create mode 100644 testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/arquillian/DeploymentArchiveProcessorUtils.java rename testsuite/integration-arquillian/{tests/base/src/main/java/org/keycloak/testsuite => util/src/main/java/org/keycloak/testsuite/utils}/arquillian/KeycloakDependenciesResolver.java (61%) rename testsuite/integration-arquillian/{tests/base/src/main/java/org/keycloak/testsuite/util => util/src/main/java/org/keycloak/testsuite/utils/io}/IOUtil.java (99%) rename testsuite/integration-arquillian/{servers => }/util/src/main/java/org/keycloak/testsuite/utils/undertow/SimpleWebXmlParser.java (100%) rename testsuite/integration-arquillian/{servers => }/util/src/main/java/org/keycloak/testsuite/utils/undertow/UndertowDeployerHelper.java (100%) rename testsuite/integration-arquillian/{servers => }/util/src/main/java/org/keycloak/testsuite/utils/undertow/UndertowWarClassLoader.java (100%) diff --git a/testsuite/integration-arquillian/pom.xml b/testsuite/integration-arquillian/pom.xml index 5e69523b73..471112d5a4 100644 --- a/testsuite/integration-arquillian/pom.xml +++ b/testsuite/integration-arquillian/pom.xml @@ -123,6 +123,11 @@ ${arquillian-wls-container.version} test + + org.jboss.arquillian.container + undertow-embedded + ${undertow-embedded.version} + @@ -158,6 +163,7 @@ test-apps servers tests + util diff --git a/testsuite/integration-arquillian/servers/app-server/jboss/eap/pom.xml b/testsuite/integration-arquillian/servers/app-server/jboss/eap/pom.xml index 28964b7fcc..7821596dae 100644 --- a/testsuite/integration-arquillian/servers/app-server/jboss/eap/pom.xml +++ b/testsuite/integration-arquillian/servers/app-server/jboss/eap/pom.xml @@ -53,5 +53,10 @@ org.wildfly.arquillian wildfly-arquillian-container-managed + + org.keycloak.testsuite + integration-arquillian-util + ${project.version} + diff --git a/testsuite/integration-arquillian/servers/app-server/jboss/eap/src/main/java/org/keycloak/testsuite/arquillian/eap/EAPAppServerArquillianExtension.java b/testsuite/integration-arquillian/servers/app-server/jboss/eap/src/main/java/org/keycloak/testsuite/arquillian/eap/EAPAppServerArquillianExtension.java new file mode 100644 index 0000000000..dca5958bd9 --- /dev/null +++ b/testsuite/integration-arquillian/servers/app-server/jboss/eap/src/main/java/org/keycloak/testsuite/arquillian/eap/EAPAppServerArquillianExtension.java @@ -0,0 +1,34 @@ +/* + * Copyright 2018 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.keycloak.testsuite.arquillian.eap; + +import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor; +import org.jboss.arquillian.core.spi.LoadableExtension; +import org.keycloak.testsuite.arquillian.eap.container.EAPDeploymentArchiveProcessor; + +/** + * + * @author Vlasta Ramik + */ +public class EAPAppServerArquillianExtension implements LoadableExtension { + + @Override + public void register(ExtensionBuilder builder) { + builder.service(ApplicationArchiveProcessor.class, EAPDeploymentArchiveProcessor.class); + } + +} diff --git a/testsuite/integration-arquillian/servers/app-server/jboss/eap/src/main/java/org/keycloak/testsuite/arquillian/eap/container/EAPDeploymentArchiveProcessor.java b/testsuite/integration-arquillian/servers/app-server/jboss/eap/src/main/java/org/keycloak/testsuite/arquillian/eap/container/EAPDeploymentArchiveProcessor.java new file mode 100644 index 0000000000..28daaeba5f --- /dev/null +++ b/testsuite/integration-arquillian/servers/app-server/jboss/eap/src/main/java/org/keycloak/testsuite/arquillian/eap/container/EAPDeploymentArchiveProcessor.java @@ -0,0 +1,70 @@ +/* + * Copyright 2018 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.keycloak.testsuite.arquillian.eap.container; + +import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor; +import org.jboss.arquillian.test.spi.TestClass; +import org.jboss.logging.Logger; +import org.jboss.shrinkwrap.api.Archive; +import org.keycloak.testsuite.utils.annotation.UseServletFilter; +import org.keycloak.testsuite.utils.arquillian.DeploymentArchiveProcessorUtils; + +/** + * + * @author Vlasta Ramik + */ +public class EAPDeploymentArchiveProcessor implements ApplicationArchiveProcessor { + + private final Logger log = Logger.getLogger(EAPDeploymentArchiveProcessor.class); + + @Override + public void process(Archive archive, TestClass testClass) { + if (DeploymentArchiveProcessorUtils.checkRunOnServerDeployment(archive)) return; + + modifyWebXML(archive, testClass); + + modifyOIDCAdapterConfig(archive, DeploymentArchiveProcessorUtils.ADAPTER_CONFIG_PATH); + modifyOIDCAdapterConfig(archive, DeploymentArchiveProcessorUtils.ADAPTER_CONFIG_PATH_JS); + + modifySAMLAdapterConfig(archive); + } + + private void modifyWebXML(Archive archive, TestClass testClass) { + if (!archive.contains(DeploymentArchiveProcessorUtils.WEBXML_PATH)) return; + if (!testClass.getJavaClass().isAnnotationPresent(UseServletFilter.class)) return; + if (!archive.contains(DeploymentArchiveProcessorUtils.JBOSS_DEPLOYMENT_XML_PATH)) return; + + log.debug("Modifying WEB.XML in " + archive.getName() + " for Servlet Filter."); + DeploymentArchiveProcessorUtils.modifyWebXMLForServletFilter(archive, testClass); + DeploymentArchiveProcessorUtils.addFilterDependencies(archive, testClass); + } + + private void modifyOIDCAdapterConfig(Archive archive, String adapterConfigPath) { + if (!archive.contains(adapterConfigPath)) return; + + log.debug("Modifying adapter config " + adapterConfigPath + " in " + archive.getName()); + + DeploymentArchiveProcessorUtils.modifyOIDCAdapterConfig(archive, adapterConfigPath); + } + + private void modifySAMLAdapterConfig(Archive archive) { + if (!archive.contains(DeploymentArchiveProcessorUtils.SAML_ADAPTER_CONFIG_PATH)) return; + + log.debug("Modifying adapter config " + DeploymentArchiveProcessorUtils.SAML_ADAPTER_CONFIG_PATH + " in " + archive.getName()); + DeploymentArchiveProcessorUtils.modifySAMLAdapterConfig(archive); + } +} diff --git a/testsuite/integration-arquillian/servers/app-server/jboss/eap/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension b/testsuite/integration-arquillian/servers/app-server/jboss/eap/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension new file mode 100644 index 0000000000..e8688becf6 --- /dev/null +++ b/testsuite/integration-arquillian/servers/app-server/jboss/eap/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension @@ -0,0 +1 @@ +org.keycloak.testsuite.arquillian.eap.EAPAppServerArquillianExtension diff --git a/testsuite/integration-arquillian/servers/app-server/jboss/eap6/pom.xml b/testsuite/integration-arquillian/servers/app-server/jboss/eap6/pom.xml index ecb486b67a..456f968ec4 100644 --- a/testsuite/integration-arquillian/servers/app-server/jboss/eap6/pom.xml +++ b/testsuite/integration-arquillian/servers/app-server/jboss/eap6/pom.xml @@ -53,6 +53,11 @@ org.wildfly.arquillian wildfly-arquillian-container-managed + + org.keycloak.testsuite + integration-arquillian-util + ${project.version} + diff --git a/testsuite/integration-arquillian/servers/app-server/jboss/eap6/src/main/java/org/keycloak/testsuite/arquillian/eap/EAP6AppServerArquillianExtension.java b/testsuite/integration-arquillian/servers/app-server/jboss/eap6/src/main/java/org/keycloak/testsuite/arquillian/eap/EAP6AppServerArquillianExtension.java new file mode 100644 index 0000000000..659d998c2f --- /dev/null +++ b/testsuite/integration-arquillian/servers/app-server/jboss/eap6/src/main/java/org/keycloak/testsuite/arquillian/eap/EAP6AppServerArquillianExtension.java @@ -0,0 +1,34 @@ +/* + * Copyright 2018 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.keycloak.testsuite.arquillian.eap; + +import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor; +import org.jboss.arquillian.core.spi.LoadableExtension; +import org.keycloak.testsuite.arquillian.eap.container.EAP6DeploymentArchiveProcessor; + +/** + * + * @author Vlasta Ramik + */ +public class EAP6AppServerArquillianExtension implements LoadableExtension { + + @Override + public void register(ExtensionBuilder builder) { + builder.service(ApplicationArchiveProcessor.class, EAP6DeploymentArchiveProcessor.class); + } + +} diff --git a/testsuite/integration-arquillian/servers/app-server/jboss/eap6/src/main/java/org/keycloak/testsuite/arquillian/eap/container/EAP6DeploymentArchiveProcessor.java b/testsuite/integration-arquillian/servers/app-server/jboss/eap6/src/main/java/org/keycloak/testsuite/arquillian/eap/container/EAP6DeploymentArchiveProcessor.java new file mode 100644 index 0000000000..edcbea02b7 --- /dev/null +++ b/testsuite/integration-arquillian/servers/app-server/jboss/eap6/src/main/java/org/keycloak/testsuite/arquillian/eap/container/EAP6DeploymentArchiveProcessor.java @@ -0,0 +1,81 @@ +/* + * Copyright 2018 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.keycloak.testsuite.arquillian.eap.container; + +import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor; +import org.jboss.arquillian.test.spi.TestClass; +import org.jboss.logging.Logger; +import org.jboss.shrinkwrap.api.Archive; +import org.keycloak.testsuite.utils.annotation.UseServletFilter; +import org.keycloak.testsuite.utils.arquillian.DeploymentArchiveProcessorUtils; +import org.keycloak.testsuite.utils.io.IOUtil; +import org.w3c.dom.Document; + +/** + * + * @author Vlasta Ramik + */ +public class EAP6DeploymentArchiveProcessor implements ApplicationArchiveProcessor { + + private final Logger log = Logger.getLogger(EAP6DeploymentArchiveProcessor.class); + + @Override + public void process(Archive archive, TestClass testClass) { + if (DeploymentArchiveProcessorUtils.checkRunOnServerDeployment(archive)) return; + + modifyWebXML(archive, testClass); + + modifyOIDCAdapterConfig(archive, DeploymentArchiveProcessorUtils.ADAPTER_CONFIG_PATH); + modifyOIDCAdapterConfig(archive, DeploymentArchiveProcessorUtils.ADAPTER_CONFIG_PATH_JS); + + modifySAMLAdapterConfig(archive); + } + + private void modifyWebXML(Archive archive, TestClass testClass) { + if (!archive.contains(DeploymentArchiveProcessorUtils.WEBXML_PATH)) return; + if (!testClass.getJavaClass().isAnnotationPresent(UseServletFilter.class)) return; + if (!archive.contains(DeploymentArchiveProcessorUtils.JBOSS_DEPLOYMENT_XML_PATH)) return; + + log.debug("Modifying WEB.XML in " + archive.getName() + " for Servlet Filter."); + DeploymentArchiveProcessorUtils.modifyWebXMLForServletFilter(archive, testClass); + DeploymentArchiveProcessorUtils.addFilterDependencies(archive, testClass); + + Document webXmlDoc; + try { + webXmlDoc = IOUtil.loadXML(archive.get(DeploymentArchiveProcessorUtils.WEBXML_PATH).getAsset().openStream()); + } catch (IllegalArgumentException ex) { + throw new RuntimeException("Error when processing " + archive.getName(), ex); + } + IOUtil.modifyDocElementValue(webXmlDoc, "param-value", "wildfly.infinispan.InfinispanSessionCacheIdMapperUpdater", + "org.keycloak.adapters.saml.jbossweb.infinispan.InfinispanSessionCacheIdMapperUpdater"); + } + + private void modifyOIDCAdapterConfig(Archive archive, String adapterConfigPath) { + if (!archive.contains(adapterConfigPath)) return; + + log.debug("Modifying adapter config " + adapterConfigPath + " in " + archive.getName()); + + DeploymentArchiveProcessorUtils.modifyOIDCAdapterConfig(archive, adapterConfigPath); + } + + private void modifySAMLAdapterConfig(Archive archive) { + if (!archive.contains(DeploymentArchiveProcessorUtils.SAML_ADAPTER_CONFIG_PATH)) return; + + log.debug("Modifying adapter config " + DeploymentArchiveProcessorUtils.SAML_ADAPTER_CONFIG_PATH + " in " + archive.getName()); + DeploymentArchiveProcessorUtils.modifySAMLAdapterConfig(archive); + } +} diff --git a/testsuite/integration-arquillian/servers/app-server/jboss/eap6/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension b/testsuite/integration-arquillian/servers/app-server/jboss/eap6/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension new file mode 100644 index 0000000000..15abe93bf1 --- /dev/null +++ b/testsuite/integration-arquillian/servers/app-server/jboss/eap6/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension @@ -0,0 +1 @@ +org.keycloak.testsuite.arquillian.eap.EAP6AppServerArquillianExtension diff --git a/testsuite/integration-arquillian/servers/app-server/jboss/wildfly/pom.xml b/testsuite/integration-arquillian/servers/app-server/jboss/wildfly/pom.xml index f888eb15ed..a07d1c71d5 100644 --- a/testsuite/integration-arquillian/servers/app-server/jboss/wildfly/pom.xml +++ b/testsuite/integration-arquillian/servers/app-server/jboss/wildfly/pom.xml @@ -53,5 +53,10 @@ org.wildfly.arquillian wildfly-arquillian-container-managed + + org.keycloak.testsuite + integration-arquillian-util + ${project.version} + diff --git a/testsuite/integration-arquillian/servers/app-server/jboss/wildfly/src/main/java/org/keycloak/testsuite/arquillian/wildfly/WildflyAppServerArquillianExtension.java b/testsuite/integration-arquillian/servers/app-server/jboss/wildfly/src/main/java/org/keycloak/testsuite/arquillian/wildfly/WildflyAppServerArquillianExtension.java new file mode 100644 index 0000000000..851faafce9 --- /dev/null +++ b/testsuite/integration-arquillian/servers/app-server/jboss/wildfly/src/main/java/org/keycloak/testsuite/arquillian/wildfly/WildflyAppServerArquillianExtension.java @@ -0,0 +1,34 @@ +/* + * Copyright 2018 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.keycloak.testsuite.arquillian.wildfly; + +import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor; +import org.jboss.arquillian.core.spi.LoadableExtension; +import org.keycloak.testsuite.arquillian.wildfly.container.WildflyDeploymentArchiveProcessor; + +/** + * + * @author Vlasta Ramik + */ +public class WildflyAppServerArquillianExtension implements LoadableExtension { + + @Override + public void register(ExtensionBuilder builder) { + builder.service(ApplicationArchiveProcessor.class, WildflyDeploymentArchiveProcessor.class); + } + +} diff --git a/testsuite/integration-arquillian/servers/app-server/jboss/wildfly/src/main/java/org/keycloak/testsuite/arquillian/wildfly/container/WildflyDeploymentArchiveProcessor.java b/testsuite/integration-arquillian/servers/app-server/jboss/wildfly/src/main/java/org/keycloak/testsuite/arquillian/wildfly/container/WildflyDeploymentArchiveProcessor.java new file mode 100644 index 0000000000..a5ee439ec6 --- /dev/null +++ b/testsuite/integration-arquillian/servers/app-server/jboss/wildfly/src/main/java/org/keycloak/testsuite/arquillian/wildfly/container/WildflyDeploymentArchiveProcessor.java @@ -0,0 +1,70 @@ +/* + * Copyright 2018 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.keycloak.testsuite.arquillian.wildfly.container; + +import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor; +import org.jboss.arquillian.test.spi.TestClass; +import org.jboss.logging.Logger; +import org.jboss.shrinkwrap.api.Archive; +import org.keycloak.testsuite.utils.annotation.UseServletFilter; +import org.keycloak.testsuite.utils.arquillian.DeploymentArchiveProcessorUtils; + +/** + * + * @author Vlasta Ramik + */ +public class WildflyDeploymentArchiveProcessor implements ApplicationArchiveProcessor { + + private final Logger log = Logger.getLogger(WildflyDeploymentArchiveProcessor.class); + + @Override + public void process(Archive archive, TestClass testClass) { + if (DeploymentArchiveProcessorUtils.checkRunOnServerDeployment(archive)) return; + + modifyWebXML(archive, testClass); + + modifyOIDCAdapterConfig(archive, DeploymentArchiveProcessorUtils.ADAPTER_CONFIG_PATH); + modifyOIDCAdapterConfig(archive, DeploymentArchiveProcessorUtils.ADAPTER_CONFIG_PATH_JS); + + modifySAMLAdapterConfig(archive); + } + + private void modifyWebXML(Archive archive, TestClass testClass) { + if (!archive.contains(DeploymentArchiveProcessorUtils.WEBXML_PATH)) return; + if (!testClass.getJavaClass().isAnnotationPresent(UseServletFilter.class)) return; + if (!archive.contains(DeploymentArchiveProcessorUtils.JBOSS_DEPLOYMENT_XML_PATH)) return; + + log.debug("Modifying WEB.XML in " + archive.getName() + " for Servlet Filter."); + DeploymentArchiveProcessorUtils.modifyWebXMLForServletFilter(archive, testClass); + DeploymentArchiveProcessorUtils.addFilterDependencies(archive, testClass); + } + + private void modifyOIDCAdapterConfig(Archive archive, String adapterConfigPath) { + if (!archive.contains(adapterConfigPath)) return; + + log.debug("Modifying adapter config " + adapterConfigPath + " in " + archive.getName()); + + DeploymentArchiveProcessorUtils.modifyOIDCAdapterConfig(archive, adapterConfigPath); + } + + private void modifySAMLAdapterConfig(Archive archive) { + if (!archive.contains(DeploymentArchiveProcessorUtils.SAML_ADAPTER_CONFIG_PATH)) return; + + log.debug("Modifying adapter config " + DeploymentArchiveProcessorUtils.SAML_ADAPTER_CONFIG_PATH + " in " + archive.getName()); + DeploymentArchiveProcessorUtils.modifySAMLAdapterConfig(archive); + } +} diff --git a/testsuite/integration-arquillian/servers/app-server/jboss/wildfly/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension b/testsuite/integration-arquillian/servers/app-server/jboss/wildfly/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension new file mode 100644 index 0000000000..58cf0f1602 --- /dev/null +++ b/testsuite/integration-arquillian/servers/app-server/jboss/wildfly/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension @@ -0,0 +1 @@ +org.keycloak.testsuite.arquillian.wildfly.WildflyAppServerArquillianExtension diff --git a/testsuite/integration-arquillian/servers/app-server/undertow/pom.xml b/testsuite/integration-arquillian/servers/app-server/undertow/pom.xml index 4eae9689e8..5b4946b8ad 100644 --- a/testsuite/integration-arquillian/servers/app-server/undertow/pom.xml +++ b/testsuite/integration-arquillian/servers/app-server/undertow/pom.xml @@ -39,7 +39,7 @@ org.keycloak.testsuite - integration-arquillian-servers-util + integration-arquillian-util ${project.version} diff --git a/testsuite/integration-arquillian/servers/app-server/undertow/src/main/java/org/keycloak/testsuite/arquillian/undertow/UndertowAppServerArquillianExtension.java b/testsuite/integration-arquillian/servers/app-server/undertow/src/main/java/org/keycloak/testsuite/arquillian/undertow/UndertowAppServerArquillianExtension.java index 491af13b1d..06d18d691e 100644 --- a/testsuite/integration-arquillian/servers/app-server/undertow/src/main/java/org/keycloak/testsuite/arquillian/undertow/UndertowAppServerArquillianExtension.java +++ b/testsuite/integration-arquillian/servers/app-server/undertow/src/main/java/org/keycloak/testsuite/arquillian/undertow/UndertowAppServerArquillianExtension.java @@ -18,7 +18,9 @@ package org.keycloak.testsuite.arquillian.undertow; import org.jboss.arquillian.container.spi.client.container.DeployableContainer; +import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor; import org.jboss.arquillian.core.spi.LoadableExtension; +import org.keycloak.testsuite.arquillian.undertow.container.UndertowDeploymentArchiveProcessor; /** * @author Vlasta Ramik @@ -27,7 +29,10 @@ public class UndertowAppServerArquillianExtension implements LoadableExtension { @Override public void register(ExtensionBuilder builder) { - builder.service(DeployableContainer.class, UndertowAppServer.class); + builder + .service(DeployableContainer.class, UndertowAppServer.class) + .service(ApplicationArchiveProcessor.class, UndertowDeploymentArchiveProcessor.class); + } diff --git a/testsuite/integration-arquillian/servers/app-server/undertow/src/main/java/org/keycloak/testsuite/arquillian/undertow/container/UndertowDeploymentArchiveProcessor.java b/testsuite/integration-arquillian/servers/app-server/undertow/src/main/java/org/keycloak/testsuite/arquillian/undertow/container/UndertowDeploymentArchiveProcessor.java new file mode 100644 index 0000000000..dd8e8e2195 --- /dev/null +++ b/testsuite/integration-arquillian/servers/app-server/undertow/src/main/java/org/keycloak/testsuite/arquillian/undertow/container/UndertowDeploymentArchiveProcessor.java @@ -0,0 +1,59 @@ +/* + * Copyright 2018 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.keycloak.testsuite.arquillian.undertow.container; + +import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor; +import org.jboss.arquillian.test.spi.TestClass; +import org.jboss.logging.Logger; +import org.jboss.shrinkwrap.api.Archive; +import org.keycloak.testsuite.utils.annotation.UseServletFilter; +import org.keycloak.testsuite.utils.arquillian.DeploymentArchiveProcessorUtils; + +/** + * + * @author Vlasta Ramik + */ +public class UndertowDeploymentArchiveProcessor implements ApplicationArchiveProcessor { + + private final Logger log = Logger.getLogger(UndertowDeploymentArchiveProcessor.class); + + @Override + public void process(Archive archive, TestClass testClass) { + if (DeploymentArchiveProcessorUtils.checkRunOnServerDeployment(archive)) return; + if (!System.getProperty("app.server", "undertow").equals("undertow")) return; + + modifyWebXML(archive, testClass); + + modifyOIDCAdapterConfig(archive, DeploymentArchiveProcessorUtils.ADAPTER_CONFIG_PATH); + } + + private void modifyWebXML(Archive archive, TestClass testClass) { + if (!archive.contains(DeploymentArchiveProcessorUtils.WEBXML_PATH)) return; + if (!testClass.getJavaClass().isAnnotationPresent(UseServletFilter.class)) return; + + log.debug("Modifying WEB.XML in " + archive.getName() + " for Servlet Filter."); + DeploymentArchiveProcessorUtils.modifyWebXMLForServletFilter(archive, testClass); + } + + private void modifyOIDCAdapterConfig(Archive archive, String adapterConfigPath) { + if (!archive.contains(adapterConfigPath)) return; + + log.debug("Modifying adapter config " + adapterConfigPath + " in " + archive.getName()); + + DeploymentArchiveProcessorUtils.modifyOIDCAdapterConfig(archive, adapterConfigPath); + } +} diff --git a/testsuite/integration-arquillian/servers/auth-server/undertow/pom.xml b/testsuite/integration-arquillian/servers/auth-server/undertow/pom.xml index 30f47cf414..bd9a509ad0 100644 --- a/testsuite/integration-arquillian/servers/auth-server/undertow/pom.xml +++ b/testsuite/integration-arquillian/servers/auth-server/undertow/pom.xml @@ -36,7 +36,7 @@ org.keycloak.testsuite - integration-arquillian-servers-util + integration-arquillian-util ${project.version} diff --git a/testsuite/integration-arquillian/servers/pom.xml b/testsuite/integration-arquillian/servers/pom.xml index 0abfeeee8a..a67217ebc8 100644 --- a/testsuite/integration-arquillian/servers/pom.xml +++ b/testsuite/integration-arquillian/servers/pom.xml @@ -64,19 +64,8 @@ auth-server app-server cache-server - util - - - - org.jboss.arquillian.container - undertow-embedded - ${undertow-embedded.version} - - - - auth-server-cluster diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/page/AngularCorsProductTestApp.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/page/AngularCorsProductTestApp.java index cb84089f0f..3359f50c42 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/page/AngularCorsProductTestApp.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/page/AngularCorsProductTestApp.java @@ -21,6 +21,7 @@ import org.jboss.arquillian.container.test.api.OperateOnDeployment; import org.jboss.arquillian.graphene.findby.FindByJQuery; import org.jboss.arquillian.test.api.ArquillianResource; import org.keycloak.testsuite.page.AbstractPageWithInjectedUrl; +import org.keycloak.testsuite.util.WaitUtils; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -70,40 +71,49 @@ public class AngularCorsProductTestApp extends AbstractPageWithInjectedUrl { private WebElement headers; public void reloadData() { + WaitUtils.waitUntilElement(reloadDataButton).is().clickable(); reloadDataButton.click(); } public void loadRoles() { + WaitUtils.waitUntilElement(loadRolesButton).is().clickable(); loadRolesButton.click(); } public void addRole() { + WaitUtils.waitUntilElement(addRoleButton).is().clickable(); addRoleButton.click(); } public void deleteRole() { + WaitUtils.waitUntilElement(deleteRoleButton).is().clickable(); deleteRoleButton.click(); } public void loadAvailableSocialProviders() { + WaitUtils.waitUntilElement(loadAvailableSocialProvidersButton).is().clickable(); loadAvailableSocialProvidersButton.click(); } public void loadPublicRealmInfo() { + WaitUtils.waitUntilElement(loadPublicRealmInfoButton).is().clickable(); loadPublicRealmInfoButton.click(); } public void loadVersion() { + WaitUtils.waitUntilElement(loadVersionButton).is().clickable(); loadVersionButton.click(); } public WebElement getOutput() { + WaitUtils.waitUntilElement(outputArea).is().visible(); return outputArea; } public WebElement getHeaders() { + WaitUtils.waitUntilElement(headers).is().visible(); return headers; } -} \ No newline at end of file +} diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/AppServerTestEnricher.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/AppServerTestEnricher.java index a1d02ef468..df35f7f066 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/AppServerTestEnricher.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/AppServerTestEnricher.java @@ -206,6 +206,10 @@ public class AppServerTestEnricher { return CURRENT_APP_SERVER.equals("eap6"); } + public static boolean isEAPAppServer() { + return CURRENT_APP_SERVER.equals("eap"); + } + public static boolean isWASAppServer() { return CURRENT_APP_SERVER.equals("was"); } diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/DeploymentArchiveProcessor.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/DeploymentArchiveProcessor.java index 9c34b52e91..4a3ee67b1a 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/DeploymentArchiveProcessor.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/DeploymentArchiveProcessor.java @@ -17,19 +17,14 @@ package org.keycloak.testsuite.arquillian; -import org.apache.tools.ant.DirectoryScanner; +import org.keycloak.testsuite.utils.arquillian.KeycloakDependenciesResolver; import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor; import org.jboss.arquillian.core.api.InstanceProducer; import org.jboss.arquillian.core.api.annotation.Inject; import org.jboss.arquillian.test.spi.TestClass; import org.jboss.arquillian.test.spi.annotation.ClassScoped; -import org.jboss.logging.Logger; -import org.jboss.logging.Logger.Level; import org.jboss.shrinkwrap.api.Archive; -import org.jboss.shrinkwrap.api.ArchivePath; -import org.jboss.shrinkwrap.api.Filters; import org.jboss.shrinkwrap.api.Node; -import org.jboss.shrinkwrap.api.asset.ClassAsset; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.jboss.shrinkwrap.resolver.api.maven.Maven; @@ -37,44 +32,42 @@ import org.jboss.shrinkwrap.resolver.api.maven.MavenFormatStage; import org.jboss.shrinkwrap.resolver.api.maven.MavenResolverSystem; import org.keycloak.adapters.servlet.KeycloakOIDCFilter; import org.keycloak.representations.adapters.config.AdapterConfig; -import org.keycloak.testsuite.arquillian.annotation.UseServletFilter; -import org.keycloak.testsuite.util.IOUtil; +import org.keycloak.testsuite.utils.annotation.UseServletFilter; +import org.keycloak.testsuite.utils.io.IOUtil; import org.keycloak.util.JsonSerialization; import org.w3c.dom.Document; import org.w3c.dom.Element; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static org.keycloak.testsuite.arquillian.AppServerTestEnricher.hasAppServerContainerAnnotation; +import org.jboss.logging.Logger; import static org.keycloak.testsuite.arquillian.AppServerTestEnricher.isEAP6AppServer; +import static org.keycloak.testsuite.arquillian.AppServerTestEnricher.isEAPAppServer; import static org.keycloak.testsuite.arquillian.AppServerTestEnricher.isRelative; import static org.keycloak.testsuite.arquillian.AppServerTestEnricher.isTomcatAppServer; +import static org.keycloak.testsuite.arquillian.AppServerTestEnricher.isUndertowAppServer; import static org.keycloak.testsuite.arquillian.AppServerTestEnricher.isWLSAppServer; import static org.keycloak.testsuite.arquillian.AppServerTestEnricher.isWASAppServer; +import static org.keycloak.testsuite.arquillian.AppServerTestEnricher.isWildflyAppServer; import static org.keycloak.testsuite.arquillian.AuthServerTestEnricher.getAuthServerContextRoot; -import static org.keycloak.testsuite.arquillian.AuthServerTestEnricher.AUTH_SERVER_CONTAINER; -import static org.keycloak.testsuite.arquillian.AuthServerTestEnricher.AUTH_SERVER_CONTAINER_DEFAULT; -import static org.keycloak.testsuite.util.IOUtil.appendChildInDocument; -import static org.keycloak.testsuite.util.IOUtil.documentToString; -import static org.keycloak.testsuite.util.IOUtil.getElementTextContent; -import static org.keycloak.testsuite.util.IOUtil.loadJson; -import static org.keycloak.testsuite.util.IOUtil.loadXML; -import static org.keycloak.testsuite.util.IOUtil.modifyDocElementAttribute; -import static org.keycloak.testsuite.util.IOUtil.modifyDocElementValue; -import static org.keycloak.testsuite.util.IOUtil.removeElementsFromDoc; -import static org.keycloak.testsuite.util.IOUtil.removeNodeByAttributeValue; +import static org.keycloak.testsuite.utils.io.IOUtil.appendChildInDocument; +import static org.keycloak.testsuite.utils.io.IOUtil.documentToString; +import static org.keycloak.testsuite.utils.io.IOUtil.getElementTextContent; +import static org.keycloak.testsuite.utils.io.IOUtil.loadJson; +import static org.keycloak.testsuite.utils.io.IOUtil.loadXML; +import static org.keycloak.testsuite.utils.io.IOUtil.modifyDocElementAttribute; +import static org.keycloak.testsuite.utils.io.IOUtil.modifyDocElementValue; +import static org.keycloak.testsuite.utils.io.IOUtil.removeElementsFromDoc; +import static org.keycloak.testsuite.utils.io.IOUtil.removeNodeByAttributeValue; /** * @author tkyjovsk */ +@Deprecated public class DeploymentArchiveProcessor implements ApplicationArchiveProcessor { - protected final Logger log = org.jboss.logging.Logger.getLogger(this.getClass()); + protected final Logger log = Logger.getLogger(DeploymentArchiveProcessor.class); private static final boolean AUTH_SERVER_SSL_REQUIRED = Boolean.parseBoolean(System.getProperty("auth.server.ssl.required")); private static final boolean APP_SERVER_SSL_REQUIRED = Boolean.parseBoolean(System.getProperty("app.server.ssl.required")); @@ -98,17 +91,21 @@ public class DeploymentArchiveProcessor implements ApplicationArchiveProcessor { return; } + // Ignore archives modifed in specific DeploymentArchiveProcessors, see e.g. + // org.keycloak.testsuite.arquillian.wildfly.container.WildflyDeploymentArchiveProcessor + if (isEAP6AppServer() || + isEAPAppServer() || + isWildflyAppServer() || + isUndertowAppServer()) { + + return; + } + log.info("Processing archive " + archive.getName()); -// if (isAdapterTest(testClass)) { modifyAdapterConfigs(archive, testClass); - if (archive.contains(WEBXML_PATH)) { - modifyWebXml(archive, testClass); - } -// } else { -// log.info(testClass.getJavaClass().getSimpleName() + " is not an AdapterTest"); -// } - if (isWLSAppServer()) { -// { + modifyWebXml(archive, testClass); + + if (isWLSAppServer() || isWASAppServer()) { MavenResolverSystem resolver = Maven.resolver(); MavenFormatStage dependencies = resolver .loadPomFromFile("pom.xml") @@ -119,30 +116,8 @@ public class DeploymentArchiveProcessor implements ApplicationArchiveProcessor { ((WebArchive) archive) .addAsLibraries(dependencies.asFile()) .addClass(org.keycloak.testsuite.arquillian.annotation.AppServerContainer.class) - .addClass(org.keycloak.testsuite.arquillian.annotation.UseServletFilter.class); + .addClass(org.keycloak.testsuite.utils.annotation.UseServletFilter.class); } - - if (isWASAppServer()) { -// { - MavenResolverSystem resolver = Maven.resolver(); - MavenFormatStage dependencies = resolver - .loadPomFromFile("pom.xml") - .importTestDependencies() - .resolve("org.apache.httpcomponents:httpclient") - .withTransitivity(); - - ((WebArchive) archive) - .addAsLibraries(dependencies.asFile()) - .addClass(org.keycloak.testsuite.arquillian.annotation.AppServerContainer.class) - .addClass(org.keycloak.testsuite.arquillian.annotation.UseServletFilter.class); - } - - - - } - - public static boolean isAdapterTest(TestClass testClass) { - return hasAppServerContainerAnnotation(testClass.getJavaClass()); } protected void modifyAdapterConfigs(Archive archive, TestClass testClass) { @@ -191,16 +166,9 @@ public class DeploymentArchiveProcessor implements ApplicationArchiveProcessor { AdapterConfig adapterConfig = loadJson(archive.get(adapterConfigPath) .getAsset().openStream(), AdapterConfig.class); - // TODO find out if this is necessary - if (relative && !AUTH_SERVER_CONTAINER.equals(AUTH_SERVER_CONTAINER_DEFAULT)) { - log.info(" setting relative auth-server-url"); - adapterConfig.setAuthServerUrl("/auth"); -// ac.setRealmKey(null); // TODO verify if realm key is required for relative scneario - } else { - adapterConfig.setAuthServerUrl(getAuthServerContextRoot() + "/auth"); - } + adapterConfig.setAuthServerUrl(getAuthServerContextRoot() + "/auth"); - if ("true".equals(System.getProperty("app.server.ssl.required"))) { + if (APP_SERVER_SSL_REQUIRED) { adapterConfig.setSslRequired("all"); } @@ -208,38 +176,24 @@ public class DeploymentArchiveProcessor implements ApplicationArchiveProcessor { adapterConfigPath); } catch (IOException ex) { - log.log(Level.FATAL, "Cannot serialize adapter config to JSON.", ex); + log.error("Cannot serialize adapter config to JSON.", ex); } } } } - DirectoryScanner scanner = new DirectoryScanner(); - - protected List getAdapterLibs(File adapterLibsLocation) { - assert adapterLibsLocation.exists(); - List libs = new ArrayList<>(); - scanner.setBasedir(adapterLibsLocation); - scanner.setIncludes(new String[]{"**/*jar"}); - scanner.scan(); - for (String lib : scanner.getIncludedFiles()) { - libs.add(new File(adapterLibsLocation, lib)); - } - return libs; - } - public void addFilterDependencies(Archive archive, TestClass testClass) { TestContext testContext = testContextProducer.get(); if (testContext.getAppServerInfo().isUndertow()) { return; } - + Node jbossDeploymentStructureXml = archive.get(JBOSS_DEPLOYMENT_XML_PATH); if (jbossDeploymentStructureXml == null) { log.debug("Archive doesn't contain " + JBOSS_DEPLOYMENT_XML_PATH); return; } - + log.info("Adding filter dependencies to " + archive.getName()); String dependency = testClass.getAnnotation(UseServletFilter.class).filterDependency(); @@ -253,24 +207,19 @@ public class DeploymentArchiveProcessor implements ApplicationArchiveProcessor { } protected void modifyWebXml(Archive archive, TestClass testClass) { + if (!archive.contains(WEBXML_PATH)) return; + Document webXmlDoc; try { webXmlDoc = loadXML( archive.get(WEBXML_PATH).getAsset().openStream()); - } catch (Exception ex) { + } catch (IllegalArgumentException ex) { throw new RuntimeException("Error when processing " + archive.getName(), ex); } if (isTomcatAppServer()) { modifyDocElementValue(webXmlDoc, "auth-method", "KEYCLOAK", "BASIC"); } - //temporary solution, will be removed within KEYCLOAK-7510 - if (isEAP6AppServer()) { - modifyDocElementValue(webXmlDoc, "param-value", - "org.keycloak.adapters.saml.wildfly.infinispan.InfinispanSessionCacheIdMapperUpdater", - "org.keycloak.adapters.saml.jbossweb.infinispan.InfinispanSessionCacheIdMapperUpdater"); - } - if (testClass.getJavaClass().isAnnotationPresent(UseServletFilter.class) && archive.contains(JBOSS_DEPLOYMENT_XML_PATH)) { addFilterDependencies(archive, testClass); @@ -339,16 +288,4 @@ public class DeploymentArchiveProcessor implements ApplicationArchiveProcessor { archive.add(new StringAsset((documentToString(webXmlDoc))), WEBXML_PATH); } - - private String getServletClassName(Archive archive) { - - Map content = archive.getContent(Filters.include(".*Servlet.class")); - for (ArchivePath path : content.keySet()) { - ClassAsset asset = (ClassAsset) content.get(path).getAsset(); - return asset.getSource().getName(); - } - - return null; - } - } diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/pages/AppServerWelcomePage.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/pages/AppServerWelcomePage.java index dbb2e5fcdb..f5e04be821 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/pages/AppServerWelcomePage.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/pages/AppServerWelcomePage.java @@ -24,7 +24,6 @@ import org.keycloak.testsuite.auth.page.login.OIDCLogin; import org.keycloak.testsuite.util.DroneUtils; import org.keycloak.testsuite.util.JavascriptBrowser; import org.keycloak.testsuite.util.URLUtils; -import org.keycloak.testsuite.util.WaitUtils; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -52,9 +51,8 @@ public class AppServerWelcomePage extends AppServerContextRoot { } public void navigateToConsole() { - WaitUtils.pause(2000); URLUtils.navigateToUri(getInjectedUrl().toString() + "/console", true); - waitForPageToLoad(); + loginPage.form().waitForLoginButtonPresent(); } public void login(String username, String password) { diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/AdminClientUtil.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/AdminClientUtil.java index 7dc4d6e039..316e0ec8cc 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/AdminClientUtil.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/AdminClientUtil.java @@ -37,7 +37,7 @@ import org.keycloak.testsuite.arquillian.SuiteContext; import static org.keycloak.testsuite.auth.page.AuthRealm.ADMIN; import static org.keycloak.testsuite.auth.page.AuthRealm.MASTER; -import static org.keycloak.testsuite.util.IOUtil.PROJECT_BUILD_DIRECTORY; +import static org.keycloak.testsuite.utils.io.IOUtil.PROJECT_BUILD_DIRECTORY; public class AdminClientUtil { diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/LDAPTestConfiguration.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/LDAPTestConfiguration.java index b148a82656..7e7232464c 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/LDAPTestConfiguration.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/LDAPTestConfiguration.java @@ -32,7 +32,7 @@ import java.net.URL; import java.util.HashMap; import java.util.Map; -import static org.keycloak.testsuite.util.IOUtil.PROJECT_BUILD_DIRECTORY; +import static org.keycloak.testsuite.utils.io.IOUtil.PROJECT_BUILD_DIRECTORY; /** * @author Marek Posolda diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/Timer.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/Timer.java index 802b16d866..2d15778b1a 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/Timer.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/Timer.java @@ -36,7 +36,7 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; -import static org.keycloak.testsuite.util.IOUtil.PROJECT_BUILD_DIRECTORY; +import static org.keycloak.testsuite.utils.io.IOUtil.PROJECT_BUILD_DIRECTORY; /** * diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/AbstractSAMLAdapterClusteredTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/AbstractSAMLAdapterClusteredTest.java index 5453a57dca..576eadfcdb 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/AbstractSAMLAdapterClusteredTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/AbstractSAMLAdapterClusteredTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertThat; import static org.keycloak.testsuite.admin.Users.setPasswordFor; import static org.keycloak.testsuite.arquillian.DeploymentTargetModifier.APP_SERVER_CURRENT; import static org.keycloak.testsuite.auth.page.AuthRealm.DEMO; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; +import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm; import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith; import io.undertow.Undertow; diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/AbstractServletsAdapterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/AbstractServletsAdapterTest.java index 294106dc08..622011026e 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/AbstractServletsAdapterTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/AbstractServletsAdapterTest.java @@ -24,6 +24,7 @@ import org.jboss.shrinkwrap.api.spec.WebArchive; import org.keycloak.representations.idm.RealmRepresentation; import org.keycloak.testsuite.adapter.filter.AdapterActionsFilter; import org.keycloak.testsuite.util.WaitUtils; +import org.keycloak.testsuite.utils.io.IOUtil; import org.openqa.selenium.By; import javax.ws.rs.core.UriBuilder; @@ -34,7 +35,6 @@ import java.util.List; import org.junit.Assert; import static org.keycloak.testsuite.auth.page.AuthRealm.DEMO; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; public abstract class AbstractServletsAdapterTest extends AbstractAdapterTest { @@ -112,7 +112,7 @@ public abstract class AbstractServletsAdapterTest extends AbstractAdapterTest { @Override public void addAdapterTestRealms(List testRealms) { - testRealms.add(loadRealm("/adapter-test/demorealm.json")); + testRealms.add(IOUtil.loadRealm("/adapter-test/demorealm.json")); } @Override diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/AbstractFuseAdminAdapterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/AbstractFuseAdminAdapterTest.java index c0924ff3e3..d3918f14ee 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/AbstractFuseAdminAdapterTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/AbstractFuseAdminAdapterTest.java @@ -2,7 +2,7 @@ package org.keycloak.testsuite.adapter.example; import static org.junit.Assert.assertTrue; import static org.keycloak.testsuite.auth.page.AuthRealm.DEMO; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; +import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm; import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlDoesntStartWith; import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith; diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/AbstractFuseExampleAdapterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/AbstractFuseExampleAdapterTest.java index 41afa051c8..262f01d918 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/AbstractFuseExampleAdapterTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/AbstractFuseExampleAdapterTest.java @@ -37,7 +37,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.keycloak.testsuite.auth.page.AuthRealm.DEMO; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; +import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm; import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith; import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWithLoginUrlOf; diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/AbstractHawtioAdapterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/AbstractHawtioAdapterTest.java index c430b465e2..7f64ae87ff 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/AbstractHawtioAdapterTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/AbstractHawtioAdapterTest.java @@ -12,7 +12,7 @@ import org.openqa.selenium.By; import java.util.List; import static org.keycloak.testsuite.auth.page.AuthRealm.DEMO; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; +import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm; import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith; import static org.keycloak.testsuite.util.WaitUtils.pause; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement; diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/authorization/AbstractBaseServletAuthzAdapterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/authorization/AbstractBaseServletAuthzAdapterTest.java index 4b8c19a8bd..f0d0406806 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/authorization/AbstractBaseServletAuthzAdapterTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/authorization/AbstractBaseServletAuthzAdapterTest.java @@ -42,8 +42,8 @@ import java.net.URL; import java.util.List; import static org.junit.Assert.assertFalse; -import static org.keycloak.testsuite.util.IOUtil.loadJson; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; +import static org.keycloak.testsuite.utils.io.IOUtil.loadJson; +import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm; import static org.keycloak.testsuite.util.WaitUtils.pause; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement; diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/authorization/AbstractPhotozExampleAdapterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/authorization/AbstractPhotozExampleAdapterTest.java index 755575e8e7..e225151bc4 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/authorization/AbstractPhotozExampleAdapterTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/authorization/AbstractPhotozExampleAdapterTest.java @@ -83,8 +83,8 @@ import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; -import static org.keycloak.testsuite.util.IOUtil.loadJson; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; +import static org.keycloak.testsuite.utils.io.IOUtil.loadJson; +import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm; import static org.keycloak.testsuite.util.WaitUtils.waitForPageToLoad; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement; diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/authorization/DefaultAuthzConfigAdapterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/authorization/DefaultAuthzConfigAdapterTest.java index 059d8011e5..3ba0977e84 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/authorization/DefaultAuthzConfigAdapterTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/authorization/DefaultAuthzConfigAdapterTest.java @@ -41,7 +41,7 @@ import java.net.URL; import java.util.List; import static org.junit.Assert.assertTrue; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; +import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm; /** * @author Pedro Igor diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/authorization/ServletPolicyEnforcerTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/authorization/ServletPolicyEnforcerTest.java index 9428f81202..7b8f331027 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/authorization/ServletPolicyEnforcerTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/authorization/ServletPolicyEnforcerTest.java @@ -18,7 +18,7 @@ package org.keycloak.testsuite.adapter.example.authorization; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; +import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm; import static org.keycloak.testsuite.util.WaitUtils.pause; import java.io.File; diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/cors/CorsExampleAdapterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/cors/CorsExampleAdapterTest.java index 0ac7b3a02f..1200605786 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/cors/CorsExampleAdapterTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/cors/CorsExampleAdapterTest.java @@ -48,7 +48,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import static junit.framework.TestCase.assertNotNull; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; +import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm; import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith; import static org.keycloak.testsuite.util.WaitUtils.waitForPageToLoad; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement; diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/hal/ConsoleProtectionTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/hal/ConsoleProtectionTest.java index b8e05e7ad4..3e60a9cfd9 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/hal/ConsoleProtectionTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/hal/ConsoleProtectionTest.java @@ -17,10 +17,11 @@ package org.keycloak.testsuite.adapter.example.hal; import static org.junit.Assert.assertTrue; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; +import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm; import java.io.IOException; import java.util.List; +import java.util.concurrent.TimeoutException; import org.jboss.arquillian.drone.api.annotation.Drone; import org.jboss.arquillian.graphene.page.Page; @@ -43,6 +44,7 @@ import org.wildfly.extras.creaper.core.online.OnlineManagementClient; import org.wildfly.extras.creaper.core.online.operations.Address; import org.wildfly.extras.creaper.core.online.operations.OperationException; import org.wildfly.extras.creaper.core.online.operations.Operations; +import org.wildfly.extras.creaper.core.online.operations.admin.Administration; /** * @@ -98,13 +100,15 @@ public class ConsoleProtectionTest extends AbstractAdapterTest { // Create a secure-server in order to publish the wildfly console configuration via mgmt interface clientWorkerNodeClient.execute("/subsystem=keycloak/secure-server=wildfly-console:add(realm=jboss-infra,resource=wildfly-console,public-client=true)"); - // reload - clientWorkerNodeClient.execute("reload"); - } catch (CliException cause) { + log.debug("Reloading the server"); + new Administration(clientWorkerNodeClient).reload(); + log.debug("Reloaded"); + } catch (CliException | IOException | InterruptedException | TimeoutException cause) { throw new RuntimeException("Failed to configure app server", cause); } DroneUtils.addWebDriver(jsDriver); + log.debug("Added jsDriver"); } private void testLogin() throws InterruptedException { diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/DemoFilterServletAdapterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/DemoFilterServletAdapterTest.java index bc74ae15e4..87331941dc 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/DemoFilterServletAdapterTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/DemoFilterServletAdapterTest.java @@ -19,7 +19,7 @@ package org.keycloak.testsuite.adapter.servlet; import org.junit.Ignore; import org.junit.Test; import org.keycloak.testsuite.arquillian.annotation.AppServerContainer; -import org.keycloak.testsuite.arquillian.annotation.UseServletFilter; +import org.keycloak.testsuite.utils.annotation.UseServletFilter; import org.keycloak.testsuite.arquillian.containers.ContainerConstants; @AppServerContainer(ContainerConstants.APP_SERVER_UNDERTOW) diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/MultiTenancyTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/MultiTenancyTest.java index 92b13450ab..5ec3b350b4 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/MultiTenancyTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/MultiTenancyTest.java @@ -34,7 +34,7 @@ import org.keycloak.testsuite.arquillian.containers.ContainerConstants; import org.keycloak.testsuite.util.URLAssert; import org.keycloak.testsuite.util.WaitUtils; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; +import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm; /** * note: migrated from old testsuite diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/OfflineServletsAdapterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/OfflineServletsAdapterTest.java index fceb565182..7372f00e10 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/OfflineServletsAdapterTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/OfflineServletsAdapterTest.java @@ -22,11 +22,11 @@ import org.keycloak.testsuite.pages.AccountApplicationsPage; import org.keycloak.testsuite.pages.LoginPage; import org.keycloak.testsuite.pages.OAuthGrantPage; import org.keycloak.testsuite.util.ClientManager; +import org.keycloak.testsuite.utils.io.IOUtil; import org.keycloak.util.TokenUtil; import org.openqa.selenium.By; import static org.keycloak.testsuite.auth.page.AuthRealm.TEST; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlDoesntStartWith; import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith; import static org.keycloak.testsuite.util.WaitUtils.pause; @@ -67,7 +67,7 @@ public class OfflineServletsAdapterTest extends AbstractServletsAdapterTest { @Override public void addAdapterTestRealms(List testRealms) { - testRealms.add(loadRealm("/adapter-test/offline-client/offlinerealm.json")); + testRealms.add(IOUtil.loadRealm("/adapter-test/offline-client/offlinerealm.json")); } @Test diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/SAMLFilterServletAdapterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/SAMLFilterServletAdapterTest.java index 3f8e802988..b21a82155b 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/SAMLFilterServletAdapterTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/SAMLFilterServletAdapterTest.java @@ -5,7 +5,7 @@ import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.keycloak.testsuite.arquillian.annotation.AppServerContainer; -import org.keycloak.testsuite.arquillian.annotation.UseServletFilter; +import org.keycloak.testsuite.utils.annotation.UseServletFilter; import org.keycloak.testsuite.arquillian.containers.ContainerConstants; /** @@ -16,7 +16,7 @@ import org.keycloak.testsuite.arquillian.containers.ContainerConstants; @AppServerContainer(ContainerConstants.APP_SERVER_EAP6) @UseServletFilter(filterName = "saml-filter", filterClass = "org.keycloak.adapters.saml.servlet.SamlFilter", filterDependency = "org.keycloak:keycloak-saml-servlet-filter-adapter") -public class SAMLFilterServletAdapterTest extends SAMLServletsAdapterTest { +public class SAMLFilterServletAdapterTest extends SAMLServletAdapterTest { @Before public void checkRoles() { diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/SAMLServletsAdapterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/SAMLServletAdapterTest.java similarity index 91% rename from testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/SAMLServletsAdapterTest.java rename to testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/SAMLServletAdapterTest.java index 4c514b61dc..cb022cd33e 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/SAMLServletsAdapterTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/SAMLServletAdapterTest.java @@ -17,70 +17,37 @@ package org.keycloak.testsuite.adapter.servlet; -import org.jboss.resteasy.util.Base64; -import org.keycloak.dom.saml.v2.protocol.ResponseType; -import org.keycloak.dom.saml.v2.protocol.StatusCodeType; -import org.keycloak.dom.saml.v2.protocol.StatusResponseType; -import org.keycloak.saml.common.constants.JBossSAMLConstants; -import org.keycloak.saml.common.util.DocumentUtil; -import org.keycloak.saml.processing.core.parsers.saml.SAMLParser; -import org.keycloak.testsuite.updaters.ClientAttributeUpdater; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.client.protocol.HttpClientContext; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.util.EntityUtils; -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.graphene.page.Page; -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.asset.StringAsset; -import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.Assert; -import org.junit.Test; +import static javax.ws.rs.core.Response.Status.OK; +import static org.hamcrest.Matchers.*; +import static org.keycloak.OAuth2Constants.PASSWORD; +import static org.keycloak.testsuite.admin.ApiUtil.createUserAndResetPasswordWithAdminClient; +import static org.keycloak.testsuite.admin.Users.setPasswordFor; +import static org.keycloak.testsuite.AbstractAuthTest.createUserRepresentation; +import static org.keycloak.testsuite.adapter.AbstractServletsAdapterTest.samlServletDeployment; +import static org.keycloak.testsuite.auth.page.AuthRealm.SAMLSERVLETDEMO; +import static org.keycloak.testsuite.saml.AbstractSamlTest.REALM_PRIVATE_KEY; +import static org.keycloak.testsuite.saml.AbstractSamlTest.REALM_PUBLIC_KEY; +import static org.keycloak.testsuite.util.Matchers.bodyHC; +import static org.keycloak.testsuite.util.Matchers.statusCodeIsHC; +import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith; +import static org.keycloak.testsuite.util.WaitUtils.waitForPageToLoad; +import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement; -import org.keycloak.admin.client.resource.ClientResource; -import org.keycloak.admin.client.resource.ProtocolMappersResource; -import org.keycloak.admin.client.resource.RoleScopeResource; -import org.keycloak.common.util.KeyUtils; -import org.keycloak.common.util.PemUtils; -import org.keycloak.dom.saml.v2.protocol.AuthnRequestType; -import org.keycloak.keys.Attributes; -import org.keycloak.keys.KeyProvider; -import org.keycloak.keys.ImportedRsaKeyProviderFactory; -import org.keycloak.protocol.saml.SamlConfigAttributes; -import org.keycloak.protocol.saml.SamlProtocol; -import org.keycloak.representations.idm.ComponentRepresentation; -import org.keycloak.protocol.saml.mappers.AttributeStatementHelper; -import org.keycloak.protocol.saml.mappers.RoleListMapper; -import org.keycloak.representations.idm.ClientRepresentation; -import org.keycloak.representations.idm.ProtocolMapperRepresentation; -import org.keycloak.representations.idm.RealmRepresentation; -import org.keycloak.representations.idm.RoleRepresentation; -import org.keycloak.representations.idm.UserRepresentation; -import org.keycloak.saml.SAML2ErrorResponseBuilder; -import org.keycloak.saml.common.constants.JBossSAMLURIConstants; -import org.keycloak.saml.common.util.XmlKeyInfoKeyNameTransformer; -import org.keycloak.saml.processing.core.saml.v2.common.SAMLDocumentHolder; -import org.keycloak.services.resources.RealmsResource; -import org.keycloak.testsuite.adapter.AbstractServletsAdapterTest; -import org.keycloak.testsuite.adapter.page.*; -import org.keycloak.testsuite.admin.ApiUtil; -import org.keycloak.testsuite.arquillian.annotation.AppServerContainer; -import org.keycloak.testsuite.arquillian.containers.ContainerConstants; -import org.keycloak.testsuite.auth.page.login.Login; -import org.keycloak.testsuite.auth.page.login.SAMLIDPInitiatedLogin; -import org.keycloak.testsuite.page.AbstractPage; -import org.keycloak.testsuite.util.*; - -import org.keycloak.testsuite.util.SamlClient.Binding; -import org.keycloak.testsuite.util.SamlClientBuilder; -import org.openqa.selenium.By; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.xml.sax.SAXException; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.Closeable; +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.net.URI; +import java.net.URL; +import java.security.KeyPair; +import java.security.PublicKey; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; @@ -109,43 +76,83 @@ import javax.xml.transform.stream.StreamSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; import javax.xml.validation.Validator; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.Closeable; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.net.URI; -import java.net.URL; -import java.security.KeyPair; -import java.security.PublicKey; -import java.util.*; -import java.util.stream.Collectors; - import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathFactory; + +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpUriRequest; +import org.apache.http.client.protocol.HttpClientContext; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.util.EntityUtils; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.graphene.page.Page; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; + +import org.junit.Assert; +import org.junit.Test; + +import org.keycloak.admin.client.resource.ClientResource; +import org.keycloak.admin.client.resource.ProtocolMappersResource; +import org.keycloak.admin.client.resource.RoleScopeResource; +import org.keycloak.common.util.Base64; +import org.keycloak.common.util.KeyUtils; +import org.keycloak.common.util.PemUtils; +import org.keycloak.dom.saml.v2.protocol.AuthnRequestType; +import org.keycloak.dom.saml.v2.protocol.ResponseType; +import org.keycloak.dom.saml.v2.protocol.StatusCodeType; +import org.keycloak.dom.saml.v2.protocol.StatusResponseType; +import org.keycloak.keys.Attributes; +import org.keycloak.keys.ImportedRsaKeyProviderFactory; +import org.keycloak.keys.KeyProvider; +import org.keycloak.protocol.saml.SamlConfigAttributes; +import org.keycloak.protocol.saml.SamlProtocol; +import org.keycloak.protocol.saml.mappers.AttributeStatementHelper; +import org.keycloak.protocol.saml.mappers.RoleListMapper; +import org.keycloak.representations.idm.ClientRepresentation; +import org.keycloak.representations.idm.ComponentRepresentation; +import org.keycloak.representations.idm.ProtocolMapperRepresentation; +import org.keycloak.representations.idm.RealmRepresentation; +import org.keycloak.representations.idm.RoleRepresentation; +import org.keycloak.representations.idm.UserRepresentation; +import org.keycloak.saml.SAML2ErrorResponseBuilder; +import org.keycloak.saml.common.constants.JBossSAMLConstants; +import org.keycloak.saml.common.constants.JBossSAMLURIConstants; +import org.keycloak.saml.common.util.DocumentUtil; +import org.keycloak.saml.common.util.XmlKeyInfoKeyNameTransformer; +import org.keycloak.saml.processing.core.parsers.saml.SAMLParser; +import org.keycloak.saml.processing.core.saml.v2.common.SAMLDocumentHolder; +import org.keycloak.services.resources.RealmsResource; +import org.keycloak.testsuite.adapter.AbstractServletsAdapterTest; +import org.keycloak.testsuite.adapter.page.*; +import org.keycloak.testsuite.admin.ApiUtil; +import org.keycloak.testsuite.arquillian.annotation.AppServerContainer; +import org.keycloak.testsuite.arquillian.containers.ContainerConstants; +import org.keycloak.testsuite.auth.page.login.Login; +import org.keycloak.testsuite.auth.page.login.SAMLIDPInitiatedLogin; +import org.keycloak.testsuite.page.AbstractPage; +import org.keycloak.testsuite.updaters.ClientAttributeUpdater; +import org.keycloak.testsuite.util.SamlClient; +import org.keycloak.testsuite.util.SamlClient.Binding; +import org.keycloak.testsuite.util.SamlClientBuilder; +import org.keycloak.testsuite.util.UserBuilder; +import org.keycloak.testsuite.util.WaitUtils; +import org.keycloak.testsuite.utils.io.IOUtil; + +import org.openqa.selenium.By; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import static javax.ws.rs.core.Response.Status.OK; -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; -import static org.keycloak.representations.idm.CredentialRepresentation.PASSWORD; -import static org.keycloak.testsuite.AbstractAuthTest.createUserRepresentation; -import static org.keycloak.testsuite.admin.ApiUtil.createUserAndResetPasswordWithAdminClient; -import static org.keycloak.testsuite.admin.Users.setPasswordFor; -import static org.keycloak.testsuite.auth.page.AuthRealm.SAMLSERVLETDEMO; -import static org.keycloak.testsuite.saml.AbstractSamlTest.REALM_PRIVATE_KEY; -import static org.keycloak.testsuite.saml.AbstractSamlTest.REALM_PUBLIC_KEY; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; -import static org.keycloak.testsuite.util.IOUtil.loadXML; -import static org.keycloak.testsuite.util.IOUtil.modifyDocElementAttribute; -import static org.keycloak.testsuite.util.Matchers.bodyHC; -import static org.keycloak.testsuite.util.Matchers.statusCodeIsHC; -import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith; -import static org.keycloak.testsuite.util.WaitUtils.*; +import org.xml.sax.SAXException; /** * @author mhajas @@ -153,7 +160,7 @@ import static org.keycloak.testsuite.util.WaitUtils.*; @AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY) @AppServerContainer(ContainerConstants.APP_SERVER_EAP) @AppServerContainer(ContainerConstants.APP_SERVER_EAP6) -public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { +public class SAMLServletAdapterTest extends AbstractServletsAdapterTest { @Page protected BadClientSalesPostSigServlet badClientSalesPostSigServletPage; @@ -392,7 +399,7 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { @Override public void addAdapterTestRealms(List testRealms) { - testRealms.add(loadRealm("/adapter-test/keycloak-saml/testsaml.json")); + testRealms.add(IOUtil.loadRealm("/adapter-test/keycloak-saml/testsaml.json")); } @Override @@ -407,7 +414,7 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { page.navigateTo(); waitUntilElement(By.xpath("//body")).text().not().contains(expectedNotContains); //Different 403 status page on EAP and Wildfly - assertTrue(driver.getPageSource().contains("Forbidden") + Assert.assertTrue(driver.getPageSource().contains("Forbidden") || driver.getPageSource().contains(FORBIDDEN_TEXT) || driver.getPageSource().contains(WEBSPHERE_FORBIDDEN_TEXT)); // WebSphere } @@ -423,7 +430,7 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { loginPage.form().login(username, password); waitUntilElement(By.xpath("//body")).text().not().contains(expectedNotContains); //Different 403 status page on EAP and Wildfly - assertTrue(driver.getPageSource().contains("Forbidden") + Assert.assertTrue(driver.getPageSource().contains("Forbidden") || driver.getPageSource().contains(FORBIDDEN_TEXT) || driver.getPageSource().contains(WEBSPHERE_FORBIDDEN_TEXT)); // WebSphere } @@ -517,7 +524,7 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { waitUntilElement(By.xpath("//body")).text().not().contains("principal="); //Different 403 status page on EAP and Wildfly - assertTrue(driver.getPageSource().contains("Forbidden") + Assert.assertTrue(driver.getPageSource().contains("Forbidden") || driver.getPageSource().contains(FORBIDDEN_TEXT) || driver.getPageSource().contains(WEBSPHERE_FORBIDDEN_TEXT)); // WebSphere } @@ -538,9 +545,9 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { .navigateTo(employeeAcsServletPage.buildUri()) .getSamlResponse(Binding.POST); - assertThat(samlResponse.getSamlObject(), instanceOf(AuthnRequestType.class)); - assertThat(((AuthnRequestType) samlResponse.getSamlObject()).getAssertionConsumerServiceURL(), notNullValue()); - assertThat(((AuthnRequestType) samlResponse.getSamlObject()).getAssertionConsumerServiceURL().getPath(), is("/employee-acs/a/different/endpoint/for/saml")); + Assert.assertThat(samlResponse.getSamlObject(), instanceOf(AuthnRequestType.class)); + Assert.assertThat(((AuthnRequestType) samlResponse.getSamlObject()).getAssertionConsumerServiceURL(), notNullValue()); + Assert.assertThat(((AuthnRequestType) samlResponse.getSamlObject()).getAssertionConsumerServiceURL().getPath(), is("/employee-acs/a/different/endpoint/for/saml")); assertSuccessfulLogin(employeeAcsServletPage, bburkeUser, testRealmSAMLPostLoginPage, "principal=bburke"); } @@ -670,10 +677,10 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { @Test public void salesMetadataTest() throws Exception { - Document doc = loadXML(SAMLServletsAdapterTest.class.getResourceAsStream("/adapter-test/keycloak-saml/sp-metadata.xml")); + Document doc = IOUtil.loadXML(SAMLServletAdapterTest.class.getResourceAsStream("/adapter-test/keycloak-saml/sp-metadata.xml")); - modifyDocElementAttribute(doc, "SingleLogoutService", "Location", "8080", System.getProperty("app.server.http.port", null)); - modifyDocElementAttribute(doc, "AssertionConsumerService", "Location", "8080", System.getProperty("app.server.http.port", null)); + IOUtil.modifyDocElementAttribute(doc, "SingleLogoutService", "Location", "8080", System.getProperty("app.server.http.port", null)); + IOUtil.modifyDocElementAttribute(doc, "AssertionConsumerService", "Location", "8080", System.getProperty("app.server.http.port", null)); ClientRepresentation clientRep = testRealmResource().convertClientDescription(IOUtil.documentToString(doc)); @@ -687,7 +694,7 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { clientRep.setAdminUrl(appServerUrl + "sales-metadata/saml"); Response response = testRealmResource().clients().create(clientRep); - assertEquals(201, response.getStatus()); + Assert.assertEquals(201, response.getStatus()); response.close(); testSuccessfulAndUnauthorizedLogin(salesMetadataServletPage, testRealmSAMLPostLoginPage); @@ -746,8 +753,8 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { .processSamlResponse(Binding.POST).build() .execute(r -> { - assertThat(r, statusCodeIsHC(Response.Status.OK)); - assertThat(r, bodyHC(containsString("urn:oasis:names:tc:SAML:2.0:status:RequestDenied"))); // TODO: revisit - should the HTTP status be 403 too? + Assert.assertThat(r, statusCodeIsHC(Response.Status.OK)); + Assert.assertThat(r, bodyHC(containsString("urn:oasis:names:tc:SAML:2.0:status:RequestDenied"))); // TODO: revisit - should the HTTP status be 403 too? }); } finally { salesPostEncServletPage.logout(); @@ -768,8 +775,8 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { .processSamlResponse(Binding.POST).build() .execute(r -> { - assertThat(r, statusCodeIsHC(Response.Status.OK)); - assertThat(r, bodyHC(containsString("urn:oasis:names:tc:SAML:2.0:status:RequestDenied"))); // TODO: revisit - should the HTTP status be 403 too? + Assert.assertThat(r, statusCodeIsHC(Response.Status.OK)); + Assert.assertThat(r, bodyHC(containsString("urn:oasis:names:tc:SAML:2.0:status:RequestDenied"))); // TODO: revisit - should the HTTP status be 403 too? }); } finally { salesPostServletPage.logout(); @@ -825,8 +832,8 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { UserRepresentation storedUser = testRealmResource().users().get(userId).toRepresentation(); - assertThat(storedUser, notNullValue()); - assertThat("Database seems to be unable to store Unicode for username. Refer to KEYCLOAK-3439 and related issues.", storedUser.getUsername(), equalToIgnoringCase(username)); + Assert.assertThat(storedUser, notNullValue()); + Assert.assertThat("Database seems to be unable to store Unicode for username. Refer to KEYCLOAK-3439 and related issues.", storedUser.getUsername(), equalToIgnoringCase(username)); assertSuccessfulLogin(salesPostSigServletPage, user, testRealmSAMLPostLoginPage, "principal=" + storedUser.getUsername()); @@ -849,8 +856,8 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { UserRepresentation storedUser = testRealmResource().users().get(userId).toRepresentation(); - assertThat(storedUser, notNullValue()); - assertThat("Database seems to be unable to store Unicode for username. Refer to KEYCLOAK-3439 and related issues.", storedUser.getUsername(), equalToIgnoringCase(username)); + Assert.assertThat(storedUser, notNullValue()); + Assert.assertThat("Database seems to be unable to store Unicode for username. Refer to KEYCLOAK-3439 and related issues.", storedUser.getUsername(), equalToIgnoringCase(username)); assertSuccessfulLogin(employeeSigServletPage, user, testRealmSAMLRedirectLoginPage, "principal=" + storedUser.getUsername()); @@ -874,14 +881,14 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { .login().user(user).build() .processSamlResponse(Binding.POST) .transformString(s -> { - assertThat(s, org.hamcrest.Matchers.containsString(">bburke@redhat.com.additional.domain<")); + Assert.assertThat(s, org.hamcrest.Matchers.containsString(">bburke@redhat.com.additional.domain<")); s = s.replaceAll("bburke@redhat.com.additional.domain", "bburke@redhat.com.additional.domain"); return s; }) .build() .executeAndTransform(resp -> EntityUtils.toString(resp.getEntity())); - assertThat(resultPage, org.hamcrest.Matchers.containsString("principal=bburke@redhat.com.additional.domain")); + Assert.assertThat(resultPage, org.hamcrest.Matchers.containsString("principal=bburke@redhat.com.additional.domain")); } @Test @@ -895,14 +902,14 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { .login().user(user).build() .processSamlResponse(Binding.POST) .transformString(s -> { - assertThat(s, org.hamcrest.Matchers.containsString(">bburke@redhat.com.additional.domain<")); + Assert.assertThat(s, org.hamcrest.Matchers.containsString(">bburke@redhat.com.additional.domain<")); s = s.replaceAll("bburke@redhat.com.additional.domain", "bburke@redhat.com"); return s; }) .build() .executeAndTransform(resp -> EntityUtils.toString(resp.getEntity())); - assertThat(resultPage, org.hamcrest.Matchers.containsString("INVALID_SIGNATURE")); + Assert.assertThat(resultPage, org.hamcrest.Matchers.containsString("INVALID_SIGNATURE")); } @Test @@ -959,7 +966,7 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { waitUntilElement(By.xpath("//body")).text().not().contains("bburke"); //Different 403 status page on EAP and Wildfly - assertTrue(driver.getPageSource().contains("Forbidden") + Assert.assertTrue(driver.getPageSource().contains("Forbidden") || driver.getPageSource().contains(FORBIDDEN_TEXT) || driver.getPageSource().contains(WEBSPHERE_FORBIDDEN_TEXT)); // WebSphere @@ -1007,7 +1014,7 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { samlidpInitiatedLoginPage.form().login(bburkeUser); assertCurrentUrlStartsWith(salesPost2ServletPage); - assertThat(driver.getCurrentUrl(), endsWith("/foo")); + Assert.assertThat(driver.getCurrentUrl(), endsWith("/foo")); waitUntilElement(By.xpath("//body")).text().contains("principal=bburke"); salesPost2ServletPage.logout(); checkLoggedOut(salesPost2ServletPage, testRealmSAMLPostLoginPage); @@ -1025,7 +1032,7 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { testRealmSAMLPostLoginPage.form().login("bburke", "password"); waitUntilElement(By.xpath("//body")).text().contains("Error info: SamlAuthenticationError [reason=INVALID_SIGNATURE"); - assertEquals(driver.getCurrentUrl(), badAssertionSalesPostSigPage + "/saml"); + Assert.assertEquals(driver.getCurrentUrl(), badAssertionSalesPostSigPage + "/saml"); } @Test @@ -1035,7 +1042,7 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { testRealmSAMLPostLoginPage.form().login("bburke", "password"); waitUntilElement(By.xpath("//body")).text().contains("Error info: SamlAuthenticationError [reason=INVALID_SIGNATURE"); - assertEquals(driver.getCurrentUrl(), missingAssertionSigPage + "/saml"); + Assert.assertEquals(driver.getCurrentUrl(), missingAssertionSigPage + "/saml"); } @Test @@ -1049,7 +1056,7 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { new SamlClientBuilder() .addStep((client, currentURI, currentResponse, context) -> Binding.REDIRECT.createSamlUnsignedResponse(URI.create(employeeSigServletPage.toString() + "/saml"), null, document)) - .execute(closeableHttpResponse -> assertThat(closeableHttpResponse, bodyHC(containsString("INVALID_SIGNATURE")))); + .execute(closeableHttpResponse -> Assert.assertThat(closeableHttpResponse, bodyHC(containsString("INVALID_SIGNATURE")))); } @Test @@ -1063,7 +1070,7 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { new SamlClientBuilder() .addStep((client, currentURI, currentResponse, context) -> Binding.REDIRECT.createSamlSignedResponse(URI.create(employeeSigServletPage.toString() + "/saml"), null, document, REALM_PRIVATE_KEY, REALM_PUBLIC_KEY)) - .execute(closeableHttpResponse -> assertThat(closeableHttpResponse, bodyHC(containsString("ERROR_STATUS")))); + .execute(closeableHttpResponse -> Assert.assertThat(closeableHttpResponse, bodyHC(containsString("ERROR_STATUS")))); } @Test @@ -1076,8 +1083,8 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { assertCurrentUrlStartsWith(employeeServletPage); waitForPageToLoad(); String pageSource = driver.getPageSource(); - assertThat(pageSource, containsString("Relay state: " + SamlSPFacade.RELAY_STATE)); - assertThat(pageSource, not(containsString("SAML response: null"))); + Assert.assertThat(pageSource, containsString("Relay state: " + SamlSPFacade.RELAY_STATE)); + Assert.assertThat(pageSource, not(containsString("SAML response: null"))); } @Test @@ -1225,8 +1232,8 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { .navigateTo(employee2ServletPage.toString() + "/getAttributes") .execute(r -> { - assertThat(r, statusCodeIsHC(Response.Status.OK)); - assertThat(r, bodyHC(containsString("boolean-attribute: true"))); + Assert.assertThat(r, statusCodeIsHC(Response.Status.OK)); + Assert.assertThat(r, bodyHC(containsString("boolean-attribute: true"))); }); } @@ -1243,7 +1250,7 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { XPathExpression expr = xpath.compile("//*[local-name()='NameID']"); NodeList nodeList = (NodeList) expr.evaluate(responseDoc, XPathConstants.NODESET); - assertThat(nodeList.getLength(), is(1)); + Assert.assertThat(nodeList.getLength(), is(1)); final Node nameIdNode = nodeList.item(0); nameIdNode.getParentNode().removeChild(nameIdNode); @@ -1255,8 +1262,8 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { .navigateTo(employee2ServletPage.toString()) .execute(r -> { - assertThat(r, statusCodeIsHC(Response.Status.OK)); - assertThat(r, bodyHC(allOf(containsString("principal="), not(containsString("500"))))); + Assert.assertThat(r, statusCodeIsHC(Response.Status.OK)); + Assert.assertThat(r, bodyHC(allOf(containsString("principal="), not(containsString("500"))))); }); } @@ -1282,13 +1289,13 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { HttpUriRequest post = SamlClient.Binding.POST.createSamlUnsignedResponse(getAppServerSamlEndpoint(salesPostSigEmailServletPage), null, responseDoc); response = client.execute(post, context); System.out.println(EntityUtils.toString(response.getEntity())); - assertThat(response, statusCodeIsHC(Response.Status.FOUND)); + Assert.assertThat(response, statusCodeIsHC(Response.Status.FOUND)); response.close(); HttpGet get = new HttpGet(salesPostSigEmailServletPage.toString()); response = client.execute(get); - assertThat(response, statusCodeIsHC(Response.Status.OK)); - assertThat(response, bodyHC(containsString("principal=bburke"))); + Assert.assertThat(response, statusCodeIsHC(Response.Status.OK)); + Assert.assertThat(response, bodyHC(containsString("principal=bburke"))); } catch (Exception ex) { throw new RuntimeException(ex); } finally { @@ -1304,8 +1311,8 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { public void testDifferentCookieName() { assertSuccessfulLogin(differentCookieNameServletPage, bburkeUser, testRealmSAMLPostLoginPage, "principal=bburke"); - assertThat(driver.manage().getCookieNamed("DIFFERENT_SESSION_ID"), notNullValue()); - assertThat(driver.manage().getCookieNamed("JSESSIONID"), nullValue()); + Assert.assertThat(driver.manage().getCookieNamed("DIFFERENT_SESSION_ID"), notNullValue()); + Assert.assertThat(driver.manage().getCookieNamed("JSESSIONID"), nullValue()); salesPost2ServletPage.logout(); checkLoggedOut(differentCookieNameServletPage, testRealmSAMLPostLoginPage); @@ -1374,11 +1381,11 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { SOAPHeaderElement ecpRequestHeader = it.next(); NodeList idpList = ecpRequestHeader.getElementsByTagNameNS("urn:oasis:names:tc:SAML:2.0:protocol", "IDPList"); - assertThat("No IDPList returned from Service Provider", idpList.getLength(), is(1)); + Assert.assertThat("No IDPList returned from Service Provider", idpList.getLength(), is(1)); NodeList idpEntries = idpList.item(0).getChildNodes(); - assertThat("No IDPEntry returned from Service Provider", idpEntries.getLength(), is(1)); + Assert.assertThat("No IDPEntry returned from Service Provider", idpEntries.getLength(), is(1)); String singleSignOnService = null; @@ -1390,7 +1397,7 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { singleSignOnService = location.getNodeValue(); } - assertThat("Could not obtain SSO Service URL", singleSignOnService, notNullValue()); + Assert.assertThat("Could not obtain SSO Service URL", singleSignOnService, notNullValue()); Document authenticationRequest = authnRequestMessage.getSOAPBody().getFirstChild().getOwnerDocument(); String username = "pedroigor"; @@ -1402,7 +1409,7 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { .header(HttpHeaders.AUTHORIZATION, authHeader) .post(Entity.entity(DocumentUtil.asString(authenticationRequest), "text/xml")); - assertThat(authenticationResponse.getStatus(), is(OK.getStatusCode())); + Assert.assertThat(authenticationResponse.getStatus(), is(OK.getStatusCode())); SOAPMessage responseMessage = MessageFactory.newInstance().createMessage(null, new ByteArrayInputStream(authenticationResponse.readEntity(byte[].class))); @@ -1412,19 +1419,19 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { NodeList ecpResponse = responseMessageHeaders.getElementsByTagNameNS(JBossSAMLURIConstants.ECP_PROFILE.get(), JBossSAMLConstants.RESPONSE__ECP.get()); - assertThat("No ECP Response", ecpResponse.getLength(), is(1)); + Assert.assertThat("No ECP Response", ecpResponse.getLength(), is(1)); Node samlResponse = responseMessage.getSOAPBody().getFirstChild(); - assertThat(samlResponse, notNullValue()); + Assert.assertThat(samlResponse, notNullValue()); ResponseType responseType = (ResponseType) SAMLParser.getInstance().parse(samlResponse); StatusCodeType statusCode = responseType.getStatus().getStatusCode(); - assertThat(statusCode.getValue().toString(), is(JBossSAMLURIConstants.STATUS_SUCCESS.get())); - assertThat(responseType.getDestination(), is(ecpSPPage.toString() + "/")); - assertThat(responseType.getSignature(), notNullValue()); - assertThat(responseType.getAssertions().size(), is(1)); + Assert.assertThat(statusCode.getValue().toString(), is(JBossSAMLURIConstants.STATUS_SUCCESS.get())); + Assert.assertThat(responseType.getDestination(), is(ecpSPPage.toString() + "/")); + Assert.assertThat(responseType.getSignature(), notNullValue()); + Assert.assertThat(responseType.getAssertions().size(), is(1)); SOAPMessage samlResponseRequest = MessageFactory.newInstance().createMessage(); @@ -1446,7 +1453,7 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { } Response resourceResponse = resourceRequest.get(); - assertThat(resourceResponse.readEntity(String.class), containsString("pedroigor")); + Assert.assertThat(resourceResponse.readEntity(String.class), containsString("pedroigor")); } @Test @@ -1465,11 +1472,11 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { SOAPHeaderElement ecpRequestHeader = it.next(); NodeList idpList = ecpRequestHeader.getElementsByTagNameNS("urn:oasis:names:tc:SAML:2.0:protocol", "IDPList"); - assertThat("No IDPList returned from Service Provider", idpList.getLength(), is(1)); + Assert.assertThat("No IDPList returned from Service Provider", idpList.getLength(), is(1)); NodeList idpEntries = idpList.item(0).getChildNodes(); - assertThat("No IDPEntry returned from Service Provider", idpEntries.getLength(), is(1)); + Assert.assertThat("No IDPEntry returned from Service Provider", idpEntries.getLength(), is(1)); String singleSignOnService = null; @@ -1481,7 +1488,7 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { singleSignOnService = location.getNodeValue(); } - assertThat("Could not obtain SSO Service URL", singleSignOnService, notNullValue()); + Assert.assertThat("Could not obtain SSO Service URL", singleSignOnService, notNullValue()); Document authenticationRequest = authnRequestMessage.getSOAPBody().getFirstChild().getOwnerDocument(); String username = "pedroigor"; @@ -1493,17 +1500,17 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { .header(HttpHeaders.AUTHORIZATION, authHeader) .post(Entity.entity(DocumentUtil.asString(authenticationRequest), "application/soap+xml")); - assertThat(authenticationResponse.getStatus(), is(OK.getStatusCode())); + Assert.assertThat(authenticationResponse.getStatus(), is(OK.getStatusCode())); SOAPMessage responseMessage = MessageFactory.newInstance().createMessage(null, new ByteArrayInputStream(authenticationResponse.readEntity(byte[].class))); Node samlResponse = responseMessage.getSOAPBody().getFirstChild(); - assertThat(samlResponse, notNullValue()); + Assert.assertThat(samlResponse, notNullValue()); StatusResponseType responseType = (StatusResponseType) SAMLParser.getInstance().parse(samlResponse); StatusCodeType statusCode = responseType.getStatus().getStatusCode(); - assertThat(statusCode.getStatusCode().getValue().toString(), is(not(JBossSAMLURIConstants.STATUS_SUCCESS.get()))); + Assert.assertThat(statusCode.getStatusCode().getValue().toString(), is(not(JBossSAMLURIConstants.STATUS_SUCCESS.get()))); } public static void printDocument(Source doc, OutputStream out) throws IOException, TransformerException { @@ -1568,7 +1575,7 @@ public class SAMLServletsAdapterTest extends AbstractServletsAdapterTest { waitUntilElement(By.xpath("//body")).is().present(); //Different 403 status page on EAP and Wildfly - assertTrue(driver.getPageSource().contains("Forbidden") + Assert.assertTrue(driver.getPageSource().contains("Forbidden") || driver.getPageSource().contains(FORBIDDEN_TEXT) || driver.getPageSource().contains(WEBSPHERE_FORBIDDEN_TEXT)); // WebSphere } diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/undertow/servlet/UndertowRelaviteUriAdapterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/undertow/servlet/UndertowRelaviteUriAdapterTest.java index 20be835e98..850eb59a9a 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/undertow/servlet/UndertowRelaviteUriAdapterTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/undertow/servlet/UndertowRelaviteUriAdapterTest.java @@ -41,7 +41,7 @@ import org.keycloak.testsuite.arquillian.annotation.AppServerContainer; import static org.keycloak.testsuite.arquillian.AuthServerTestEnricher.AUTH_SERVER_CONTAINER_DEFAULT; import static org.keycloak.testsuite.auth.page.AuthRealm.DEMO; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; +import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm; import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlEquals; import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWithLoginUrlOf; diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/client/authorization/ClaimInformationPointProviderTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/client/authorization/ClaimInformationPointProviderTest.java index 87c4382f7b..4d87e69dbc 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/client/authorization/ClaimInformationPointProviderTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/client/authorization/ClaimInformationPointProviderTest.java @@ -19,7 +19,7 @@ package org.keycloak.testsuite.admin.client.authorization; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; +import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm; import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/client/authorization/EnforcerConfigTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/client/authorization/EnforcerConfigTest.java index 327b733e54..76e4e0586b 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/client/authorization/EnforcerConfigTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/client/authorization/EnforcerConfigTest.java @@ -33,7 +33,7 @@ import java.util.Map; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; +import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm; /** * @author Pedro Igor diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/group/AbstractGroupTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/group/AbstractGroupTest.java index 07fcf5f530..94184d270f 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/group/AbstractGroupTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/group/AbstractGroupTest.java @@ -37,7 +37,7 @@ import org.keycloak.testsuite.util.OAuthClient.AccessTokenResponse; import java.security.PublicKey; import java.util.List; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; +import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm; /** * @author Marko Strukelj diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/KcSamlIdPInitiatedSsoTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/KcSamlIdPInitiatedSsoTest.java index 1ebdd0fa28..80c8ffd7fa 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/KcSamlIdPInitiatedSsoTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/KcSamlIdPInitiatedSsoTest.java @@ -16,7 +16,7 @@ import org.keycloak.testsuite.Assert; import org.keycloak.testsuite.pages.LoginPage; import org.keycloak.testsuite.pages.PageUtils; import org.keycloak.testsuite.pages.UpdateAccountInformationPage; -import org.keycloak.testsuite.util.IOUtil; +import org.keycloak.testsuite.utils.io.IOUtil; import org.keycloak.testsuite.util.Matchers; import org.keycloak.testsuite.util.SamlClient.Binding; diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/migration/JsonFileImport198MigrationTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/migration/JsonFileImport198MigrationTest.java index 11f6f70170..a507e2b978 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/migration/JsonFileImport198MigrationTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/migration/JsonFileImport198MigrationTest.java @@ -24,7 +24,7 @@ import org.keycloak.exportimport.util.ImportUtils; import org.keycloak.representations.idm.RealmRepresentation; import org.keycloak.testsuite.arquillian.DeploymentTargetModifier; import org.keycloak.testsuite.runonserver.RunOnServerDeployment; -import org.keycloak.testsuite.util.IOUtil; +import org.keycloak.testsuite.utils.io.IOUtil; import org.keycloak.util.JsonSerialization; import java.io.IOException; diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/migration/JsonFileImport255MigrationTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/migration/JsonFileImport255MigrationTest.java index a57fc85b85..ed2f628a74 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/migration/JsonFileImport255MigrationTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/migration/JsonFileImport255MigrationTest.java @@ -24,7 +24,7 @@ import org.keycloak.exportimport.util.ImportUtils; import org.keycloak.representations.idm.RealmRepresentation; import org.keycloak.testsuite.arquillian.DeploymentTargetModifier; import org.keycloak.testsuite.runonserver.RunOnServerDeployment; -import org.keycloak.testsuite.util.IOUtil; +import org.keycloak.testsuite.utils.io.IOUtil; import org.keycloak.testsuite.util.WaitUtils; import org.keycloak.util.JsonSerialization; diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/saml/AbstractSamlTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/saml/AbstractSamlTest.java index 7d12450bd1..46c29d80e0 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/saml/AbstractSamlTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/saml/AbstractSamlTest.java @@ -12,7 +12,7 @@ import javax.ws.rs.core.UriBuilderException; import java.net.URI; import java.util.List; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; +import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm; /** * @author mhajas diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/saml/BasicSamlTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/saml/BasicSamlTest.java index 0eb56d02b2..d2618383fe 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/saml/BasicSamlTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/saml/BasicSamlTest.java @@ -35,8 +35,8 @@ import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.Matchers.containsString; import static org.junit.Assert.assertThat; import static org.keycloak.testsuite.saml.AbstractSamlTest.REALM_NAME; -import static org.keycloak.testsuite.util.IOUtil.documentToString; -import static org.keycloak.testsuite.util.IOUtil.setDocElementAttributeValue; +import static org.keycloak.testsuite.utils.io.IOUtil.documentToString; +import static org.keycloak.testsuite.utils.io.IOUtil.setDocElementAttributeValue; import static org.keycloak.testsuite.util.Matchers.statusCodeIsHC; /** diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/saml/ConcurrentAuthnRequestTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/saml/ConcurrentAuthnRequestTest.java index 13370acd4d..0494752d71 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/saml/ConcurrentAuthnRequestTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/saml/ConcurrentAuthnRequestTest.java @@ -21,8 +21,9 @@ import org.keycloak.representations.idm.RealmRepresentation; import org.keycloak.representations.idm.UserRepresentation; import org.keycloak.saml.processing.api.saml.v2.request.SAML2Request; import org.keycloak.testsuite.util.SamlClient; - import org.keycloak.testsuite.util.saml.LoginBuilder; +import org.keycloak.testsuite.utils.io.IOUtil; + import java.io.IOException; import java.net.URI; import java.util.Collection; @@ -43,7 +44,6 @@ import org.junit.Test; import org.w3c.dom.Document; import static org.keycloak.testsuite.util.SamlClient.*; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; /** * @@ -108,9 +108,10 @@ public class ConcurrentAuthnRequestTest extends AbstractSamlTest { @Override public void addTestRealms(List testRealms) { - testRealms.add(loadRealm("/adapter-test/keycloak-saml/testsaml.json")); + testRealms.add(IOUtil.loadRealm("/adapter-test/keycloak-saml/testsaml.json")); } + @Override public AuthnRequestType createLoginRequestDocument(String issuer, String assertionConsumerURL, String realmName) { return SamlClient.createLoginRequestDocument(issuer, assertionConsumerURL, getAuthServerSamlEndpoint(realmName)); } diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/saml/SamlConsentTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/saml/SamlConsentTest.java index bd30eea540..c91d19dcb9 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/saml/SamlConsentTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/saml/SamlConsentTest.java @@ -8,7 +8,7 @@ import org.keycloak.saml.common.exceptions.ParsingException; import org.keycloak.saml.common.exceptions.ProcessingException; import org.keycloak.saml.processing.core.saml.v2.common.SAMLDocumentHolder; import org.keycloak.testsuite.util.ClientBuilder; -import org.keycloak.testsuite.util.IOUtil; +import org.keycloak.testsuite.utils.io.IOUtil; import org.keycloak.testsuite.util.SamlClient.Binding; import org.keycloak.testsuite.util.SamlClientBuilder; @@ -17,7 +17,6 @@ import java.util.List; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.not; import static org.junit.Assert.assertThat; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; /** * @author mhajas @@ -26,7 +25,7 @@ public class SamlConsentTest extends AbstractSamlTest { @Override public void addTestRealms(List testRealms) { - testRealms.add(loadRealm("/adapter-test/keycloak-saml/testsaml.json")); + testRealms.add(IOUtil.loadRealm("/adapter-test/keycloak-saml/testsaml.json")); } @Test diff --git a/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/adapter/RemoteSAMLAdapterTest.java b/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/adapter/RemoteSAMLAdapterTest.java index 438ddb1fa8..588ad39739 100644 --- a/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/adapter/RemoteSAMLAdapterTest.java +++ b/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/adapter/RemoteSAMLAdapterTest.java @@ -1,12 +1,12 @@ package org.keycloak.testsuite.adapter; -import org.keycloak.testsuite.adapter.servlet.SAMLServletsAdapterTest; +import org.keycloak.testsuite.adapter.servlet.SAMLServletAdapterTest; import org.keycloak.testsuite.arquillian.annotation.AppServerContainer; /** * @author mhajas */ @AppServerContainer("app-server-remote") -public class RemoteSAMLAdapterTest extends SAMLServletsAdapterTest { +public class RemoteSAMLAdapterTest extends SAMLServletAdapterTest { } diff --git a/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/performance/PerformanceMeasurement.java b/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/performance/PerformanceMeasurement.java index 2cac1176bb..0cc0eb0996 100644 --- a/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/performance/PerformanceMeasurement.java +++ b/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/performance/PerformanceMeasurement.java @@ -16,7 +16,7 @@ import java.util.Date; import java.util.List; import static org.keycloak.testsuite.performance.PerformanceTest.LOG; -import static org.keycloak.testsuite.util.IOUtil.PROJECT_BUILD_DIRECTORY; +import static org.keycloak.testsuite.utils.io.IOUtil.PROJECT_BUILD_DIRECTORY; /** * diff --git a/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/performance/htmlunit/HtmlUnitLoginLogoutPerfTest.java b/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/performance/htmlunit/HtmlUnitLoginLogoutPerfTest.java index 22726d8afa..b4ba6a36c4 100644 --- a/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/performance/htmlunit/HtmlUnitLoginLogoutPerfTest.java +++ b/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/performance/htmlunit/HtmlUnitLoginLogoutPerfTest.java @@ -27,7 +27,7 @@ import static org.keycloak.testsuite.performance.LoginLogoutTestParameters.LOGIN import static org.keycloak.testsuite.performance.LoginLogoutTestParameters.LOGOUT_REQUEST_TIME; import static org.keycloak.testsuite.performance.LoginLogoutTestParameters.LOGOUT_VERIFY_REQUEST_TIME; import static org.keycloak.testsuite.performance.LoginLogoutTestParameters.PASSWORD_HASH_ITERATIONS; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; +import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm; /** * diff --git a/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/performance/httpclient/HttpClientLoginLogoutPerfTest.java b/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/performance/httpclient/HttpClientLoginLogoutPerfTest.java index c665f798c3..40a188f40a 100644 --- a/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/performance/httpclient/HttpClientLoginLogoutPerfTest.java +++ b/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/performance/httpclient/HttpClientLoginLogoutPerfTest.java @@ -42,7 +42,7 @@ import static org.keycloak.testsuite.performance.LoginLogoutTestParameters.LOGIN import static org.keycloak.testsuite.performance.LoginLogoutTestParameters.LOGOUT_REQUEST_TIME; import static org.keycloak.testsuite.performance.LoginLogoutTestParameters.LOGOUT_VERIFY_REQUEST_TIME; import static org.keycloak.testsuite.performance.LoginLogoutTestParameters.PASSWORD_HASH_ITERATIONS; -import static org.keycloak.testsuite.util.IOUtil.loadRealm; +import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm; /** * diff --git a/testsuite/integration-arquillian/servers/util/pom.xml b/testsuite/integration-arquillian/util/pom.xml similarity index 68% rename from testsuite/integration-arquillian/servers/util/pom.xml rename to testsuite/integration-arquillian/util/pom.xml index 91e9494880..3f53425b2a 100644 --- a/testsuite/integration-arquillian/servers/util/pom.xml +++ b/testsuite/integration-arquillian/util/pom.xml @@ -20,19 +20,31 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> org.keycloak.testsuite - integration-arquillian-servers + integration-arquillian 4.1.0.Final-SNAPSHOT 4.0.0 - integration-arquillian-servers-util + integration-arquillian-util jar - Test Servers Util + Test Util org.jboss.arquillian.container undertow-embedded + + org.keycloak + keycloak-core + + + org.keycloak + keycloak-servlet-filter-adapter + + + org.jboss.shrinkwrap.resolver + shrinkwrap-resolver-api-maven + diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/annotation/UseServletFilter.java b/testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/annotation/UseServletFilter.java similarity index 91% rename from testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/annotation/UseServletFilter.java rename to testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/annotation/UseServletFilter.java index 526340afd5..82cfca2d83 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/annotation/UseServletFilter.java +++ b/testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/annotation/UseServletFilter.java @@ -1,4 +1,4 @@ -package org.keycloak.testsuite.arquillian.annotation; +package org.keycloak.testsuite.utils.annotation; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/arquillian/DeploymentArchiveProcessorUtils.java b/testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/arquillian/DeploymentArchiveProcessorUtils.java new file mode 100644 index 0000000000..c5dece7818 --- /dev/null +++ b/testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/arquillian/DeploymentArchiveProcessorUtils.java @@ -0,0 +1,201 @@ +/* + * Copyright 2018 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.keycloak.testsuite.utils.arquillian; + +import java.io.File; +import java.io.IOException; +import org.jboss.arquillian.test.spi.TestClass; +import org.jboss.logging.Logger; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.keycloak.adapters.servlet.KeycloakOIDCFilter; +import org.keycloak.representations.adapters.config.AdapterConfig; +import org.keycloak.testsuite.utils.annotation.UseServletFilter; +import org.keycloak.testsuite.utils.io.IOUtil; +import org.keycloak.util.JsonSerialization; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +/** + * + * @author Vlasta Ramik + */ +public class DeploymentArchiveProcessorUtils { + + private static final Logger log = Logger.getLogger(DeploymentArchiveProcessorUtils.class); + + private static final boolean AUTH_SERVER_SSL_REQUIRED = Boolean.parseBoolean(System.getProperty("auth.server.ssl.required")); + private static final boolean APP_SERVER_SSL_REQUIRED = Boolean.parseBoolean(System.getProperty("app.server.ssl.required")); + + public static final String WEBXML_PATH = "/WEB-INF/web.xml"; + public static final String ADAPTER_CONFIG_PATH = "/WEB-INF/keycloak.json"; + public static final String ADAPTER_CONFIG_PATH_TENANT1 = "/WEB-INF/classes/tenant1-keycloak.json"; + public static final String ADAPTER_CONFIG_PATH_TENANT2 = "/WEB-INF/classes/tenant2-keycloak.json"; + public static final String ADAPTER_CONFIG_PATH_JS = "/keycloak.json"; + public static final String SAML_ADAPTER_CONFIG_PATH = "/WEB-INF/keycloak-saml.xml"; + public static final String JBOSS_DEPLOYMENT_XML_PATH = "/WEB-INF/jboss-deployment-structure.xml"; + + /** + * @return true iff archive's name equals run-on-server-classes.war + */ + public static boolean checkRunOnServerDeployment(Archive archive) { + return archive.getName().equals("run-on-server-classes.war"); + } + + public static void modifyWebXMLForServletFilter(Archive archive, TestClass testClass) { + Document webXmlDoc; + try { + webXmlDoc = IOUtil.loadXML( + archive.get(WEBXML_PATH).getAsset().openStream()); + } catch (Exception ex) { + throw new RuntimeException("Error when processing " + archive.getName(), ex); + } + + //We need to add filter declaration to web.xml + log.info("Adding filter to " + testClass.getAnnotation(UseServletFilter.class).filterClass() + + " with mapping " + testClass.getAnnotation(UseServletFilter.class).filterPattern() + + " for " + archive.getName()); + + Element filter = webXmlDoc.createElement("filter"); + Element filterName = webXmlDoc.createElement("filter-name"); + Element filterClass = webXmlDoc.createElement("filter-class"); + + filterName.setTextContent(testClass.getAnnotation(UseServletFilter.class).filterName()); + filterClass.setTextContent(testClass.getAnnotation(UseServletFilter.class).filterClass()); + + filter.appendChild(filterName); + filter.appendChild(filterClass); + IOUtil.appendChildInDocument(webXmlDoc, "web-app", filter); + + filter.appendChild(filterName); + filter.appendChild(filterClass); + + // Limitation that all deployments of annotated class use same skipPattern. Refactor if + // something more flexible is needed (would require more tricky web.xml parsing though...) + String skipPattern = testClass.getAnnotation(UseServletFilter.class).skipPattern(); + if (skipPattern != null && !skipPattern.isEmpty()) { + Element initParam = webXmlDoc.createElement("init-param"); + + Element paramName = webXmlDoc.createElement("param-name"); + paramName.setTextContent(KeycloakOIDCFilter.SKIP_PATTERN_PARAM); + + Element paramValue = webXmlDoc.createElement("param-value"); + paramValue.setTextContent(skipPattern); + + initParam.appendChild(paramName); + initParam.appendChild(paramValue); + + filter.appendChild(initParam); + } + + IOUtil.appendChildInDocument(webXmlDoc, "web-app", filter); + + Element filterMapping = webXmlDoc.createElement("filter-mapping"); + + Element urlPattern = webXmlDoc.createElement("url-pattern"); + + filterName = webXmlDoc.createElement("filter-name"); + + filterName.setTextContent(testClass.getAnnotation(UseServletFilter.class).filterName()); + urlPattern.setTextContent(IOUtil.getElementTextContent(webXmlDoc, "web-app/security-constraint/web-resource-collection/url-pattern")); + + filterMapping.appendChild(filterName); + filterMapping.appendChild(urlPattern); + + if (!testClass.getAnnotation(UseServletFilter.class).dispatcherType().isEmpty()) { + Element dispatcher = webXmlDoc.createElement("dispatcher"); + dispatcher.setTextContent(testClass.getAnnotation(UseServletFilter.class).dispatcherType()); + filterMapping.appendChild(dispatcher); + } + IOUtil.appendChildInDocument(webXmlDoc, "web-app", filterMapping); + + //finally we need to remove all keycloak related configuration from web.xml + IOUtil.removeElementsFromDoc(webXmlDoc, "web-app", "security-constraint"); + IOUtil.removeElementsFromDoc(webXmlDoc, "web-app", "login-config"); + IOUtil.removeElementsFromDoc(webXmlDoc, "web-app", "security-role"); + + archive.add(new StringAsset((IOUtil.documentToString(webXmlDoc))), WEBXML_PATH); + } + + public static void addFilterDependencies(Archive archive, TestClass testClass) { + log.info("Adding filter dependencies to " + archive.getName()); + + String dependency = testClass.getAnnotation(UseServletFilter.class).filterDependency(); + ((WebArchive) archive).addAsLibraries(KeycloakDependenciesResolver.resolveDependencies((dependency + ":" + System.getProperty("project.version")))); + + Document jbossXmlDoc = IOUtil.loadXML(archive.get(JBOSS_DEPLOYMENT_XML_PATH).getAsset().openStream()); + IOUtil.removeNodeByAttributeValue(jbossXmlDoc, "dependencies", "module", "name", "org.keycloak.keycloak-saml-core"); + IOUtil.removeNodeByAttributeValue(jbossXmlDoc, "dependencies", "module", "name", "org.keycloak.keycloak-adapter-spi"); + + archive.add(new StringAsset((IOUtil.documentToString(jbossXmlDoc))), JBOSS_DEPLOYMENT_XML_PATH); + } + + public static void modifyOIDCAdapterConfig(Archive archive, String adapterConfigPath) { + try { + AdapterConfig adapterConfig = IOUtil.loadJson(archive.get(adapterConfigPath) + .getAsset().openStream(), AdapterConfig.class); + + adapterConfig.setAuthServerUrl(getAuthServerUrl()); + + if (APP_SERVER_SSL_REQUIRED) { + adapterConfig.setSslRequired("all"); + } + + archive.add(new StringAsset(JsonSerialization.writeValueAsPrettyString(adapterConfig)), + adapterConfigPath); + } catch (IOException ex) { + log.error("Cannot serialize adapter config to JSON.", ex); + } + } + + public static void modifySAMLAdapterConfig(Archive archive) { + Document doc = IOUtil.loadXML(archive.get(SAML_ADAPTER_CONFIG_PATH).getAsset().openStream()); + + if (AUTH_SERVER_SSL_REQUIRED) { + IOUtil.modifyDocElementAttribute(doc, "SingleSignOnService", "bindingUrl", "8080", System.getProperty("auth.server.https.port")); + IOUtil.modifyDocElementAttribute(doc, "SingleSignOnService", "bindingUrl", "http", "https"); + IOUtil.modifyDocElementAttribute(doc, "SingleSignOnService", "assertionConsumerServiceUrl", "8081", System.getProperty("app.server.https.port")); + IOUtil.modifyDocElementAttribute(doc, "SingleSignOnService", "assertionConsumerServiceUrl", "http", "https"); + IOUtil.modifyDocElementAttribute(doc, "SingleLogoutService", "postBindingUrl", "8080", System.getProperty("auth.server.https.port")); + IOUtil.modifyDocElementAttribute(doc, "SingleLogoutService", "postBindingUrl", "http", "https"); + IOUtil.modifyDocElementAttribute(doc, "SingleLogoutService", "redirectBindingUrl", "8080", System.getProperty("auth.server.https.port")); + IOUtil.modifyDocElementAttribute(doc, "SingleLogoutService", "redirectBindingUrl", "http", "https"); + IOUtil.modifyDocElementAttribute(doc, "SP", "logoutPage", "8081", System.getProperty("app.server.https.port")); + IOUtil.modifyDocElementAttribute(doc, "SP", "logoutPage", "http", "https"); + } else { + IOUtil.modifyDocElementAttribute(doc, "SingleSignOnService", "bindingUrl", "8080", System.getProperty("auth.server.http.port")); + IOUtil.modifyDocElementAttribute(doc, "SingleSignOnService", "assertionConsumerServiceUrl", "8081", System.getProperty("app.server.http.port")); + IOUtil.modifyDocElementAttribute(doc, "SingleLogoutService", "postBindingUrl", "8080", System.getProperty("auth.server.http.port")); + IOUtil.modifyDocElementAttribute(doc, "SingleLogoutService", "redirectBindingUrl", "8080", System.getProperty("auth.server.http.port")); + IOUtil.modifyDocElementAttribute(doc, "SP", "logoutPage", "8081", System.getProperty("app.server.http.port")); + } + + archive.add(new StringAsset(IOUtil.documentToString(doc)), SAML_ADAPTER_CONFIG_PATH); + + ((WebArchive) archive).addAsResource(new File(DeploymentArchiveProcessorUtils.class.getResource("/keystore/keycloak.truststore").getFile())); + } + + private static String getAuthServerUrl() { + String scheme = AUTH_SERVER_SSL_REQUIRED ? "https" : "http"; + String host = System.getProperty("app.server.host", "localhost"); + String port = AUTH_SERVER_SSL_REQUIRED ? System.getProperty("auth.server.https.port", "8443") : + System.getProperty("auth.server.http.port", "8180"); + + return String.format("%s://%s:%s/auth", scheme, host, port); + } +} diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/KeycloakDependenciesResolver.java b/testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/arquillian/KeycloakDependenciesResolver.java similarity index 61% rename from testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/KeycloakDependenciesResolver.java rename to testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/arquillian/KeycloakDependenciesResolver.java index 2f62c2b29e..a788b7617a 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/KeycloakDependenciesResolver.java +++ b/testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/arquillian/KeycloakDependenciesResolver.java @@ -1,4 +1,20 @@ -package org.keycloak.testsuite.arquillian; +/* + * Copyright 2018 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.keycloak.testsuite.utils.arquillian; import org.jboss.logging.Logger; import org.jboss.shrinkwrap.resolver.api.maven.Maven; @@ -15,7 +31,7 @@ import java.util.Map; */ public class KeycloakDependenciesResolver { - private static Map dependencies = new HashMap<>(); + private static final Map dependencies = new HashMap<>(); protected static final Logger log = org.jboss.logging.Logger.getLogger(KeycloakDependenciesResolver.class); diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/IOUtil.java b/testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/io/IOUtil.java similarity index 99% rename from testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/IOUtil.java rename to testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/io/IOUtil.java index cdabb893cc..d46765e350 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/IOUtil.java +++ b/testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/io/IOUtil.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.keycloak.testsuite.util; +package org.keycloak.testsuite.utils.io; import org.jboss.logging.Logger; import org.keycloak.representations.idm.RealmRepresentation; @@ -69,7 +69,7 @@ public class IOUtil { try { return loadRealm(new FileInputStream(realmFile)); } catch (FileNotFoundException ex) { - throw new IllegalStateException("Test realm file not found: " + realmFile); + throw new IllegalStateException("Test realm file not found: " + realmFile, ex); } } diff --git a/testsuite/integration-arquillian/servers/util/src/main/java/org/keycloak/testsuite/utils/undertow/SimpleWebXmlParser.java b/testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/undertow/SimpleWebXmlParser.java similarity index 100% rename from testsuite/integration-arquillian/servers/util/src/main/java/org/keycloak/testsuite/utils/undertow/SimpleWebXmlParser.java rename to testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/undertow/SimpleWebXmlParser.java diff --git a/testsuite/integration-arquillian/servers/util/src/main/java/org/keycloak/testsuite/utils/undertow/UndertowDeployerHelper.java b/testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/undertow/UndertowDeployerHelper.java similarity index 100% rename from testsuite/integration-arquillian/servers/util/src/main/java/org/keycloak/testsuite/utils/undertow/UndertowDeployerHelper.java rename to testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/undertow/UndertowDeployerHelper.java diff --git a/testsuite/integration-arquillian/servers/util/src/main/java/org/keycloak/testsuite/utils/undertow/UndertowWarClassLoader.java b/testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/undertow/UndertowWarClassLoader.java similarity index 100% rename from testsuite/integration-arquillian/servers/util/src/main/java/org/keycloak/testsuite/utils/undertow/UndertowWarClassLoader.java rename to testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/undertow/UndertowWarClassLoader.java