use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class GroupITCase method bulkMembersAction.
@Test
public void bulkMembersAction() throws InterruptedException {
// 1. create group without resources
GroupTO groupTO = getBasicSampleTO("forProvision");
groupTO = createGroup(groupTO).getEntity();
// 2. create user with such group assigned
UserTO userTO = UserITCase.getUniqueSampleTO("forProvision@syncope.apache.org");
userTO.getMemberships().add(new MembershipTO.Builder().group(groupTO.getKey()).build());
userTO = createUser(userTO).getEntity();
// 3. modify the group by assiging the LDAP resource
GroupPatch groupPatch = new GroupPatch();
groupPatch.setKey(groupTO.getKey());
groupPatch.getResources().add(new StringPatchItem.Builder().value(RESOURCE_NAME_LDAP).build());
ProvisioningResult<GroupTO> groupUpdateResult = updateGroup(groupPatch);
groupTO = groupUpdateResult.getEntity();
PropagationStatus propStatus = groupUpdateResult.getPropagationStatuses().get(0);
assertEquals(RESOURCE_NAME_LDAP, propStatus.getResource());
assertEquals(PropagationTaskExecStatus.SUCCESS, propStatus.getStatus());
// 4. verify that the user above is not found on LDAP
try {
resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.USER.name(), userTO.getKey());
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.NotFound, e.getType());
}
try {
// 5. bulk provision group members
ExecTO exec = groupService.bulkMembersAction(groupTO.getKey(), BulkMembersActionType.PROVISION);
assertNotNull(exec.getRefKey());
int i = 0;
int maxit = 50;
// wait for task exec completion (executions incremented)
SchedTaskTO taskTO;
do {
Thread.sleep(1000);
taskTO = taskService.read(TaskType.SCHEDULED, exec.getRefKey(), true);
assertNotNull(taskTO);
assertNotNull(taskTO.getExecutions());
i++;
} while (taskTO.getExecutions().isEmpty() && i < maxit);
assertFalse(taskTO.getExecutions().isEmpty());
assertEquals(TaskJob.Status.SUCCESS.name(), taskTO.getExecutions().get(0).getStatus());
// 6. verify that the user above is now fond on LDAP
ConnObjectTO userOnLdap = resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.USER.name(), userTO.getKey());
assertNotNull(userOnLdap);
} finally {
groupService.delete(groupTO.getKey());
userService.delete(userTO.getKey());
}
}
use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class GroupITCase method provision.
@Test
public void provision() {
GroupTO groupTO = getSampleTO("provision");
groupTO.getResources().clear();
try {
groupTO = createGroup(groupTO).getEntity();
assertNotNull(groupTO);
try {
resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey());
fail("This should not happen");
} catch (Exception e) {
assertNotNull(e);
}
AssociationPatch associationPatch = new AssociationPatch.Builder().key(groupTO.getKey()).action(ResourceAssociationAction.PROVISION).resource(RESOURCE_NAME_LDAP).build();
assertNotNull(groupService.associate(associationPatch).readEntity(BulkActionResult.class));
groupTO = groupService.read(groupTO.getKey());
assertTrue(groupTO.getResources().isEmpty());
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey()));
} finally {
if (groupTO.getKey() != null) {
groupService.delete(groupTO.getKey());
}
}
}
use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class GroupITCase method getSampleTO.
public static GroupTO getSampleTO(final String name) {
GroupTO groupTO = getBasicSampleTO(name);
groupTO.getPlainAttrs().add(attrTO("icon", "anIcon"));
groupTO.getResources().add(RESOURCE_NAME_LDAP);
return groupTO;
}
use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class GroupITCase method createWithInternationalCharacters.
@Test
public void createWithInternationalCharacters() {
GroupTO groupTO = getSampleTO("räksmörgås");
groupTO = createGroup(groupTO).getEntity();
assertNotNull(groupTO);
}
use of org.apache.syncope.common.lib.to.GroupTO in project syncope by apache.
the class GroupITCase method typeExtensions.
@Test
public void typeExtensions() {
TypeExtensionTO typeExtension = new TypeExtensionTO();
typeExtension.setAnyType(AnyTypeKind.USER.name());
typeExtension.getAuxClasses().add("csv");
GroupTO groupTO = getBasicSampleTO("typeExtensions");
groupTO.getTypeExtensions().add(typeExtension);
groupTO = createGroup(groupTO).getEntity();
assertNotNull(groupTO);
assertEquals(1, groupTO.getTypeExtensions().size());
assertEquals(1, groupTO.getTypeExtension(AnyTypeKind.USER.name()).get().getAuxClasses().size());
assertTrue(groupTO.getTypeExtension(AnyTypeKind.USER.name()).get().getAuxClasses().contains("csv"));
typeExtension = new TypeExtensionTO();
typeExtension.setAnyType(AnyTypeKind.USER.name());
typeExtension.getAuxClasses().add("csv");
typeExtension.getAuxClasses().add("other");
GroupPatch groupPatch = new GroupPatch();
groupPatch.setKey(groupTO.getKey());
groupPatch.getTypeExtensions().add(typeExtension);
groupTO = updateGroup(groupPatch).getEntity();
assertNotNull(groupTO);
assertEquals(1, groupTO.getTypeExtensions().size());
assertEquals(2, groupTO.getTypeExtension(AnyTypeKind.USER.name()).get().getAuxClasses().size());
assertTrue(groupTO.getTypeExtension(AnyTypeKind.USER.name()).get().getAuxClasses().contains("csv"));
assertTrue(groupTO.getTypeExtension(AnyTypeKind.USER.name()).get().getAuxClasses().contains("other"));
}
Aggregations