Skip to content
Snippets Groups Projects
Commit 2df50a8f authored by OZGCloud's avatar OZGCloud
Browse files

Merge branch 'OZG-2653_Usersynchronisation' of git.ozg-sh.de:mgm/user-manager...

Merge branch 'OZG-2653_Usersynchronisation' of git.ozg-sh.de:mgm/user-manager into OZG-2653_Usersynchronisation
parents d731cfc1 0fd5c1c6
No related branches found
No related tags found
No related merge requests found
package de.itvsh.kop.user; package de.itvsh.kop.user;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -10,7 +11,6 @@ import javax.inject.Inject; ...@@ -10,7 +11,6 @@ import javax.inject.Inject;
import org.keycloak.admin.client.resource.UserResource; import org.keycloak.admin.client.resource.UserResource;
import org.keycloak.representations.idm.ClientMappingsRepresentation; import org.keycloak.representations.idm.ClientMappingsRepresentation;
import org.keycloak.representations.idm.GroupRepresentation;
import org.keycloak.representations.idm.RoleRepresentation; import org.keycloak.representations.idm.RoleRepresentation;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
...@@ -43,13 +43,12 @@ public abstract class UserResourceMapper { ...@@ -43,13 +43,12 @@ public abstract class UserResourceMapper {
} }
List<String> mapOrganisationsEinheitIds(UserResource userRes) { List<String> mapOrganisationsEinheitIds(UserResource userRes) {
return userRes.groups().stream() return getOrganisationsEinheitIdsFromUserAttributes(userRes);
.map(GroupRepresentation::getAttributes) }
.filter(Objects::nonNull)
.map(attributeMap -> attributeMap.get(properties.organisationsEinheitIdKey())) private List<String> getOrganisationsEinheitIdsFromUserAttributes(UserResource userResource) {
.filter(Objects::nonNull) var attributes = userResource.toRepresentation().getAttributes();
.map(attributeValues -> attributeValues.get(0)) return attributes != null ? attributes.get(properties.organisationsEinheitIdKey()) : new ArrayList<>();
.toList();
} }
List<String> mapRoles(UserResource userRes) { List<String> mapRoles(UserResource userRes) {
...@@ -65,7 +64,8 @@ public abstract class UserResourceMapper { ...@@ -65,7 +64,8 @@ public abstract class UserResourceMapper {
String mapId(UserResource userRes) { String mapId(UserResource userRes) {
var userRepresentation = userRes.toRepresentation(); var userRepresentation = userRes.toRepresentation();
var id = userRepresentation.getAttributes().get(properties.ldapIdKey()); var attributes = userRepresentation.getAttributes();
var id = attributes != null ? attributes.get(properties.ldapIdKey()) : null;
return id != null ? id.get(0) : userRepresentation.getId(); return id != null ? id.get(0) : userRepresentation.getId();
} }
......
...@@ -6,5 +6,6 @@ usermanager: ...@@ -6,5 +6,6 @@ usermanager:
user: goofyApiUser user: goofyApiUser
password: S9UEMuLG9y9ev99 password: S9UEMuLG9y9ev99
realm: sh-kiel-dev realm: sh-kiel-dev
organisations-einheit-id-key: organisationseinheitId
keycloak: keycloak:
url: https://sso.dev.ozg-sh.de/auth url: https://sso.dev.ozg-sh.de/auth
\ No newline at end of file
package de.itvsh.kop.user.keycloak; package de.itvsh.kop.user.keycloak;
import static org.assertj.core.api.Assertions.*;
import javax.inject.Inject; import javax.inject.Inject;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.*;
import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.TestProfile; import io.quarkus.test.junit.TestProfile;
...@@ -18,7 +18,7 @@ class KeycloakApiServiceITCase { ...@@ -18,7 +18,7 @@ class KeycloakApiServiceITCase {
@Test @Test
void shouldGetAllUsers() { void shouldGetAllUsers() {
var usersStream = service.findAllUser(); var usersStream = service.findAllUser().toList();
assertThat(usersStream).isNotEmpty(); assertThat(usersStream).isNotEmpty();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment