Skip to content

Commit 10bf769

Browse files
committed
WIP for #599
1 parent 1fe2298 commit 10bf769

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

server/src/main/java/invite/internal/InternalInviteController.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public InternalInviteController(RoleRepository roleRepository,
9292

9393
@GetMapping("/roles")
9494
@PreAuthorize("hasAnyRole('SP_DASHBOARD','ACCESS')")
95+
@Transactional(readOnly = true)
9596
@Hidden
9697
public ResponseEntity<List<Role>> rolesByApplication(@Parameter(hidden = true) @AuthenticationPrincipal RemoteUser remoteUser) {
9798
LOG.debug(String.format("/roles for user %s", remoteUser.getName()));
@@ -105,6 +106,19 @@ public ResponseEntity<List<Role>> rolesByApplication(@Parameter(hidden = true) @
105106
return ResponseEntity.ok(roles);
106107
}
107108

109+
@GetMapping("/roles/{organizationGUID}/{manageId}")
110+
@PreAuthorize("hasRole('ACCESS')")
111+
@Transactional(readOnly = true)
112+
public ResponseEntity<List<Role>> rolesPerOrganizationApplicationId(@PathVariable("organizationGUID") String organizationGUID,
113+
@PathVariable("manageId") String manageId,
114+
@Parameter(hidden = true) @AuthenticationPrincipal RemoteUser remoteUser) {
115+
LOG.debug(String.format("/rolesPerApplicationId for remoteUser %s", remoteUser.getName()));
116+
117+
List<Role> roles = roleRepository
118+
.findByOrganizationGUIDAndApplicationUsagesApplicationManageId(organizationGUID, manageId);
119+
return ResponseEntity.ok(roles);
120+
}
121+
108122
@GetMapping("/roles/{id}")
109123
@PreAuthorize("hasAnyRole('SP_DASHBOARD','ACCESS')")
110124
@Hidden

server/src/test/java/invite/internal/InternalInviteControllerTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,26 @@ void userRolesByRole() {
210210
assertEquals(2, userRoles.size());
211211
}
212212

213+
@Test
214+
void rolesPerOrganizationApplicationId() {
215+
List<Role> roles = given()
216+
.when()
217+
.auth().preemptive().basic("access", "secret")
218+
.accept(ContentType.JSON)
219+
.contentType(ContentType.JSON)
220+
.pathParam("organizationGUID", ORGANISATION_GUID)
221+
//See Role research in AbstractTest#doSeed
222+
.pathParam("manageId", "4")
223+
.get("/api/external/v1/internal/invite/roles/{organizationGUID}/{manageId}")
224+
.as(new TypeRef<>() {
225+
});
226+
227+
assertEquals(1, roles.size());
228+
229+
Role role = roles.getFirst();
230+
assertEquals("Research", role.getName());
231+
assertEquals(2L, role.getUserRoleCount());
232+
}
233+
234+
213235
}

0 commit comments

Comments
 (0)