Search in sources :

Example 36 with Grouping

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

the class MembershipServiceTest method addGroupingMemberbyUuidTest.

@Test
public void addGroupingMemberbyUuidTest() {
    Iterable<Grouping> group = groupingRepository.findAll();
    List<GroupingsServiceResult> listGsr;
    GroupingsServiceResult gsr;
    // Base test
    // Remove person who's not in composite from exclude and return SUCCESS
    listGsr = membershipService.addGroupingMemberByUuid(users.get(0).getUsername(), GROUPING_3_PATH, users.get(3).getUuid());
    assertTrue(listGsr.get(0).getResultCode().startsWith(SUCCESS));
    // todo Case where !inComposite && !inBasis is impossible w/ current db
    // In composite
    listGsr = membershipService.addGroupingMemberByUuid(users.get(0).getUsername(), GROUPING_3_PATH, users.get(5).getUuid());
    assertTrue(listGsr.get(0).getResultCode().startsWith(SUCCESS));
    // Test if user is not an owner
    try {
        listGsr = membershipService.addGroupingMemberByUuid(users.get(5).getUsername(), GROUPING_3_PATH, users.get(3).getUuid());
        assertTrue(listGsr.get(0).getResultCode().startsWith(SUCCESS));
    } catch (GroupingsServiceResultException gsre) {
        gsr = gsre.getGsr();
    }
    // Test if user is admin
    listGsr = membershipService.addGroupingMemberByUuid(ADMIN_USER, GROUPING_3_PATH, users.get(3).getUuid());
    assertTrue(listGsr.get(0).getResultCode().startsWith(SUCCESS));
}
Also used : GroupingsServiceResultException(edu.hawaii.its.api.type.GroupingsServiceResultException) GroupingsServiceResult(edu.hawaii.its.api.type.GroupingsServiceResult) Grouping(edu.hawaii.its.api.type.Grouping) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 37 with Grouping

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

the class MembershipServiceTest method addMembersByUuid.

@Test
public void addMembersByUuid() {
    // add all uuids
    List<String> uuids = new ArrayList<>();
    for (Person user : users) {
        uuids.add(user.getUuid());
    }
    Grouping grouping = groupingRepository.findByPath(GROUPING_3_PATH);
    // check how many members are in the basis
    int numberOfBasisMembers = grouping.getBasis().getMembers().size();
    // try to put all users into exclude group
    membershipService.addGroupMembersByUuid(users.get(0).getUsername(), GROUPING_3_EXCLUDE_PATH, uuids);
    grouping = groupingRepository.findByPath(GROUPING_3_PATH);
    // there should be no real members in composite, but it should still have the 'grouperAll' member
    assertEquals(1, grouping.getComposite().getMembers().size());
    // only the users in the basis should have been added to the exclude group
    assertEquals(numberOfBasisMembers, grouping.getExclude().getMembers().size());
    // try to put all users into the include group
    membershipService.addGroupMembersByUuid(users.get(0).getUsername(), GROUPING_3_INCLUDE_PATH, uuids);
    grouping = groupingRepository.findByPath(GROUPING_3_PATH);
    // all members should be in the group ( - 1 for 'grouperAll' in composite);
    assertEquals(uuids.size(), grouping.getComposite().getMembers().size() - 1);
    // members in basis should not have been added to the include group ( + 2 for 'grouperAll' in both groups)
    assertEquals(uuids.size() - numberOfBasisMembers + 2, grouping.getInclude().getMembers().size());
}
Also used : ArrayList(java.util.ArrayList) Grouping(edu.hawaii.its.api.type.Grouping) Person(edu.hawaii.its.api.type.Person) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 38 with Grouping

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

the class TestGroupingAssignmentService method getGroupingTest.

@Test
public void getGroupingTest() {
    Grouping grouping = groupingAssignmentService.getGrouping(GROUPING, username[4]);
    assertEquals(grouping.getPath(), "");
    assertEquals(grouping.getName(), "");
    assertEquals(grouping.getOwners().getMembers().size(), 0);
    assertEquals(grouping.getInclude().getMembers().size(), 0);
    assertEquals(grouping.getExclude().getMembers().size(), 0);
    assertEquals(grouping.getBasis().getMembers().size(), 0);
    assertEquals(grouping.getComposite().getMembers().size(), 0);
    grouping = groupingAssignmentService.getGrouping(GROUPING, username[0]);
    assertEquals(grouping.getPath(), GROUPING);
    assertTrue(grouping.getBasis().getUsernames().contains(username[3]));
    assertTrue(grouping.getBasis().getUsernames().contains(username[4]));
    assertTrue(grouping.getBasis().getUsernames().contains(username[5]));
    assertTrue(grouping.getComposite().getUsernames().contains(username[0]));
    assertTrue(grouping.getComposite().getUsernames().contains(username[1]));
    assertTrue(grouping.getComposite().getUsernames().contains(username[2]));
    assertTrue(grouping.getComposite().getUsernames().contains(username[4]));
    assertTrue(grouping.getComposite().getUsernames().contains(username[5]));
    assertTrue(grouping.getExclude().getUsernames().contains(username[3]));
    assertTrue(grouping.getInclude().getUsernames().contains(username[0]));
    assertTrue(grouping.getInclude().getUsernames().contains(username[1]));
    assertTrue(grouping.getInclude().getUsernames().contains(username[2]));
    assertTrue(grouping.getOwners().getUsernames().contains(username[0]));
}
Also used : Grouping(edu.hawaii.its.api.type.Grouping) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 39 with Grouping

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

the class TestGroupingAssignmentService method groupingsInTest.

@Test
public void groupingsInTest() {
    GroupingAssignment groupingAssignment = groupingAssignmentService.getGroupingAssignment(username[0]);
    boolean inGrouping = false;
    for (Grouping grouping : groupingAssignment.getGroupingsIn()) {
        if (grouping.getPath().contains(GROUPING)) {
            inGrouping = true;
            break;
        }
    }
    assertTrue(inGrouping);
    inGrouping = false;
    groupingAssignment = groupingAssignmentService.getGroupingAssignment(username[3]);
    for (Grouping grouping : groupingAssignment.getGroupingsIn()) {
        if (grouping.getPath().contains(GROUPING)) {
            inGrouping = true;
            break;
        }
    }
    assertFalse(inGrouping);
}
Also used : Grouping(edu.hawaii.its.api.type.Grouping) GroupingAssignment(edu.hawaii.its.api.type.GroupingAssignment) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 40 with Grouping

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

the class GrouperFactoryServiceImplLocal method makeWsAssignAttributesResultsForGroup.

@Override
public WsAssignAttributesResults makeWsAssignAttributesResultsForGroup(WsSubjectLookup lookup, String attributeAssignType, String attributeAssignOperation, String attributeDefNameName, String ownerGroupName) {
    WsAssignAttributesResults wsAssignAttributesResults;
    Grouping grouping = groupingRepository.findByPath(ownerGroupName);
    Person person = personRepository.findByUsername(lookup.getSubjectIdentifier());
    if (grouping.getOwners().isMember(person)) {
        wsAssignAttributesResults = makeWsAssignAttributesResultsForGroup(attributeAssignType, attributeAssignOperation, attributeDefNameName, ownerGroupName);
    } else {
        wsAssignAttributesResults = new WsAssignAttributesResults();
        WsResultMeta wsResultMeta = new WsResultMeta();
        wsResultMeta.setResultCode(FAILURE);
        wsAssignAttributesResults.setResultMetadata(wsResultMeta);
    }
    return wsAssignAttributesResults;
}
Also used : WsAssignAttributesResults(edu.internet2.middleware.grouperClient.ws.beans.WsAssignAttributesResults) Grouping(edu.hawaii.its.api.type.Grouping) WsResultMeta(edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta) Person(edu.hawaii.its.api.type.Person)

Aggregations

Grouping (edu.hawaii.its.api.type.Grouping)45 Test (org.junit.Test)28 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)28 ArrayList (java.util.ArrayList)14 Group (edu.hawaii.its.api.type.Group)13 GroupingAssignment (edu.hawaii.its.api.type.GroupingAssignment)11 WsGroup (edu.internet2.middleware.grouperClient.ws.beans.WsGroup)11 WithMockUhUser (edu.hawaii.its.groupings.controller.WithMockUhUser)9 Person (edu.hawaii.its.api.type.Person)8 GroupingsServiceResult (edu.hawaii.its.api.type.GroupingsServiceResult)6 GroupingsServiceResultException (edu.hawaii.its.api.type.GroupingsServiceResultException)6 WsAttributeAssign (edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign)5 WsResultMeta (edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta)5 WsAssignAttributesResults (edu.internet2.middleware.grouperClient.ws.beans.WsAssignAttributesResults)3 WsGetAttributeAssignmentsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults)3 AdminListsHolder (edu.hawaii.its.api.type.AdminListsHolder)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Membership (edu.hawaii.its.api.type.Membership)1 StemScope (edu.internet2.middleware.grouperClient.ws.StemScope)1 WsAddMemberResults (edu.internet2.middleware.grouperClient.ws.beans.WsAddMemberResults)1