Search in sources :

Example 16 with ProtocolMapperRepresentation

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

the class ClientScopeProtocolMapperTest method testDeleteOidcMapper.

@Test
public void testDeleteOidcMapper() {
    ProtocolMapperRepresentation rep = makeOidcMapper("oidc-hardcoded-role-mapper3");
    Response resp = oidcMappersRsc.createMapper(rep);
    resp.close();
    String createdId = ApiUtil.getCreatedId(resp);
    assertAdminEvents.assertEvent(getRealmId(), OperationType.CREATE, AdminEventPaths.clientScopeProtocolMapperPath(oidcClientScopeId, createdId), rep, ResourceType.PROTOCOL_MAPPER);
    oidcMappersRsc.delete(createdId);
    assertAdminEvents.assertEvent(getRealmId(), OperationType.DELETE, AdminEventPaths.clientScopeProtocolMapperPath(oidcClientScopeId, createdId), ResourceType.PROTOCOL_MAPPER);
    try {
        oidcMappersRsc.getMapperById(createdId);
        Assert.fail("Not expected to find mapper");
    } catch (NotFoundException nfe) {
    // Expected
    }
}
Also used : Response(javax.ws.rs.core.Response) ProtocolMapperRepresentation(org.keycloak.representations.idm.ProtocolMapperRepresentation) NotFoundException(javax.ws.rs.NotFoundException) Test(org.junit.Test)

Example 17 with ProtocolMapperRepresentation

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

the class AbstractProtocolMapperTest method makeMapper.

protected ProtocolMapperRepresentation makeMapper(String protocol, String name, String mapperType, Map<String, String> config) {
    ProtocolMapperRepresentation rep = new ProtocolMapperRepresentation();
    rep.setProtocol(protocol);
    rep.setName(name);
    rep.setProtocolMapper(mapperType);
    rep.setConfig(config);
    return rep;
}
Also used : ProtocolMapperRepresentation(org.keycloak.representations.idm.ProtocolMapperRepresentation)

Example 18 with ProtocolMapperRepresentation

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

the class ClientProtocolMapperTest method test04CreateSamlProtocolMapper.

@Test
public void test04CreateSamlProtocolMapper() {
    // {"protocol":"saml",
    // "config":{"role":"account.view-profile","new.role.name":"new-role-name"},
    // "consentRequired":true,
    // "consentText":"My consent text",
    // "name":"saml-role-name-maper",
    // "protocolMapper":"saml-role-name-mapper"}
    ProtocolMapperRepresentation rep = makeSamlMapper("saml-role-name-mapper");
    int totalMappers = samlMappersRsc.getMappers().size();
    int totalSamlMappers = samlMappersRsc.getMappersPerProtocol("saml").size();
    Response resp = samlMappersRsc.createMapper(rep);
    resp.close();
    String createdId = ApiUtil.getCreatedId(resp);
    assertAdminEvents.assertEvent(getRealmId(), OperationType.CREATE, AdminEventPaths.clientProtocolMapperPath(samlClientId, createdId), rep, ResourceType.PROTOCOL_MAPPER);
    assertEquals(totalMappers + 1, samlMappersRsc.getMappers().size());
    assertEquals(totalSamlMappers + 1, samlMappersRsc.getMappersPerProtocol("saml").size());
    ProtocolMapperRepresentation created = samlMappersRsc.getMapperById(createdId);
    assertEqualMappers(rep, created);
}
Also used : Response(javax.ws.rs.core.Response) ProtocolMapperRepresentation(org.keycloak.representations.idm.ProtocolMapperRepresentation) Test(org.junit.Test)

Example 19 with ProtocolMapperRepresentation

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

the class ClientProtocolMapperTest method test08DeleteSamlMapper.

@Test
public void test08DeleteSamlMapper() {
    ProtocolMapperRepresentation rep = makeSamlMapper("saml-role-name-mapper3");
    Response resp = samlMappersRsc.createMapper(rep);
    resp.close();
    String createdId = ApiUtil.getCreatedId(resp);
    assertAdminEvents.assertEvent(getRealmId(), OperationType.CREATE, AdminEventPaths.clientProtocolMapperPath(samlClientId, createdId), rep, ResourceType.PROTOCOL_MAPPER);
    samlMappersRsc.delete(createdId);
    assertAdminEvents.assertEvent(getRealmId(), OperationType.DELETE, AdminEventPaths.clientProtocolMapperPath(samlClientId, createdId), ResourceType.PROTOCOL_MAPPER);
    try {
        samlMappersRsc.getMapperById(createdId);
        Assert.fail("Not expected to find mapper");
    } catch (NotFoundException nfe) {
    // Expected
    }
}
Also used : Response(javax.ws.rs.core.Response) ProtocolMapperRepresentation(org.keycloak.representations.idm.ProtocolMapperRepresentation) NotFoundException(javax.ws.rs.NotFoundException) Test(org.junit.Test)

Example 20 with ProtocolMapperRepresentation

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

the class ClientScopeProtocolMapperTest method testDeleteSamlMapper.

@Test
public void testDeleteSamlMapper() {
    ProtocolMapperRepresentation rep = makeSamlMapper("saml-role-name-mapper3");
    Response resp = samlMappersRsc.createMapper(rep);
    resp.close();
    String createdId = ApiUtil.getCreatedId(resp);
    assertAdminEvents.assertEvent(getRealmId(), OperationType.CREATE, AdminEventPaths.clientScopeProtocolMapperPath(samlClientScopeId, createdId), rep, ResourceType.PROTOCOL_MAPPER);
    samlMappersRsc.delete(createdId);
    assertAdminEvents.assertEvent(getRealmId(), OperationType.DELETE, AdminEventPaths.clientScopeProtocolMapperPath(samlClientScopeId, createdId), ResourceType.PROTOCOL_MAPPER);
    try {
        samlMappersRsc.getMapperById(createdId);
        Assert.fail("Not expected to find mapper");
    } catch (NotFoundException nfe) {
    // Expected
    }
}
Also used : Response(javax.ws.rs.core.Response) ProtocolMapperRepresentation(org.keycloak.representations.idm.ProtocolMapperRepresentation) NotFoundException(javax.ws.rs.NotFoundException) 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