Skip to content
Snippets Groups Projects
Commit 287ac95c authored by OZGCloud's avatar OZGCloud
Browse files

OZG-5422 add client to the realmrole

parent 67094aa8
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,9 @@ package de.ozgcloud.operator.keycloak.realm; ...@@ -26,7 +26,9 @@ package de.ozgcloud.operator.keycloak.realm;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -70,6 +72,7 @@ interface KeycloakRealmMapper { ...@@ -70,6 +72,7 @@ interface KeycloakRealmMapper {
.map(RealmRole::getName) .map(RealmRole::getName)
.collect(Collectors.toList()); .collect(Collectors.toList());
List<RoleRepresentation> rolerepresentationList = new ArrayList<>(roleNames.size()); List<RoleRepresentation> rolerepresentationList = new ArrayList<>(roleNames.size());
Map<String, List<RoleRepresentation>> client = new HashMap<String, List<RoleRepresentation>>();
roleNames.forEach(roleName -> { roleNames.forEach(roleName -> {
...@@ -78,6 +81,7 @@ interface KeycloakRealmMapper { ...@@ -78,6 +81,7 @@ interface KeycloakRealmMapper {
rolerepresentationList.add(newRepresentation); } ); rolerepresentationList.add(newRepresentation); } );
roles.setRealm(rolerepresentationList); roles.setRealm(rolerepresentationList);
roles.setClient(client);
return roles; return roles;
} }
......
...@@ -89,4 +89,22 @@ class KeycloakRealmMapperTest { ...@@ -89,4 +89,22 @@ class KeycloakRealmMapperTest {
assertThat(mapped.getActionTokenGeneratedByUserLifespan()).isEqualTo(900); assertThat(mapped.getActionTokenGeneratedByUserLifespan()).isEqualTo(900);
} }
@Test
void shouldMapRealmRoles() {
var mapped = mapper.map(OzgCloudKeycloakRealmSpecTestFactory.create());
assertThat(mapped.getRoles().getRealm().size()).isEqualTo(2);
}
/* @Test
void shouldContainRealmRolesValues() {
var mapped = mapper.map(OzgCloudKeycloakRealmSpecTestFactory.create());
var mappedRealmRoles = mapped.getRoles();
assertThat(mappedRealmRoles.getRealm().getName()).isEqualTo("host");
var role = mapper.mapRole(OzgCloudKeycloakClientSpecTestFactory.ROLE1);
assertThat(role.getName()).isEqualTo(OzgCloudKeycloakClientSpecTestFactory.ROLE_NAME_1);
}*/
} }
...@@ -23,11 +23,21 @@ ...@@ -23,11 +23,21 @@
*/ */
package de.ozgcloud.operator.keycloak.realm; package de.ozgcloud.operator.keycloak.realm;
import java.util.List;
import de.ozgcloud.operator.keycloak.realm.OzgCloudKeycloakRealmSpec.RealmRole;
public class OzgCloudKeycloakRealmSpecTestFactory { public class OzgCloudKeycloakRealmSpecTestFactory {
public final static String DISPLAY_NAME = "TestDisplayName"; public final static String DISPLAY_NAME = "TestDisplayName";
public final static boolean KEEP_AFTER_DELETE = false; public final static boolean KEEP_AFTER_DELETE = false;
public static final String ROLE_NAME_1 = "RoleName1";
public static final RealmRole ROLE1 = RealmRole.builder().name(ROLE_NAME_1).build();
public static final String ROLE_NAME_2 = "RoleName2";
public static final RealmRole ROLE2 = RealmRole.builder().name(ROLE_NAME_2).build();
public static final List<RealmRole> ROLES = List.of(ROLE1,ROLE2);
public static OzgCloudKeycloakRealmSpec create() { public static OzgCloudKeycloakRealmSpec create() {
return createBuilder().build(); return createBuilder().build();
} }
...@@ -35,6 +45,7 @@ public class OzgCloudKeycloakRealmSpecTestFactory { ...@@ -35,6 +45,7 @@ public class OzgCloudKeycloakRealmSpecTestFactory {
public static OzgCloudKeycloakRealmSpec.OzgCloudKeycloakRealmSpecBuilder createBuilder() { public static OzgCloudKeycloakRealmSpec.OzgCloudKeycloakRealmSpecBuilder createBuilder() {
return OzgCloudKeycloakRealmSpec.builder() return OzgCloudKeycloakRealmSpec.builder()
.keepAfterDelete(KEEP_AFTER_DELETE) .keepAfterDelete(KEEP_AFTER_DELETE)
.displayName(DISPLAY_NAME); .displayName(DISPLAY_NAME)
.realmRoles(ROLES);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment