Add tests for IDP initiated login
This commit is contained in:
parent
d766c56eba
commit
4f0609f8b2
3 changed files with 41 additions and 1 deletions
|
@ -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}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.keycloak.representations.idm.RealmRepresentation;
|
||||||
import org.keycloak.testsuite.adapter.AbstractServletsAdapterTest;
|
import org.keycloak.testsuite.adapter.AbstractServletsAdapterTest;
|
||||||
import org.keycloak.testsuite.adapter.page.*;
|
import org.keycloak.testsuite.adapter.page.*;
|
||||||
import org.keycloak.testsuite.admin.ApiUtil;
|
import org.keycloak.testsuite.admin.ApiUtil;
|
||||||
|
import org.keycloak.testsuite.auth.page.login.SAMLIDPInitiatedLogin;
|
||||||
import org.keycloak.testsuite.util.IOUtil;
|
import org.keycloak.testsuite.util.IOUtil;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
|
@ -81,6 +82,9 @@ public abstract class AbstractSAMLServletsAdapterTest extends AbstractServletsAd
|
||||||
@Page
|
@Page
|
||||||
private SalesPostSigTransientServlet salesPostSigTransientServletPage;
|
private SalesPostSigTransientServlet salesPostSigTransientServletPage;
|
||||||
|
|
||||||
|
@Page
|
||||||
|
private SAMLIDPInitiatedLogin samlidpInitiatedLogin;
|
||||||
|
|
||||||
@Deployment(name = BadClientSalesPostSigServlet.DEPLOYMENT_NAME)
|
@Deployment(name = BadClientSalesPostSigServlet.DEPLOYMENT_NAME)
|
||||||
protected static WebArchive badClientSalesPostSig() {
|
protected static WebArchive badClientSalesPostSig() {
|
||||||
return samlServletDeployment(BadClientSalesPostSigServlet.DEPLOYMENT_NAME, SendUsernameServlet.class);
|
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"));
|
assertTrue(driver.getPageSource().contains("Forbidden") || driver.getPageSource().contains("Status 403"));
|
||||||
salesPostSigTransientServletPage.logout();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,7 +299,8 @@
|
||||||
],
|
],
|
||||||
"adminUrl": "http://localhost:8080/employee2",
|
"adminUrl": "http://localhost:8080/employee2",
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"saml.authnstatement": "true"
|
"saml.authnstatement": "true",
|
||||||
|
"saml_idp_initiated_sso_url_name" : "employee2"
|
||||||
},
|
},
|
||||||
"protocolMappers": [
|
"protocolMappers": [
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue