diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/login/SAMLIDPInitiatedLogin.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/login/SAMLIDPInitiatedLogin.java new file mode 100644 index 0000000000..66cf0758c0 --- /dev/null +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/login/SAMLIDPInitiatedLogin.java @@ -0,0 +1,19 @@ +package org.keycloak.testsuite.auth.page.login; + +import javax.ws.rs.core.UriBuilder; + +/** + * @author mhajas + */ +public class SAMLIDPInitiatedLogin extends SAMLRedirectLogin { + + public void setUrlName(String urlName) { + setUriParameter("clientUrlName", urlName); + } + + @Override + public UriBuilder createUriBuilder() { + return super.createUriBuilder().path("clients/{clientUrlName}"); + } +} + diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/AbstractSAMLServletsAdapterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/AbstractSAMLServletsAdapterTest.java index e07b02f213..2d5645a104 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/AbstractSAMLServletsAdapterTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/AbstractSAMLServletsAdapterTest.java @@ -27,6 +27,7 @@ import org.keycloak.representations.idm.RealmRepresentation; import org.keycloak.testsuite.adapter.AbstractServletsAdapterTest; import org.keycloak.testsuite.adapter.page.*; import org.keycloak.testsuite.admin.ApiUtil; +import org.keycloak.testsuite.auth.page.login.SAMLIDPInitiatedLogin; import org.keycloak.testsuite.util.IOUtil; import org.w3c.dom.Document; @@ -81,6 +82,9 @@ public abstract class AbstractSAMLServletsAdapterTest extends AbstractServletsAd @Page private SalesPostSigTransientServlet salesPostSigTransientServletPage; + @Page + private SAMLIDPInitiatedLogin samlidpInitiatedLogin; + @Deployment(name = BadClientSalesPostSigServlet.DEPLOYMENT_NAME) protected static WebArchive badClientSalesPostSig() { return samlServletDeployment(BadClientSalesPostSigServlet.DEPLOYMENT_NAME, SendUsernameServlet.class); @@ -458,4 +462,20 @@ public abstract class AbstractSAMLServletsAdapterTest extends AbstractServletsAd assertTrue(driver.getPageSource().contains("Forbidden") || driver.getPageSource().contains("Status 403")); salesPostSigTransientServletPage.logout(); } + + @Test + public void idpInitiatedLogin() { + samlidpInitiatedLogin.setAuthRealm(SAMLSERVLETDEMO); + samlidpInitiatedLogin.setUrlName("employee2"); + samlidpInitiatedLogin.navigateTo(); + samlidpInitiatedLogin.form().login(bburkeUser); + + employee2ServletPage.navigateTo(); + assertTrue(driver.getPageSource().contains("principal=bburke")); + + salesPostSigServletPage.navigateTo(); + assertTrue(driver.getPageSource().contains("principal=bburke")); + + employee2ServletPage.logout(); + } } diff --git a/testsuite/integration-arquillian/tests/base/src/test/resources/adapter-test/keycloak-saml/testsaml.json b/testsuite/integration-arquillian/tests/base/src/test/resources/adapter-test/keycloak-saml/testsaml.json index 031edc7018..5a1d2c6c20 100755 --- a/testsuite/integration-arquillian/tests/base/src/test/resources/adapter-test/keycloak-saml/testsaml.json +++ b/testsuite/integration-arquillian/tests/base/src/test/resources/adapter-test/keycloak-saml/testsaml.json @@ -299,7 +299,8 @@ ], "adminUrl": "http://localhost:8080/employee2", "attributes": { - "saml.authnstatement": "true" + "saml.authnstatement": "true", + "saml_idp_initiated_sso_url_name" : "employee2" }, "protocolMappers": [ {