From f449b8b454423ac5a9c1706855f990d036c98399 Mon Sep 17 00:00:00 2001 From: vramik Date: Tue, 23 Oct 2018 14:19:26 +0200 Subject: [PATCH] KEYCLOAK-8637 Add support for OIDC multitenancy adapter test for jboss based containers --- .../adapter/servlet/MultiTenantResolver.java | 2 +- .../adapter/AbstractServletsAdapterTest.java | 16 ++++++++++++++-- .../adapter/servlet/MultiTenancyTest.java | 5 +++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/testsuite/integration-arquillian/test-apps/servlets/src/main/java/org/keycloak/testsuite/adapter/servlet/MultiTenantResolver.java b/testsuite/integration-arquillian/test-apps/servlets/src/main/java/org/keycloak/testsuite/adapter/servlet/MultiTenantResolver.java index 643cc61dbc..9bd7873f1e 100644 --- a/testsuite/integration-arquillian/test-apps/servlets/src/main/java/org/keycloak/testsuite/adapter/servlet/MultiTenantResolver.java +++ b/testsuite/integration-arquillian/test-apps/servlets/src/main/java/org/keycloak/testsuite/adapter/servlet/MultiTenantResolver.java @@ -43,7 +43,7 @@ public class MultiTenantResolver implements KeycloakConfigResolver { realm = realm.split("\\?")[0]; } - InputStream is = getClass().getResourceAsStream("/adapter-test/multi-tenant/WEB-INF/" + realm + "-keycloak.json"); + InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("/" + realm + "-keycloak.json"); if (is == null) { throw new IllegalStateException("Not able to find the file /" + realm + "-keycloak.json"); 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 ba694bb14d..79198086b8 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 @@ -41,9 +41,21 @@ public abstract class AbstractServletsAdapterTest extends AbstractAdapterTest { protected static WebArchive servletDeploymentMultiTenant(String name, Class... servletClasses) { WebArchive servletDeployment = servletDeployment(name, null, servletClasses); - return servletDeployment; + + String webInfPath = "/adapter-test/" + name + "/WEB-INF/"; + String config1 = "tenant1-keycloak.json"; + String config2 = "tenant2-keycloak.json"; + + URL config1Url = AbstractServletsAdapterTest.class.getResource(webInfPath + config1); + Assert.assertNotNull("config1Url should be in " + webInfPath + config1, config1Url); + URL config2Url = AbstractServletsAdapterTest.class.getResource(webInfPath + config2); + Assert.assertNotNull("config2Url should be in " + webInfPath + config2, config2Url); + + return servletDeployment + .add(new UrlAsset(config1Url), "/WEB-INF/classes/" + config1) + .add(new UrlAsset(config2Url), "/WEB-INF/classes/" + config2); } - + protected static WebArchive servletDeployment(String name, Class... servletClasses) { return servletDeployment(name, "keycloak.json", servletClasses); } 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 5ec3b350b4..d84ed384e6 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 @@ -42,6 +42,11 @@ import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm; * @author Juraci Paixão Kröhling */ @AppServerContainer(ContainerConstants.APP_SERVER_UNDERTOW) +@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY) +@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY_DEPRECATED) +@AppServerContainer(ContainerConstants.APP_SERVER_EAP) +@AppServerContainer(ContainerConstants.APP_SERVER_EAP6) +@AppServerContainer(ContainerConstants.APP_SERVER_EAP71) public class MultiTenancyTest extends AbstractServletsAdapterTest { @Page