From b216b9579c80954b8859bac76aee5d5a81ec1ea2 Mon Sep 17 00:00:00 2001 From: Michal Hajas Date: Thu, 27 May 2021 10:31:01 +0200 Subject: [PATCH] KEYCLOAK-18264 Fix SamlLogoutTest with different consumer and provider url --- .../testsuite/broker/AbstractBaseBrokerTest.java | 14 ++++++++++---- .../testsuite/broker/KcSamlLogoutTest.java | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/AbstractBaseBrokerTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/AbstractBaseBrokerTest.java index 0bdf4e5711..1f4fbe40f9 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/AbstractBaseBrokerTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/AbstractBaseBrokerTest.java @@ -71,8 +71,8 @@ import static org.keycloak.testsuite.admin.ApiUtil.resetUserPassword; import static org.keycloak.testsuite.broker.BrokerTestConstants.USER_EMAIL; import static org.keycloak.testsuite.broker.BrokerTestTools.encodeUrl; import static org.keycloak.testsuite.broker.BrokerTestTools.getConsumerRoot; +import static org.keycloak.testsuite.broker.BrokerTestTools.getProviderRoot; import static org.keycloak.testsuite.broker.BrokerTestTools.waitForPage; -import static org.keycloak.testsuite.util.WaitUtils.waitForPageToLoad; /** * No test methods there. Just some useful common functionality @@ -343,10 +343,16 @@ public abstract class AbstractBaseBrokerTest extends AbstractKeycloakTest { protected URI getConsumerSamlEndpoint(String realm) throws IllegalArgumentException, UriBuilderException { - return RealmsResource - .protocolUrl(UriBuilder.fromUri(getConsumerRoot()).path("auth")) - .build(realm, SamlProtocol.LOGIN_PROTOCOL); + return getSamlEndpoint(getConsumerRoot(), realm); } + protected URI getProviderSamlEndpoint(String realm) throws IllegalArgumentException, UriBuilderException { + return getSamlEndpoint(getProviderRoot(), realm); + } + protected URI getSamlEndpoint(String fromUri, String realm) { + return RealmsResource + .protocolUrl(UriBuilder.fromUri(fromUri).path("auth")) + .build(realm, SamlProtocol.LOGIN_PROTOCOL); + } } diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/KcSamlLogoutTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/KcSamlLogoutTest.java index cf23396f08..1800c110e7 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/KcSamlLogoutTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/KcSamlLogoutTest.java @@ -118,7 +118,7 @@ public class KcSamlLogoutTest extends AbstractInitializedBaseBrokerTest { .build() // Login using a different client to the provider realm, should be already logged in - .authnRequest(getConsumerSamlEndpoint(bc.providerRealmName()), PROVIDER_SAML_CLIENT_ID, PROVIDER_SAML_CLIENT_ID + "saml", POST).build() + .authnRequest(getProviderSamlEndpoint(bc.providerRealmName()), PROVIDER_SAML_CLIENT_ID, PROVIDER_SAML_CLIENT_ID + "saml", POST).build() .followOneRedirect() // Process saml response and store reference to nameId and sessionIndex so that we can initiate logout for the session @@ -141,7 +141,7 @@ public class KcSamlLogoutTest extends AbstractInitializedBaseBrokerTest { .build() // Send logout request to provider realm - .logoutRequest(getConsumerSamlEndpoint(bc.providerRealmName()), PROVIDER_SAML_CLIENT_ID, POST) + .logoutRequest(getProviderSamlEndpoint(bc.providerRealmName()), PROVIDER_SAML_CLIENT_ID, POST) .nameId(nameIdRef::get) .sessionIndex(sessionIndexRef::get) .build()