Search in sources :

Example 1 with AdminListsHolder

use of edu.hawaii.its.api.type.AdminListsHolder in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingAssignmentServiceTest method adminListsTest.

@Test
public void adminListsTest() {
    AdminListsHolder adminListsHolder = groupingAssignmentService.adminLists(ADMIN_USER);
    AdminListsHolder emptyAdminListHolder = groupingAssignmentService.adminLists(users.get(1).getUsername());
    assertEquals(adminListsHolder.getAllGroupings().size(), 5);
    assertEquals(adminListsHolder.getAdminGroup().getMembers().size(), 1);
    assertEquals(emptyAdminListHolder.getAllGroupings().size(), 0);
    assertEquals(emptyAdminListHolder.getAdminGroup().getMembers().size(), 0);
}
Also used : AdminListsHolder(edu.hawaii.its.api.type.AdminListsHolder) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with AdminListsHolder

use of edu.hawaii.its.api.type.AdminListsHolder in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingAssignmentServiceImpl method adminLists.

// returns an adminLists object containing the list of all admins and all groupings
@Override
public AdminListsHolder adminLists(String adminUsername) {
    AdminListsHolder info = new AdminListsHolder();
    List<Grouping> groupings;
    if (memberAttributeService.isSuperuser(adminUsername)) {
        WsGetAttributeAssignmentsResults attributeAssignmentsResults = grouperFS.makeWsGetAttributeAssignmentsResultsTrio(ASSIGN_TYPE_GROUP, TRIO);
        List<WsGroup> groups = new ArrayList<>(Arrays.asList(attributeAssignmentsResults.getWsGroups()));
        List<String> groupPaths = groups.stream().map(WsGroup::getName).collect(Collectors.toList());
        Group admin = getMembers(adminUsername, GROUPING_ADMINS);
        groupings = helperService.makeGroupings(groupPaths);
        info.setAdminGroup(admin);
        info.setAllGroupings(groupings);
    }
    return info;
}
Also used : AdminListsHolder(edu.hawaii.its.api.type.AdminListsHolder) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) ArrayList(java.util.ArrayList) WsGetAttributeAssignmentsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults) Grouping(edu.hawaii.its.api.type.Grouping) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup)

Example 3 with AdminListsHolder

use of edu.hawaii.its.api.type.AdminListsHolder in project uhgroupings by uhawaii-system-its-ti-iam.

the class TestGroupingsRestController method adminListsPassTest.

@Test
@WithMockUhUser(username = "_groupings_api_2")
public void adminListsPassTest() throws Exception {
    AdminListsHolder infoSuccess = mapAdminListsHolder();
    // STUDENT_TEST_USERNAME can be replaced with any account that has admin access
    assertTrue(infoSuccess.getAdminGroup().getUsernames().contains(STUDENT_TEST_USERNAME));
}
Also used : AdminListsHolder(edu.hawaii.its.api.type.AdminListsHolder) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) WithMockUhUser(edu.hawaii.its.groupings.controller.WithMockUhUser)

Example 4 with AdminListsHolder

use of edu.hawaii.its.api.type.AdminListsHolder 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);
}
Also used : AdminListsHolder(edu.hawaii.its.api.type.AdminListsHolder) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) WithMockUhUser(edu.hawaii.its.groupings.controller.WithMockUhUser)

Example 5 with AdminListsHolder

use of edu.hawaii.its.api.type.AdminListsHolder in project uhgroupings by uhawaii-system-its-ti-iam.

the class TestGroupingAssignmentService method adminListsTest.

@Test
public void adminListsTest() {
    // try with non-admin
    AdminListsHolder info = groupingAssignmentService.adminLists(username[0]);
    assertNotNull(info);
    assertEquals(info.getAllGroupings().size(), 0);
    assertEquals(info.getAdminGroup().getMembers().size(), 0);
    assertEquals(info.getAdminGroup().getUsernames().size(), 0);
    assertEquals(info.getAdminGroup().getNames().size(), 0);
    assertEquals(info.getAdminGroup().getUuids().size(), 0);
}
Also used : AdminListsHolder(edu.hawaii.its.api.type.AdminListsHolder) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

AdminListsHolder (edu.hawaii.its.api.type.AdminListsHolder)5 Test (org.junit.Test)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 WithMockUhUser (edu.hawaii.its.groupings.controller.WithMockUhUser)2 Group (edu.hawaii.its.api.type.Group)1 Grouping (edu.hawaii.its.api.type.Grouping)1 WsGetAttributeAssignmentsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults)1 WsGroup (edu.internet2.middleware.grouperClient.ws.beans.WsGroup)1 ArrayList (java.util.ArrayList)1