use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestGroupingsRestController method getGroupingTest.
@Test
@WithMockUhUser(username = "iamtst01")
public void getGroupingTest() throws Exception {
Grouping grouping = mapGrouping(GROUPING);
Group basis = grouping.getBasis();
Group composite = grouping.getComposite();
Group exclude = grouping.getExclude();
Group include = grouping.getInclude();
// basis
assertTrue(basis.getUsernames().contains(tst[3]));
assertTrue(basis.getUsernames().contains(tst[4]));
assertTrue(basis.getUsernames().contains(tst[5]));
assertTrue(basis.getNames().contains(tstName[3]));
assertTrue(basis.getNames().contains(tstName[4]));
assertTrue(basis.getNames().contains(tstName[5]));
// composite
assertTrue(composite.getUsernames().contains(tst[0]));
assertTrue(composite.getUsernames().contains(tst[1]));
assertTrue(composite.getUsernames().contains(tst[2]));
assertTrue(composite.getUsernames().contains(tst[4]));
assertTrue(composite.getUsernames().contains(tst[5]));
assertTrue(composite.getNames().contains(tstName[0]));
assertTrue(composite.getNames().contains(tstName[1]));
assertTrue(composite.getNames().contains(tstName[2]));
assertTrue(composite.getNames().contains(tstName[4]));
assertTrue(composite.getNames().contains(tstName[5]));
// exclude
assertTrue(exclude.getUsernames().contains(tst[3]));
assertTrue(exclude.getNames().contains(tstName[3]));
// include
assertTrue(include.getUsernames().contains(tst[0]));
assertTrue(include.getUsernames().contains(tst[1]));
assertTrue(include.getUsernames().contains(tst[2]));
assertTrue(include.getNames().contains(tstName[0]));
assertTrue(include.getNames().contains(tstName[1]));
assertTrue(include.getNames().contains(tstName[2]));
assertFalse(grouping.getOwners().getNames().contains(tstName[5]));
mapGSR("/api/groupings/" + grouping.getPath() + "/" + tst[5] + "/assignOwnership");
grouping = mapGrouping(GROUPING);
assertTrue(grouping.getOwners().getNames().contains(tstName[5]));
mapGSR("/api/groupings/" + grouping.getPath() + "/" + tst[5] + "/removeOwnership");
grouping = mapGrouping(GROUPING);
assertFalse(grouping.getOwners().getNames().contains(tstName[5]));
}
use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingsRestControllerTest method hasAdminPrivsTest.
@Test
@WithMockUhUser(username = "admin")
public void hasAdminPrivsTest() throws Exception {
String uri = REST_CONTROLLER_BASE + "admins";
given(httpRequestService.makeApiRequest(eq(ADMIN_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(ADMIN_USERNAME), anyString(), eq(HttpMethod.GET));
}
use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingsRestControllerTest method removeFromGroupsTest.
@Test
@WithMockUhUser(username = "admin")
public void removeFromGroupsTest() throws Exception {
String uri = REST_CONTROLLER_BASE + GROUPING3 + "/user/removeFromGroups";
given(httpRequestService.makeApiRequest(eq(ADMIN_USERNAME), anyString(), eq(HttpMethod.DELETE))).willReturn(new ResponseEntity(HttpStatus.OK));
assertNotNull(mockMvc.perform(post(uri).with(csrf())).andExpect(status().isOk()).andReturn());
verify(httpRequestService, times(1)).makeApiRequest(eq(ADMIN_USERNAME), anyString(), eq(HttpMethod.DELETE));
}
use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingsRestControllerTest method removeAdminTest.
@Test
@WithMockUhUser(username = "admin")
public void removeAdminTest() throws Exception {
String uri = REST_CONTROLLER_BASE + "newAdmin/removeAdmin";
given(httpRequestService.makeApiRequest(eq(ADMIN_USERNAME), anyString(), eq(HttpMethod.DELETE))).willReturn(new ResponseEntity(HttpStatus.OK));
assertNotNull(mockMvc.perform(post(uri).with(csrf())).andExpect(status().isOk()).andReturn());
verify(httpRequestService, times(1)).makeApiRequest(eq(ADMIN_USERNAME), anyString(), eq(HttpMethod.DELETE));
}
use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingsRestControllerTest method groupingTest.
@Test
@WithMockUhUser
public void groupingTest() throws Exception {
String uri = REST_CONTROLLER_BASE + "groupings/" + 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));
}
Aggregations