Add tests for IDP initiated login

This commit is contained in:
mhajas 2016-02-26 16:45:17 +01:00
parent d766c56eba
commit 4f0609f8b2
3 changed files with 41 additions and 1 deletions

View file

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

View file

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

View file

@ -299,7 +299,8 @@
],
"adminUrl": "http://localhost:8080/employee2",
"attributes": {
"saml.authnstatement": "true"
"saml.authnstatement": "true",
"saml_idp_initiated_sso_url_name" : "employee2"
},
"protocolMappers": [
{