KEYCLOAK-11754 Prevent AbstractKeycloakTest from inititating backchannel logout on cleanup

This commit is contained in:
stianst 2019-10-16 10:42:10 +02:00 committed by Stian Thorgersen
parent 9cb2f1afdc
commit 31ed01a6de
2 changed files with 15 additions and 5 deletions

View file

@ -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<RealmRepresentation> 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()) {

View file

@ -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));
}
}