diff --git a/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/main/java/org/keycloak/testsuite/arquillian/remote/RemoteAppServerArquillianExtension.java b/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/main/java/org/keycloak/testsuite/arquillian/remote/RemoteAppServerArquillianExtension.java new file mode 100644 index 0000000000..57674d31f5 --- /dev/null +++ b/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/main/java/org/keycloak/testsuite/arquillian/remote/RemoteAppServerArquillianExtension.java @@ -0,0 +1,30 @@ +/* + * Copyright 2019 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.remote; + +import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor; +import org.jboss.arquillian.core.spi.LoadableExtension; +import org.keycloak.testsuite.arquillian.remote.container.RemoteDeploymentArchiveProcessor; + +public class RemoteAppServerArquillianExtension implements LoadableExtension { + + @Override + public void register(ExtensionBuilder builder) { + builder.service(ApplicationArchiveProcessor.class, RemoteDeploymentArchiveProcessor.class); + } + +} diff --git a/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/main/java/org/keycloak/testsuite/arquillian/remote/container/RemoteDeploymentArchiveProcessor.java b/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/main/java/org/keycloak/testsuite/arquillian/remote/container/RemoteDeploymentArchiveProcessor.java new file mode 100644 index 0000000000..c0ee1ab24b --- /dev/null +++ b/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/main/java/org/keycloak/testsuite/arquillian/remote/container/RemoteDeploymentArchiveProcessor.java @@ -0,0 +1,68 @@ +/* + * Copyright 2019 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.remote.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; + +public class RemoteDeploymentArchiveProcessor implements ApplicationArchiveProcessor { + + private final Logger log = Logger.getLogger(RemoteDeploymentArchiveProcessor.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, DeploymentArchiveProcessorUtils.SAML_ADAPTER_CONFIG_PATH); + modifySAMLAdapterConfig(archive, DeploymentArchiveProcessorUtils.SAML_ADAPTER_CONFIG_PATH_TENANT1); + modifySAMLAdapterConfig(archive, DeploymentArchiveProcessorUtils.SAML_ADAPTER_CONFIG_PATH_TENANT2); + } + + 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, String adapterConfigPath) { + if (!archive.contains(adapterConfigPath)) return; + + log.debug("Modifying adapter config " + adapterConfigPath + " in " + archive.getName()); + DeploymentArchiveProcessorUtils.modifySAMLAdapterConfig(archive, adapterConfigPath); + } +} diff --git a/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension b/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension new file mode 100644 index 0000000000..994970e0d0 --- /dev/null +++ b/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension @@ -0,0 +1 @@ +org.keycloak.testsuite.arquillian.remote.RemoteAppServerArquillianExtension diff --git a/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/adapter/RemoteOIDCAdapterTest.java b/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/adapter/RemoteOIDCAdapterTest.java index 5a78bbc4fa..18c53d30f7 100644 --- a/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/adapter/RemoteOIDCAdapterTest.java +++ b/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/adapter/RemoteOIDCAdapterTest.java @@ -1,5 +1,7 @@ package org.keycloak.testsuite.adapter; +import org.junit.Ignore; +import org.junit.Test; import org.keycloak.testsuite.adapter.servlet.DemoServletsAdapterTest; import org.keycloak.testsuite.arquillian.annotation.AppServerContainer; @@ -10,4 +12,9 @@ import org.keycloak.testsuite.arquillian.annotation.AppServerContainer; @AppServerContainer("app-server-remote") public class RemoteOIDCAdapterTest extends DemoServletsAdapterTest { + @Test + @Ignore + @Override + public void testBasicAuth() { + } } diff --git a/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/adapter/RemoteOfflineServletsAdapterTest.java b/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/adapter/RemoteOfflineServletsAdapterTest.java deleted file mode 100644 index 34eb330d03..0000000000 --- a/testsuite/integration-arquillian/tests/other/adapters/jboss/remote/src/test/java/org/keycloak/testsuite/adapter/RemoteOfflineServletsAdapterTest.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.keycloak.testsuite.adapter; - -import org.keycloak.testsuite.adapter.servlet.OfflineServletsAdapterTest; -import org.keycloak.testsuite.arquillian.annotation.AppServerContainer; - -/** - * @author Bruno Oliveira. - */ -@AppServerContainer("app-server-remote") -public class RemoteOfflineServletsAdapterTest extends OfflineServletsAdapterTest { -}