use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingsRestControllerTest method numberOfGroupingsTest.
@Test
@WithMockUhUser
public void numberOfGroupingsTest() throws Exception {
String uri = REST_CONTROLLER_BASE + "owners/grouping";
given(httpRequestService.makeApiRequest(eq(USERNAME), anyString(), eq(HttpMethod.GET))).willReturn(new ResponseEntity(HttpStatus.OK));
assertNotNull(mockMvc.perform(get(uri).with(csrf())).andExpect(status().isOk()).andReturn());
verify(httpRequestService, times(1)).makeApiRequest(eq(USERNAME), anyString(), eq(HttpMethod.GET));
}
use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.
the class UserBuilderTest method testAdminUser.
@Test
@WithMockUhUser
public void testAdminUser() {
Map<String, String> map = new HashMap<>();
Principal principal = new SimplePrincipal(userContextService.getCurrentUhUuid());
map.put("uid", userContextService.getCurrentUser().getUid());
map.put("uhUuid", userContextService.getCurrentUhUuid());
given(groupingsRestController.hasOwnerPrivs(principal)).willReturn(new ResponseEntity<>("true", HttpStatus.OK));
given(groupingsRestController.hasAdminPrivs(principal)).willReturn(new ResponseEntity<>("true", HttpStatus.OK));
User user = userBuilder.make(map);
// Check results.
assertEquals(4, user.getAuthorities().size());
assertTrue(user.hasRole(Role.ANONYMOUS));
assertTrue(user.hasRole(Role.UH));
assertTrue(user.hasRole(Role.ADMIN));
assertTrue(user.hasRole(Role.OWNER));
}
use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingsRestControllerTest method addMembersToIncludeGroupTest.
@Test
@WithMockUhUser
public void addMembersToIncludeGroupTest() throws Exception {
String uri = REST_CONTROLLER_BASE + GROUPING + "/" + USERNAME + "/addMembersToIncludeGroup";
given(httpRequestService.makeApiRequest(eq(USERNAME), anyString(), eq(HttpMethod.PUT))).willReturn(new ResponseEntity(HttpStatus.OK));
assertNotNull(mockMvc.perform(post(uri).with(csrf())).andExpect(status().isOk()).andReturn());
verify(httpRequestService, times(1)).makeApiRequest(eq(USERNAME), anyString(), eq(HttpMethod.PUT));
}
use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingsRestControllerTest method hasOwnerPrivsTest.
@Test
@WithMockUhUser
public void hasOwnerPrivsTest() throws Exception {
String uri = REST_CONTROLLER_BASE + "owners";
given(httpRequestService.makeApiRequest(eq(USERNAME), anyString(), eq(HttpMethod.GET))).willReturn(new ResponseEntity(HttpStatus.OK));
assertNotNull(mockMvc.perform(get(uri).with(csrf())).andExpect(status().isOk()).andReturn());
verify(httpRequestService, times(1)).makeApiRequest(eq(USERNAME), anyString(), eq(HttpMethod.GET));
}
Aggregations