mirror of
https://github.com/valitydev/org-manager.git
synced 2024-11-06 00:15:23 +00:00
add controller test + fix check method
This commit is contained in:
parent
e177a2a275
commit
a88353e54d
@ -144,7 +144,7 @@ public class OrgsController implements OrgsApi {
|
||||
String userId,
|
||||
MemberRole body) {
|
||||
log.info("Assign member role: requestId={}, orgId={}, payload={}", xRequestID, orgId, body);
|
||||
resourceAccessService.checkRoleRights(orgId, body);
|
||||
resourceAccessService.checkMemberRoleRights(orgId, userId, body);
|
||||
return organizationService.assignMemberRole(orgId, userId, body);
|
||||
}
|
||||
|
||||
|
@ -97,6 +97,20 @@ public class OrgsControllerTest extends AbstractControllerTest {
|
||||
.andExpect(status().isForbidden());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void assignMemberRoleWithoutAccess() throws Exception {
|
||||
MemberRole memberRole = TestData.buildMemberRole();
|
||||
doThrow(new AccessDeniedException("Access denied")).when(resourceAccessService)
|
||||
.checkMemberRoleRights(ORGANIZATION_ID, MEMBER_ID, memberRole);
|
||||
|
||||
mockMvc.perform(put(String.format("/orgs/%s/members/%s/roles", ORGANIZATION_ID, MEMBER_ID))
|
||||
.contentType("application/json")
|
||||
.content(objectMapper.writeValueAsString(memberRole))
|
||||
.header("Authorization", "Bearer " + generateRBKadminJwt())
|
||||
.header("X-Request-ID", "testRequestId"))
|
||||
.andExpect(status().isForbidden());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void assignMemberRoleTest() throws Exception {
|
||||
MemberRole memberRole = TestData.buildMemberRole();
|
||||
|
Loading…
Reference in New Issue
Block a user