From 31ed01a6de92df5c64946f42d96c0905541c2024 Mon Sep 17 00:00:00 2001 From: stianst Date: Wed, 16 Oct 2019 10:42:10 +0200 Subject: [PATCH] KEYCLOAK-11754 Prevent AbstractKeycloakTest from inititating backchannel logout on cleanup --- .../org/keycloak/testsuite/AbstractKeycloakTest.java | 8 +++----- .../testsuite/adapter/servlet/MultiTenancyTest.java | 12 ++++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) 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)); + } }