Skip to content

Commit

Permalink
Fixes #286
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Aug 23, 2024
1 parent a285a25 commit 2bef72f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/src/main/java/access/profile/ProfileController.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ResponseEntity<List<UserRoleProfile>> roles(@RequestParam("collabPersonId
Optional<User> optionalUser = userRepository.findBySubIgnoreCase(collabPersonId);
Set<UserRole> userRoles = optionalUser.map(User::getUserRoles).orElse(Collections.emptySet());
List<Role> 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().
Expand Down
16 changes: 16 additions & 0 deletions server/src/test/java/access/profile/ProfileControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ void roles() {
}

@Test
void rolesGuestRoleIncluded() {
stubForManagerProvidersByIdIn(EntityType.SAML20_SP, List.of("1"));

List<UserRoleProfile> 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<UserRoleProfile> roles = given()
.when()
Expand Down

0 comments on commit 2bef72f

Please sign in to comment.