use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestMemberAttributeService method assignRemoveOwnershipTest.
@Test
public void assignRemoveOwnershipTest() {
// expect to fail
GroupingsServiceResult assignOwnershipFail;
GroupingsServiceResult removeOwnershipFail;
assertTrue(memberAttributeService.isOwner(GROUPING, username[0]));
assertFalse(memberAttributeService.isOwner(GROUPING, username[1]));
assertFalse(memberAttributeService.isOwner(GROUPING, username[2]));
try {
assignOwnershipFail = memberAttributeService.assignOwnership(GROUPING, username[1], username[1]);
} catch (GroupingsServiceResultException gsre) {
assignOwnershipFail = gsre.getGsr();
}
assertFalse(memberAttributeService.isOwner(GROUPING, username[1]));
assertTrue(assignOwnershipFail.getResultCode().startsWith(FAILURE));
GroupingsServiceResult assignOwnershipSuccess = memberAttributeService.assignOwnership(GROUPING, username[0], username[1]);
assertTrue(memberAttributeService.isOwner(GROUPING, username[1]));
assertTrue(assignOwnershipSuccess.getResultCode().startsWith(SUCCESS));
try {
removeOwnershipFail = memberAttributeService.removeOwnership(GROUPING, username[2], username[1]);
} catch (GroupingsServiceResultException gsre) {
removeOwnershipFail = gsre.getGsr();
}
assertTrue(memberAttributeService.isOwner(GROUPING, username[1]));
assertTrue(removeOwnershipFail.getResultCode().startsWith(FAILURE));
GroupingsServiceResult removeOwnershipSuccess = memberAttributeService.removeOwnership(GROUPING, username[0], username[1]);
assertFalse(memberAttributeService.isOwner(GROUPING, username[1]));
assertTrue(removeOwnershipSuccess.getResultCode().startsWith(SUCCESS));
// have an owner remove itself
assignOwnershipSuccess = memberAttributeService.assignOwnership(GROUPING, username[0], username[1]);
assertTrue(memberAttributeService.isOwner(GROUPING, username[1]));
removeOwnershipSuccess = memberAttributeService.removeOwnership(GROUPING, username[1], username[1]);
assertFalse(memberAttributeService.isOwner(GROUPING, username[1]));
}
use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestMembershipService method deleteMemberAsTest.
@Test
public void deleteMemberAsTest() {
// username[2] is in composite and include, not basis or exclude
assertTrue(memberAttributeService.isMember(GROUPING, username[2]));
assertTrue(memberAttributeService.isMember(GROUPING_INCLUDE, username[2]));
assertFalse(memberAttributeService.isMember(GROUPING_BASIS, username[2]));
assertFalse(memberAttributeService.isMember(GROUPING_EXCLUDE, username[2]));
// username[3] is in basis and exclude, not composite or include
assertTrue(memberAttributeService.isMember(GROUPING_BASIS, username[3]));
assertTrue(memberAttributeService.isMember(GROUPING_EXCLUDE, username[3]));
assertFalse(memberAttributeService.isMember(GROUPING, username[3]));
assertFalse(memberAttributeService.isMember(GROUPING_INCLUDE, username[3]));
// delete username[3] from exclude
GroupingsServiceResult deleteMember1 = membershipService.deleteGroupMemberByUsername(username[0], GROUPING_EXCLUDE, username[3]);
// deletion was successful
assertEquals(deleteMember1.getResultCode(), SUCCESS);
// username[3] is no longer in the exclude
assertFalse(memberAttributeService.isMember(GROUPING_EXCLUDE, username[3]));
// delete username[2] from include
GroupingsServiceResult deleteMember2 = membershipService.deleteGroupMemberByUsername(username[0], GROUPING_INCLUDE, username[2]);
// deletion was successful
assertEquals(deleteMember2.getResultCode(), SUCCESS);
// username[2] is no longer in composite or include
assertFalse(memberAttributeService.isMember(GROUPING, username[2]));
assertFalse(memberAttributeService.isMember(GROUPING_INCLUDE, username[2]));
// test when not in group
deleteMember1 = membershipService.deleteGroupMemberByUsername(username[0], GROUPING_EXCLUDE, username[3]);
deleteMember2 = membershipService.deleteGroupMemberByUsername(username[0], GROUPING_INCLUDE, username[2]);
// results are successful because the end result is the same
assertTrue(deleteMember1.getResultCode().startsWith(SUCCESS));
assertTrue(deleteMember2.getResultCode().startsWith(SUCCESS));
}
use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestMembershipService method updateLastModifiedTest.
@Test
public void updateLastModifiedTest() {
// Test is accurate to the minute, and if checks to see if the current
// time gets added to the lastModified attribute of a group if the
// minute happens to change in between getting the time and setting
// the time, the test will fail.
final String group = GROUPING_INCLUDE;
GroupingsServiceResult gsr = membershipService.updateLastModified(group);
String dateStr = gsr.getAction().split(" to time ")[1];
WsGetAttributeAssignmentsResults assignments = groupAttributeService.attributeAssignmentsResults(ASSIGN_TYPE_GROUP, group, YYYYMMDDTHHMM);
String assignedValue = assignments.getWsAttributeAssigns()[0].getWsAttributeAssignValues()[0].getValueSystem();
assertEquals(dateStr, assignedValue);
}
use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class HelperServiceImpl method makeGroupingsServiceResult.
// makes a groupingsServiceResult with the resultCode and the action string
@Override
public GroupingsServiceResult makeGroupingsServiceResult(String resultCode, String action) {
GroupingsServiceResult groupingsServiceResult = new GroupingsServiceResult();
groupingsServiceResult.setAction(action);
groupingsServiceResult.setResultCode(resultCode);
if (groupingsServiceResult.getResultCode().startsWith(FAILURE)) {
throw new GroupingsServiceResultException(groupingsServiceResult);
}
return groupingsServiceResult;
}
use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class MemberAttributeServiceImpl method removeOwnership.
// remove ownership of a grouping from a current owner
// todo change ownerUsername to "actor"?
@Override
public GroupingsServiceResult removeOwnership(String groupingPath, String ownerUsername, String ownerToRemove) {
logger.info("removeOwnership; grouping: " + groupingPath + "; username: " + ownerUsername + "; ownerToRemove: " + ownerToRemove + ";");
GroupingsServiceResult ownershipResults;
String action = "remove ownership of " + groupingPath + " from " + ownerToRemove;
if (isOwner(groupingPath, ownerUsername) || isAdmin(ownerUsername)) {
WsSubjectLookup lookup = grouperFS.makeWsSubjectLookup(ownerUsername);
WsDeleteMemberResults memberResults = grouperFS.makeWsDeleteMemberResults(groupingPath + OWNERS, lookup, ownerToRemove);
ownershipResults = hs.makeGroupingsServiceResult(memberResults, action);
return ownershipResults;
}
ownershipResults = hs.makeGroupingsServiceResult(FAILURE + ", " + ownerUsername + " does not own " + groupingPath, action);
return ownershipResults;
}
Aggregations