Search in sources :

Example 6 with Group

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

the class GroupingAssignmentServiceTest method setup.

@Before
public void setup() {
    new DatabaseSetup(personRepository, groupRepository, groupingRepository, membershipRepository);
    admins.add(ADMIN_PERSON);
    Group adminGroup = new Group(GROUPING_ADMINS, admins);
    personRepository.save(ADMIN_PERSON);
    groupRepository.save(adminGroup);
    admins.add(APP_PERSON);
    Group 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 : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) 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 7 with Group

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

the class GroupingAssignmentServiceTest method groupingsOwnedTest.

@Test
public void groupingsOwnedTest() {
    Iterable<Group> groupsIn = groupRepository.findByMembersUsername(users.get(0).getUsername());
    List<String> groupPaths = new ArrayList<>();
    for (Group group : groupsIn) {
        groupPaths.add(group.getPath());
    }
    List<Grouping> groupingsOwned = groupingAssignmentService.groupingsOwned(groupPaths);
    for (int i = 0; i < groupingsOwned.size(); i++) {
        assertTrue(groupingsOwned.get(i).getPath().equals(PATH_ROOT + i));
    }
}
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)

Example 8 with Group

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

the class MemberAttributeServiceTest method checkSelfOptedTest.

@Test
public void checkSelfOptedTest() {
    // user is not in group
    boolean selfOpted = memberAttributeService.isSelfOpted(GROUPING_0_INCLUDE_PATH, users.get(2).getUsername());
    assertFalse(selfOpted);
    // user has not self opted
    selfOpted = memberAttributeService.isSelfOpted(GROUPING_0_INCLUDE_PATH, users.get(5).getUsername());
    assertFalse(selfOpted);
    // user has self opted
    Person person = personRepository.findByUsername(users.get(5).getUsername());
    Group group = groupRepository.findByPath(GROUPING_0_INCLUDE_PATH);
    Membership membership = membershipRepository.findByPersonAndGroup(person, group);
    membership.setSelfOpted(true);
    membershipRepository.save(membership);
    selfOpted = memberAttributeService.isSelfOpted(GROUPING_0_INCLUDE_PATH, users.get(5).getUsername());
    assertTrue(selfOpted);
}
Also used : Group(edu.hawaii.its.api.type.Group) Membership(edu.hawaii.its.api.type.Membership) Person(edu.hawaii.its.api.type.Person) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with Group

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

the class TestMembershipService method getMembersTest.

@Test
public void getMembersTest() {
    Group group = groupingAssignmentService.getMembers(username[0], GROUPING);
    List<String> usernames = group.getUsernames();
    assertTrue(usernames.contains(username[0]));
    assertTrue(usernames.contains(username[1]));
    assertTrue(usernames.contains(username[2]));
    assertFalse(usernames.contains(username[3]));
    assertTrue(usernames.contains(username[4]));
    assertTrue(usernames.contains(username[5]));
}
Also used : Group(edu.hawaii.its.api.type.Group) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 10 with Group

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

the class GrouperFactoryServiceImplLocal method makeWsAddMemberResults.

@Override
public WsAddMemberResults makeWsAddMemberResults(String group, WsSubjectLookup lookup, Person personToAdd) {
    Person newGroupMember;
    WsAddMemberResults wsAddMemberResults = new WsAddMemberResults();
    WsResultMeta wsResultMeta = new WsResultMeta();
    wsResultMeta.setResultCode(SUCCESS);
    wsAddMemberResults.setResultMetadata(wsResultMeta);
    Grouping grouping = groupingRepository.findByIncludePathOrExcludePathOrCompositePathOrOwnersPath(group, group, group, group);
    if (personToAdd.getUsername() != null) {
        newGroupMember = personRepository.findByUsername(personToAdd.getUsername());
    } else {
        newGroupMember = personRepository.findByUuid(personToAdd.getUuid());
    }
    if (grouping == null) {
        Group groupToAddTo = groupRepository.findByPath(group);
        addMember(groupToAddTo, newGroupMember);
    } else {
        boolean inBasis = grouping.getBasis().isMember(newGroupMember);
        boolean inExclude = grouping.getExclude().isMember(newGroupMember);
        boolean inInclude = grouping.getInclude().isMember(newGroupMember);
        if (group.endsWith(OWNERS)) {
            addMember(grouping.getOwners(), newGroupMember);
        } else if (group.endsWith(EXCLUDE)) {
            if (inBasis) {
                addMember(grouping.getExclude(), newGroupMember);
            } else if (inInclude) {
                deleteMember(grouping.getInclude(), newGroupMember);
            }
        } else if (group.endsWith(INCLUDE)) {
            if (inExclude) {
                deleteMember(grouping.getExclude(), newGroupMember);
            } else if (!inBasis) {
                addMember(grouping.getInclude(), newGroupMember);
            }
        }
        grouping = groupingRepository.findByPath(grouping.getPath());
        Group composite = buildComposite(grouping.getInclude(), grouping.getExclude(), grouping.getBasis(), grouping.getPath());
        groupRepository.save(composite);
    }
    return wsAddMemberResults;
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) WsResultMeta(edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta) Grouping(edu.hawaii.its.api.type.Grouping) Person(edu.hawaii.its.api.type.Person) WsAddMemberResults(edu.internet2.middleware.grouperClient.ws.beans.WsAddMemberResults)

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