use of org.keycloak.representations.idm.ProtocolMapperRepresentation in project keycloak by keycloak.
the class ClientProtocolMapperTest method test07UpdateOidcMapper.
@Test
public void test07UpdateOidcMapper() {
ProtocolMapperRepresentation rep = makeOidcMapper("oidc-hardcoded-role-mapper2");
Response resp = oidcMappersRsc.createMapper(rep);
resp.close();
String createdId = ApiUtil.getCreatedId(resp);
assertAdminEvents.assertEvent(getRealmId(), OperationType.CREATE, AdminEventPaths.clientProtocolMapperPath(oidcClientId, createdId), rep, ResourceType.PROTOCOL_MAPPER);
rep.getConfig().put("role", "myotherrole");
rep.setId(createdId);
oidcMappersRsc.update(createdId, rep);
assertAdminEvents.assertEvent(getRealmId(), OperationType.UPDATE, AdminEventPaths.clientProtocolMapperPath(oidcClientId, createdId), rep, ResourceType.PROTOCOL_MAPPER);
ProtocolMapperRepresentation updated = oidcMappersRsc.getMapperById(createdId);
assertEqualMappers(rep, updated);
}
use of org.keycloak.representations.idm.ProtocolMapperRepresentation in project keycloak by keycloak.
the class ClientProtocolMapperTest method test09DeleteOidcMapper.
@Test
public void test09DeleteOidcMapper() {
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.clientProtocolMapperPath(oidcClientId, createdId), rep, ResourceType.PROTOCOL_MAPPER);
oidcMappersRsc.delete(createdId);
assertAdminEvents.assertEvent(getRealmId(), OperationType.DELETE, AdminEventPaths.clientProtocolMapperPath(oidcClientId, createdId), ResourceType.PROTOCOL_MAPPER);
try {
oidcMappersRsc.getMapperById(createdId);
Assert.fail("Not expected to find mapper");
} catch (NotFoundException nfe) {
// Expected
}
}
use of org.keycloak.representations.idm.ProtocolMapperRepresentation in project keycloak by keycloak.
the class ClientProtocolMapperTest method test06UpdateSamlMapper.
@Test
public void test06UpdateSamlMapper() {
ProtocolMapperRepresentation rep = makeSamlMapper("saml-role-name-mapper2");
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);
rep.getConfig().put("role", "account.manage-account");
rep.setId(createdId);
samlMappersRsc.update(createdId, rep);
assertAdminEvents.assertEvent(getRealmId(), OperationType.UPDATE, AdminEventPaths.clientProtocolMapperPath(samlClientId, createdId), rep, ResourceType.PROTOCOL_MAPPER);
ProtocolMapperRepresentation updated = samlMappersRsc.getMapperById(createdId);
assertEqualMappers(rep, updated);
}
use of org.keycloak.representations.idm.ProtocolMapperRepresentation in project keycloak by keycloak.
the class ClientProtocolMapperTest method test05CreateOidcProtocolMapper.
@Test
public void test05CreateOidcProtocolMapper() {
// {"protocol":"openid-connect",
// "config":{"role":"myrole"},
// "consentRequired":true,
// "consentText":"My consent text",
// "name":"oidc-hardcoded-role-mapper",
// "protocolMapper":"oidc-hardcoded-role-mapper"}
ProtocolMapperRepresentation rep = makeOidcMapper("oidc-hardcoded-role-mapper");
int totalMappers = oidcMappersRsc.getMappers().size();
int totalOidcMappers = oidcMappersRsc.getMappersPerProtocol("openid-connect").size();
Response resp = oidcMappersRsc.createMapper(rep);
resp.close();
String createdId = ApiUtil.getCreatedId(resp);
assertAdminEvents.assertEvent(getRealmId(), OperationType.CREATE, AdminEventPaths.clientProtocolMapperPath(oidcClientId, createdId), rep, ResourceType.PROTOCOL_MAPPER);
assertEquals(totalMappers + 1, oidcMappersRsc.getMappers().size());
assertEquals(totalOidcMappers + 1, oidcMappersRsc.getMappersPerProtocol("openid-connect").size());
// findByName(samlMappersRsc, "saml-role-name-mapper");
ProtocolMapperRepresentation created = oidcMappersRsc.getMapperById(createdId);
assertEqualMappers(rep, created);
}
use of org.keycloak.representations.idm.ProtocolMapperRepresentation in project keycloak by keycloak.
the class ClientScopeTest method testUpdateProtocolMappers.
// KEYCLOAK-5863
@Test
public void testUpdateProtocolMappers() {
ClientScopeRepresentation scopeRep = new ClientScopeRepresentation();
scopeRep.setName("testUpdateProtocolMappers");
scopeRep.setProtocol("openid-connect");
String scopeId = createClientScope(scopeRep);
ProtocolMapperRepresentation mapper = new ProtocolMapperRepresentation();
mapper.setName("test");
mapper.setProtocol("openid-connect");
mapper.setProtocolMapper("oidc-usermodel-attribute-mapper");
Map<String, String> m = new HashMap<>();
m.put("user.attribute", "test");
m.put("claim.name", "");
m.put("jsonType.label", "");
mapper.setConfig(m);
ProtocolMappersResource protocolMappers = clientScopes().get(scopeId).getProtocolMappers();
Response response = protocolMappers.createMapper(mapper);
String mapperId = ApiUtil.getCreatedId(response);
mapper = protocolMappers.getMapperById(mapperId);
mapper.getConfig().put("claim.name", "claim");
protocolMappers.update(mapperId, mapper);
List<ProtocolMapperRepresentation> mappers = protocolMappers.getMappers();
assertEquals(1, mappers.size());
assertEquals(2, mappers.get(0).getConfig().size());
assertEquals("test", mappers.get(0).getConfig().get("user.attribute"));
assertEquals("claim", mappers.get(0).getConfig().get("claim.name"));
clientScopes().get(scopeId).remove();
}
Aggregations