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