use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestGroupingsRestController method groupingAssignmentTest.
@Test
@WithMockUhUser(username = "iamtst01")
public void groupingAssignmentTest() throws Exception {
GroupingAssignment groupings = mapGroupingAssignment();
boolean inGrouping = false;
for (Grouping grouping : groupings.getGroupingsIn()) {
if (grouping.getPath().contains(this.GROUPING)) {
inGrouping = true;
break;
}
}
assertTrue(inGrouping);
boolean canOptin = false;
for (Grouping grouping : groupings.getGroupingsToOptInTo()) {
if (grouping.getPath().contains(this.GROUPING)) {
canOptin = true;
break;
}
}
assertFalse(canOptin);
boolean canOptOut = false;
for (Grouping grouping : groupings.getGroupingsToOptOutOf()) {
if (grouping.getPath().contains(this.GROUPING)) {
canOptOut = true;
break;
}
}
assertTrue(canOptOut);
boolean ownsGrouping = false;
for (Grouping grouping : groupings.getGroupingsOwned()) {
if (grouping.getPath().contains(this.GROUPING)) {
ownsGrouping = true;
break;
}
}
assertTrue(ownsGrouping);
}
use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestGroupingsRestController method adminListsFailTest.
@Test
@WithMockUhUser(username = "iamtst01")
public void adminListsFailTest() throws Exception {
AdminListsHolder infoFail = mapAdminListsHolder();
assertEquals(infoFail.getAdminGroup().getMembers().size(), 0);
assertEquals(infoFail.getAllGroupings().size(), 0);
}
use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.
the class UserContextServiceTest method testOwner.
@Test
@WithMockUhUser(username = "Owner", roles = { "ROLE_OWNER" })
public void testOwner() {
User user = userContextService.getCurrentUser();
assertThat(user.hasRole(Role.ADMIN), equalTo(false));
assertThat(user.hasRole(Role.OWNER), equalTo(true));
}
use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.
the class UserContextServiceTest method basics.
@Test
@WithMockUhUser(username = "admin", roles = { "ROLE_ADMIN" })
public void basics() {
assertThat(userContextService.getCurrentUhUuid(), equalTo("12345678"));
assertThat(userContextService.getCurrentUid(), equalTo("admin"));
assertThat(userContextService.toString(), startsWith("UserContextServiceImpl"));
User user = userContextService.getCurrentUser();
assertNotNull(user);
assertThat(user.getUhUuid(), equalTo("12345678"));
assertThat(user.getUid(), equalTo("admin"));
userContextService.setCurrentUhUuid("87654321");
assertThat(userContextService.getCurrentUhUuid(), equalTo("87654321"));
}
use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingsRestControllerTest method removeMembersFromIncludeGroupTest.
@Test
@WithMockUhUser
public void removeMembersFromIncludeGroupTest() throws Exception {
String uri = REST_CONTROLLER_BASE + GROUPING + "/" + USERNAME + "/removeMembersFromIncludeGroup";
given(httpRequestService.makeApiRequest(eq(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(USERNAME), anyString(), eq(HttpMethod.DELETE));
}
Aggregations