Skip to content

Commit

Permalink
Update API endpoints to match naming convention (uhawaii-system-its-t…
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhail-shkaralevich authored Feb 22, 2025
1 parent 5f20781 commit adeb938
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -652,25 +652,25 @@ public ResponseEntity<GroupingUpdateOptAttributeResult> updateOptAttribute(
/**
* True if currentUser is an owner.
*/
@GetMapping(value = "/owners")
@GetMapping(value = "/members/{uhIdentifier}/is-owner")
@ResponseBody
public ResponseEntity<Boolean> hasOwnerPrivs(@RequestHeader(CURRENT_USER_KEY) String currentUser) {
public ResponseEntity<Boolean> hasOwnerPrivs(@PathVariable String uhIdentifier) {
logger.info("Entered REST hasOwnerPrivs...");
return ResponseEntity
.ok()
.body(memberService.isOwner(currentUser));
.body(memberService.isOwner(uhIdentifier));
}

/**
* True if currentUser is an admin.
*/
@GetMapping(value = "/members/is-admin")
@GetMapping(value = "/members/{uhIdentifier}/is-admin")
@ResponseBody
public ResponseEntity<Boolean> hasAdminPrivs(@RequestHeader(CURRENT_USER_KEY) String currentUser) {
public ResponseEntity<Boolean> hasAdminPrivs(@PathVariable String uhIdentifier) {
logger.info("Entered REST hasAdminPrivs...");
return ResponseEntity
.ok()
.body(memberService.isAdmin(currentUser));
.body(memberService.isAdmin(uhIdentifier));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,7 @@ public void updateSyncDestTest() throws Exception {
@Test
public void hasOwnerPrivsTest() throws Exception {
given(memberService.isOwner(CURRENT_USER)).willReturn(false);
MvcResult result = mockMvc.perform(get(API_BASE + "/owners")
.header(CURRENT_USER, CURRENT_USER))
MvcResult result = mockMvc.perform(get(API_BASE + "/members/" + CURRENT_USER + "/is-owner"))
.andExpect(status().isOk())
.andReturn();
assertNotNull(result);
Expand All @@ -841,8 +840,7 @@ public void hasOwnerPrivsTest() throws Exception {
@Test
public void hasAdminPrivsTest() throws Exception {
given(memberService.isAdmin(CURRENT_USER)).willReturn(false);
MvcResult result = mockMvc.perform(get(API_BASE + "/members/is-admin")
.header(CURRENT_USER, CURRENT_USER))
MvcResult result = mockMvc.perform(get(API_BASE + "/members/" + CURRENT_USER + "/is-admin"))
.andExpect(status().isOk())
.andReturn();
assertNotNull(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,19 +692,17 @@ public void updateSyncDestTest() throws Exception {

@Test
public void hasAdminPrivsTest() throws Exception {
String url = API_BASE_URL + "members/is-admin";
MvcResult mvcResult = mockMvc.perform(get(url)
.header(CURRENT_USER, ADMIN))
String url = API_BASE_URL + "members/" + ADMIN + "/is-admin";
MvcResult mvcResult = mockMvc.perform(get(url))
.andExpect(status().isOk())
.andReturn();
assertNotNull(objectMapper.readValue(mvcResult.getResponse().getContentAsByteArray(), Boolean.class));
}

@Test
public void hasOwnerPrivsTest() throws Exception {
String url = API_BASE_URL + "owners";
MvcResult mvcResult = mockMvc.perform(get(url)
.header(CURRENT_USER, ADMIN))
String url = API_BASE_URL + "members/" + ADMIN + "/is-owner";
MvcResult mvcResult = mockMvc.perform(get(url))
.andExpect(status().isOk())
.andReturn();
assertNotNull(objectMapper.readValue(mvcResult.getResponse().getContentAsByteArray(), Boolean.class));
Expand Down

0 comments on commit adeb938

Please sign in to comment.