use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class MemberAttributeServiceTest method removeOwnershipTest.
@Test
public void removeOwnershipTest() {
GroupingsServiceResult randomUserRemoves;
try {
// non-owner/non-admin tries to remove ownership
randomUserRemoves = memberAttributeService.removeOwnership(GROUPING_0_PATH, users.get(1).getUsername(), users.get(1).getUsername());
} catch (GroupingsServiceResultException gsre) {
randomUserRemoves = gsre.getGsr();
}
assertTrue(randomUserRemoves.getResultCode().startsWith(FAILURE));
// add owner for owner to remove
membershipService.addGroupMemberByUsername(users.get(0).getUsername(), GROUPING_0_OWNERS_PATH, users.get(1).getUsername());
// owner tries to remove other ownership
GroupingsServiceResult ownerRemoves = memberAttributeService.removeOwnership(GROUPING_0_PATH, users.get(0).getUsername(), users.get(1).getUsername());
assertEquals(SUCCESS, ownerRemoves.getResultCode());
// try to remove ownership from user that is not an owner
GroupingsServiceResult ownerRemovesNonOwner = memberAttributeService.removeOwnership(GROUPING_0_PATH, users.get(0).getUsername(), users.get(1).getUsername());
assertEquals(SUCCESS, ownerRemovesNonOwner.getResultCode());
// add owner for admin to remove
membershipService.addGroupMemberByUsername(users.get(0).getUsername(), GROUPING_0_OWNERS_PATH, users.get(1).getUsername());
// admin tries to remove ownership
GroupingsServiceResult adminRemoves = memberAttributeService.removeOwnership(GROUPING_0_PATH, ADMIN_USER, users.get(1).getUsername());
assertEquals(adminRemoves.getResultCode(), SUCCESS);
}
use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class MembershipServiceTest method addGroupingMemberbyUsernameTest.
@Test
public void addGroupingMemberbyUsernameTest() {
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.addGroupingMemberByUsername(users.get(0).getUsername(), GROUPING_3_PATH, users.get(2).getUsername());
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).getUsername());
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).getUsername());
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));
}
use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class MembershipServiceTest method removeSelfOptedTest.
@Test
public void removeSelfOptedTest() {
Group group = groupRepository.findByPath(GROUPING_4_EXCLUDE_PATH);
GroupingsServiceResult gsr;
try {
// member is not in group
gsr = membershipService.removeSelfOpted(GROUPING_4_EXCLUDE_PATH, users.get(5).getUsername());
} catch (GroupingsServiceResultException gsre) {
gsr = gsre.getGsr();
}
assertTrue(gsr.getResultCode().startsWith(FAILURE));
// member is not self-opted
gsr = membershipService.removeSelfOpted(GROUPING_4_EXCLUDE_PATH, users.get(4).getUsername());
assertTrue(gsr.getResultCode().startsWith(SUCCESS));
// make member self-opted
Membership membership = membershipRepository.findByPersonAndGroup(users.get(4), group);
membership.setSelfOpted(true);
membershipRepository.save(membership);
// member is self-opted
gsr = membershipService.removeSelfOpted(GROUPING_4_EXCLUDE_PATH, users.get(4).getUsername());
assertTrue(gsr.getResultCode().startsWith(SUCCESS));
}
use of edu.hawaii.its.api.type.GroupingsServiceResult 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));
}
use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class MembershipServiceTest method addAdminTest.
@Test
public void addAdminTest() {
GroupingsServiceResult gsr;
try {
// user is not super user
gsr = membershipService.addAdmin(users.get(9).getUsername(), users.get(9).getUsername());
} catch (GroupingsServiceResultException gsre) {
gsr = gsre.getGsr();
}
assertTrue(gsr.getResultCode().startsWith(FAILURE));
// user is super user
gsr = membershipService.addAdmin(ADMIN_USER, users.get(9).getUsername());
assertEquals(SUCCESS, gsr.getResultCode());
// users.get(9) is already and admin
gsr = membershipService.addAdmin(ADMIN_USER, users.get(9).getUsername());
assertTrue(gsr.getResultCode().startsWith(SUCCESS));
}
Aggregations