Search in sources :

Example 96 with ProtocolMapperRepresentation

use of org.keycloak.representations.idm.ProtocolMapperRepresentation in project keycloak by keycloak.

the class ClientMappersSAMLTest method testRoleList.

@Test
public void testRoleList() {
    // create
    clientMappersPage.mapperTable().createMapper();
    setInitialValues("new role list");
    createClientMappersPage.form().setMapperType(ROLE_LIST);
    createClientMappersPage.form().setRoleAttributeName("role attribute name");
    createClientMappersPage.form().setFriendlyName("friendly name");
    createClientMappersPage.form().setSamlAttributeNameFormat("URI Reference");
    createClientMappersPage.form().setSingleRoleAttribute(true);
    createClientMappersPage.form().save();
    assertAlertSuccess();
    // check
    ProtocolMapperRepresentation found = findClientMapperByName(id, "new role list");
    assertNotNull(found);
    assertEquals("saml-role-list-mapper", found.getProtocolMapper());
    Map<String, String> config = found.getConfig();
    assertEquals("role attribute name", config.get("attribute.name"));
    assertEquals("URI Reference", config.get("attribute.nameformat"));
    assertEquals("friendly name", config.get("friendly.name"));
    assertEquals("true", config.get("single"));
}
Also used : ProtocolMapperRepresentation(org.keycloak.representations.idm.ProtocolMapperRepresentation) Test(org.junit.Test)

Example 97 with ProtocolMapperRepresentation

use of org.keycloak.representations.idm.ProtocolMapperRepresentation in project keycloak by keycloak.

the class ClientMappersOIDCTest method testUserAttribute.

@Test
public void testUserAttribute() {
    // create
    clientMappersPage.mapperTable().createMapper();
    setInitialValues("user attribute");
    createClientMappersPage.form().setMapperType(USER_ATTRIBUTE);
    createClientMappersPage.form().setUserAttribute("user attribute");
    createClientMappersPage.form().setMultivalued(true);
    createClientMappersPage.form().save();
    assertAlertSuccess();
    // check
    ProtocolMapperRepresentation found = findClientMapperByName(id, "user attribute");
    assertEquals("oidc-usermodel-attribute-mapper", found.getProtocolMapper());
    Map<String, String> config = found.getConfig();
    assertEquals("true", config.get("multivalued"));
    assertEquals("user attribute", config.get("user.attribute"));
}
Also used : ProtocolMapperRepresentation(org.keycloak.representations.idm.ProtocolMapperRepresentation) Test(org.junit.Test)

Example 98 with ProtocolMapperRepresentation

use of org.keycloak.representations.idm.ProtocolMapperRepresentation in project keycloak by keycloak.

the class ClientMappersOIDCTest method testUserSessionNote.

@Test
public void testUserSessionNote() {
    // create
    clientMappersPage.mapperTable().createMapper();
    setInitialValues("user session note");
    createClientMappersPage.form().setMapperType(USER_SESSION_NOTE);
    createClientMappersPage.form().setUserSessionNote("session note");
    createClientMappersPage.form().setTokenClaimName("claim name");
    createClientMappersPage.form().setClaimJSONType("int");
    createClientMappersPage.form().setAddToIDToken(false);
    createClientMappersPage.form().setAddToAccessToken(false);
    createClientMappersPage.form().save();
    assertAlertSuccess();
    // check
    ProtocolMapperRepresentation found = findClientMapperByName(id, "user session note");
    assertNotNull(found);
    assertEquals("oidc-usersessionmodel-note-mapper", found.getProtocolMapper());
    Map<String, String> config = found.getConfig();
    assertEquals("claim name", config.get("claim.name"));
    assertEquals("session note", config.get("user.session.note"));
    assertEquals("int", config.get("jsonType.label"));
}
Also used : ProtocolMapperRepresentation(org.keycloak.representations.idm.ProtocolMapperRepresentation) Test(org.junit.Test)

Example 99 with ProtocolMapperRepresentation

use of org.keycloak.representations.idm.ProtocolMapperRepresentation in project keycloak by keycloak.

the class ClientMappersOIDCTest method testUserAddress.

@Test
public void testUserAddress() {
    // create
    clientMappersPage.mapperTable().createMapper();
    setInitialValues("user address");
    createClientMappersPage.form().setMapperType(USERS_FULL_NAME);
    createClientMappersPage.form().save();
    assertAlertSuccess();
    // check
    ProtocolMapperRepresentation found = findClientMapperByName(id, "user address");
    assertEquals("oidc-full-name-mapper", found.getProtocolMapper());
}
Also used : ProtocolMapperRepresentation(org.keycloak.representations.idm.ProtocolMapperRepresentation) Test(org.junit.Test)

Example 100 with ProtocolMapperRepresentation

use of org.keycloak.representations.idm.ProtocolMapperRepresentation in project keycloak by keycloak.

the class ClientMappersOIDCTest method testGroupMembership.

@Test
public void testGroupMembership() {
    // create
    clientMappersPage.mapperTable().createMapper();
    setInitialValues("group membership");
    createClientMappersPage.form().setMapperType(GROUP_MEMBERSHIP);
    createClientMappersPage.form().setFullGroupPath(true);
    createClientMappersPage.form().save();
    assertAlertSuccess();
    // check
    ProtocolMapperRepresentation found = findClientMapperByName(id, "group membership");
    assertEquals("oidc-group-membership-mapper", found.getProtocolMapper());
    Map<String, String> config = found.getConfig();
    assertEquals("true", config.get("full.path"));
}
Also used : ProtocolMapperRepresentation(org.keycloak.representations.idm.ProtocolMapperRepresentation) Test(org.junit.Test)

Aggregations

ProtocolMapperRepresentation (org.keycloak.representations.idm.ProtocolMapperRepresentation)107 Test (org.junit.Test)68 HashMap (java.util.HashMap)30 Response (javax.ws.rs.core.Response)30 ClientRepresentation (org.keycloak.representations.idm.ClientRepresentation)27 Map (java.util.Map)23 AbstractKeycloakTest (org.keycloak.testsuite.AbstractKeycloakTest)20 ClientResource (org.keycloak.admin.client.resource.ClientResource)19 OAuthClient (org.keycloak.testsuite.util.OAuthClient)17 RealmResource (org.keycloak.admin.client.resource.RealmResource)14 List (java.util.List)13 ProtocolMappersResource (org.keycloak.admin.client.resource.ProtocolMappersResource)12 IDToken (org.keycloak.representations.IDToken)12 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)11 ClientScopeRepresentation (org.keycloak.representations.idm.ClientScopeRepresentation)11 AuthServerContainerExclude (org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude)10 UserRepresentation (org.keycloak.representations.idm.UserRepresentation)8 ArrayList (java.util.ArrayList)7 LinkedList (java.util.LinkedList)7 AccessToken (org.keycloak.representations.AccessToken)7