diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AbstractKeycloakTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AbstractKeycloakTest.java index 82d41663a1..e0cb0d81f3 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AbstractKeycloakTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AbstractKeycloakTest.java @@ -77,6 +77,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Scanner; +import java.util.stream.Collectors; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; @@ -210,11 +211,8 @@ public abstract class AbstractKeycloakTest { } } else { log.info("calling all TestCleanup"); - // Logout all users after the test - List realms = testContext.getTestRealmReps(); - for (RealmRepresentation realm : realms) { - adminClient.realm(realm.getRealm()).logoutAll(); - } + // Remove all sessions + testContext.getTestRealmReps().stream().forEach((r)->testingClient.testing().removeUserSessions(r.getRealm())); // Cleanup objects for (TestCleanup cleanup : testContext.getCleanups().values()) { 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 e504e9b739..8cbe8980d7 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 @@ -95,6 +95,8 @@ public class MultiTenancyTest extends AbstractServletsAdapterTest { doTenantRequests("tenant1", false); doTenantRequests("tenant2", true); + + logout("tenant1"); } /** @@ -125,6 +127,8 @@ public class MultiTenancyTest extends AbstractServletsAdapterTest { driver.navigate().to(tenantPage.getTenantRealmUrl("tenant2")); URLAssert.assertCurrentUrlStartsWith(authServerPage.toString()); + + logout("tenant1"); } private void doTenantRequests(String tenant, boolean logout) { @@ -150,4 +154,12 @@ public class MultiTenancyTest extends AbstractServletsAdapterTest { } log.debug("---------------------------------------------------------------------------------------"); } + + private void logout(String tenant) { + String tenantLoginUrl = OIDCLoginProtocolService.authUrl(UriBuilder.fromUri(authServerPage.getAuthRoot())).build(tenant).toString(); + URL tenantUrl = tenantPage.getTenantRealmUrl(tenant); + driver.navigate().to(tenantUrl + "/logout"); + Assert.assertFalse(driver.getPageSource().contains("Username: bburke@redhat.com")); + Assert.assertTrue(driver.getCurrentUrl().startsWith(tenantLoginUrl)); + } }