Search in sources :

Example 1 with Group

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

Example 2 with Group

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

the class DatabaseSetup method removeExcludedMembers.

private Group removeExcludedMembers(Group basisPlusInclude, Group exclude) {
    List<Person> newBasisPlusInclude = new ArrayList<>(basisPlusInclude.getMembers());
    newBasisPlusInclude.removeAll(exclude.getMembers());
    Group basisPlusIncludeMinusExcludeGroup = new Group();
    basisPlusIncludeMinusExcludeGroup.setMembers(newBasisPlusInclude);
    return basisPlusIncludeMinusExcludeGroup;
}
Also used : Group(edu.hawaii.its.api.type.Group) Person(edu.hawaii.its.api.type.Person)

Example 3 with Group

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

the class DatabaseSetup method setUpMemberships.

private void setUpMemberships() {
    Person grouperAll = new Person();
    grouperAll.setUsername("GrouperAll");
    personRepository.save(grouperAll);
    Iterable<Group> groups = groupRepository.findAll();
    for (Group group : groups) {
        group.addMember(grouperAll);
        groupRepository.save(group);
        for (Person person : group.getMembers()) {
            Membership membership = new Membership(person, group);
            membershipRepository.save(membership);
        }
    }
    Iterable<Grouping> groupings = groupingRepository.findAll();
    for (Grouping grouping : groupings) {
        Membership allExclude = membershipRepository.findByPersonAndGroup(grouperAll, grouping.getExclude());
        Membership allInclude = membershipRepository.findByPersonAndGroup(grouperAll, grouping.getInclude());
        Membership allComposite = membershipRepository.findByPersonAndGroup(grouperAll, grouping.getComposite());
        if (grouping.isOptOutOn()) {
            allComposite.setOptOutEnabled(true);
            allExclude.setOptInEnabled(true);
            allExclude.setOptOutEnabled(true);
        }
        if (grouping.isOptInOn()) {
            allComposite.setOptInEnabled(true);
            allInclude.setOptInEnabled(true);
            allInclude.setOptOutEnabled(true);
        }
        membershipRepository.save(allComposite);
        membershipRepository.save(allExclude);
        membershipRepository.save(allInclude);
    }
}
Also used : Group(edu.hawaii.its.api.type.Group) Membership(edu.hawaii.its.api.type.Membership) Grouping(edu.hawaii.its.api.type.Grouping) Person(edu.hawaii.its.api.type.Person)

Example 4 with Group

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

the class GroupAttributeServiceTest method setup.

@Before
public void setup() {
    new DatabaseSetup(personRepository, groupRepository, groupingRepository, membershipRepository);
    admins.add(ADMIN_PERSON);
    adminGroup = new Group(GROUPING_ADMINS, admins);
    personRepository.save(ADMIN_PERSON);
    groupRepository.save(adminGroup);
    admins.add(APP_PERSON);
    appGroup = new Group(GROUPING_APPS, apps);
    personRepository.save(APP_PERSON);
    groupRepository.save(appGroup);
    for (int i = 0; i < 100; i++) {
        String name = NAME + i;
        String uuid = UUID + i;
        String username = USERNAME + i;
        Person person = new Person(name, uuid, username);
        users.add(person);
        WsSubjectLookup lookup = new WsSubjectLookup(null, null, username);
        lookups.add(lookup);
    }
}
Also used : Group(edu.hawaii.its.api.type.Group) WsSubjectLookup(edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup) Person(edu.hawaii.its.api.type.Person) Before(org.junit.Before)

Example 5 with Group

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

the class GroupingAssignmentServiceTest method groupingsOptedOutOfTest.

@Test
public void groupingsOptedOutOfTest() {
    String user1 = users.get(1).getUsername();
    Iterable<Group> groups = groupRepository.findByMembersUsername(user1);
    List<String> groupPaths = new ArrayList<>();
    for (Group group : groups) {
        groupPaths.add(group.getPath());
    }
    List<Grouping> groupingsOptedOutOf = groupingAssignmentService.groupingsOptedOutOf(user1, groupPaths);
    // starts with no groupings out of
    assertEquals(0, groupingsOptedOutOf.size());
    // opt out of a grouping
    membershipService.optOut(user1, GROUPING_1_PATH);
    groups = groupRepository.findByMembersUsername(user1);
    groupPaths = new ArrayList<>();
    for (Group group : groups) {
        groupPaths.add(group.getPath());
    }
    groupingsOptedOutOf = groupingAssignmentService.groupingsOptedOutOf(user1, groupPaths);
    assertEquals(1, groupingsOptedOutOf.size());
    // opt out of another grouping
    membershipService.optOut(user1, GROUPING_3_PATH);
    groups = groupRepository.findByMembersUsername(user1);
    groupPaths = new ArrayList<>();
    for (Group group : groups) {
        groupPaths.add(group.getPath());
    }
    groupingsOptedOutOf = groupingAssignmentService.groupingsOptedOutOf(user1, groupPaths);
    assertEquals(2, groupingsOptedOutOf.size());
    // opt into a grouping
    membershipService.optIn(user1, GROUPING_3_PATH);
    groups = groupRepository.findByMembersUsername(user1);
    groupPaths = new ArrayList<>();
    for (Group group : groups) {
        groupPaths.add(group.getPath());
    }
    groupingsOptedOutOf = groupingAssignmentService.groupingsOptedOutOf(user1, groupPaths);
    assertEquals(1, groupingsOptedOutOf.size());
    // opt into another grouping
    membershipService.optIn(user1, GROUPING_1_PATH);
    groups = groupRepository.findByMembersUsername(user1);
    groupPaths = new ArrayList<>();
    for (Group group : groups) {
        groupPaths.add(group.getPath());
    }
    groupingsOptedOutOf = groupingAssignmentService.groupingsOptedOutOf(user1, groupPaths);
    assertEquals(0, groupingsOptedOutOf.size());
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) ArrayList(java.util.ArrayList) Grouping(edu.hawaii.its.api.type.Grouping) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Group (edu.hawaii.its.api.type.Group)40 WsGroup (edu.internet2.middleware.grouperClient.ws.beans.WsGroup)23 Person (edu.hawaii.its.api.type.Person)21 Grouping (edu.hawaii.its.api.type.Grouping)13 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)10 WsSubjectLookup (edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup)9 Before (org.junit.Before)8 WsResultMeta (edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta)7 Membership (edu.hawaii.its.api.type.Membership)6 WsGetMembersResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults)4 WsSubject (edu.internet2.middleware.grouperClient.ws.beans.WsSubject)4 WsMembership (edu.internet2.middleware.grouperClient.ws.beans.WsMembership)3 AdminListsHolder (edu.hawaii.its.api.type.AdminListsHolder)2 WsGetAttributeAssignmentsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults)2 WsGetGroupsResult (edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResult)2 WsGetGroupsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResults)2 WsGetMembersResult (edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResult)2 GroupingAssignment (edu.hawaii.its.api.type.GroupingAssignment)1