[KEYCLOAK-10696] - fixed missing client role attributes after import

This commit is contained in:
Adamczyk Błażej 2020-02-10 14:38:34 -03:00 committed by Stian Thorgersen
parent a76c496c23
commit 497787d2cd
3 changed files with 13 additions and 1 deletions

View file

@ -628,6 +628,9 @@ public class RepresentationToModel {
// Application role may already exists (for example if it is defaultRole)
RoleModel role = roleRep.getId() != null ? client.addRole(roleRep.getId(), roleRep.getName()) : client.addRole(roleRep.getName());
role.setDescription(roleRep.getDescription());
if (roleRep.getAttributes() != null) {
roleRep.getAttributes().forEach((key, value) -> role.setAttribute(key, value));
}
}
}
}

View file

@ -315,6 +315,7 @@ public class ExportImportTest extends AbstractKeycloakTest {
Map<String, List<String>> roleAttributes = adminClient.realm("test").roles().get("attribute-role").toRepresentation().getAttributes();
String testAppId = adminClient.realm("test").clients().findByClientId("test-app").get(0).getId();
String sampleClientRoleId = adminClient.realm("test").clients().get(testAppId).roles().get("sample-client-role").toRepresentation().getId();
String sampleClientRoleAttribute = adminClient.realm("test").clients().get(testAppId).roles().get("sample-client-role").toRepresentation().getAttributes().get("sample-client-role-attribute").get(0);
// Delete some realm (and some data in admin realm)
adminClient.realm("test").remove();
@ -365,6 +366,9 @@ public class ExportImportTest extends AbstractKeycloakTest {
String importedSampleClientRoleId = adminClient.realm("test").clients().get(testAppId).roles().get("sample-client-role").toRepresentation().getId();
assertEquals(sampleClientRoleId, importedSampleClientRoleId);
String importedSampleClientRoleAttribute = adminClient.realm("test").clients().get(testAppId).roles().get("sample-client-role").toRepresentation().getAttributes().get("sample-client-role-attribute").get(0);
assertEquals(sampleClientRoleAttribute, importedSampleClientRoleAttribute);
checkEventsConfig(adminClient.realm("test").getRealmEventsConfig());
}

View file

@ -473,7 +473,12 @@
},
{
"name": "sample-client-role",
"description": "Sample client role"
"description": "Sample client role",
"attributes": {
"sample-client-role-attribute": [
"sample-client-role-attribute-value"
]
}
},
{
"name": "customer-admin-composite-role",