diff --git a/server/src/main/java/access/profile/ProfileController.java b/server/src/main/java/access/profile/ProfileController.java index c533a38e..228de082 100644 --- a/server/src/main/java/access/profile/ProfileController.java +++ b/server/src/main/java/access/profile/ProfileController.java @@ -48,7 +48,7 @@ public ResponseEntity> roles(@RequestParam("collabPersonId Optional optionalUser = userRepository.findBySubIgnoreCase(collabPersonId); Set userRoles = optionalUser.map(User::getUserRoles).orElse(Collections.emptySet()); List roles = userRoles.stream() - .filter(userRole -> userRole.getAuthority().equals(Authority.GUEST)) + .filter(userRole -> userRole.getAuthority().equals(Authority.GUEST) || userRole.isGuestRoleIncluded()) .map(UserRole::getRole).toList(); return ResponseEntity.ok( manage.addManageMetaData(roles).stream(). diff --git a/server/src/test/java/access/profile/ProfileControllerTest.java b/server/src/test/java/access/profile/ProfileControllerTest.java index 4affb8e1..6a8b0612 100644 --- a/server/src/test/java/access/profile/ProfileControllerTest.java +++ b/server/src/test/java/access/profile/ProfileControllerTest.java @@ -45,6 +45,22 @@ void roles() { } @Test + void rolesGuestRoleIncluded() { + stubForManagerProvidersByIdIn(EntityType.SAML20_SP, List.of("1")); + + List roles = given() + .when() + .auth().preemptive().basic("profile", "secret") + .accept(ContentType.JSON) + .contentType(ContentType.JSON) + .queryParam("collabPersonId", MANAGE_SUB) + .get("/api/profile") + .as(new TypeRef<>() { + }); + assertEquals(1, roles.size()); + } + + @Test void rolesNotExistentUser() { List roles = given() .when()