use of org.apache.syncope.common.lib.to.ConnObjectTO in project syncope by apache.
the class GroupITCase method create.
@Test
public void create() {
GroupTO groupTO = getSampleTO("lastGroup");
groupTO.getVirAttrs().add(attrTO("rvirtualdata", "rvirtualvalue"));
groupTO.setGroupOwner("f779c0d4-633b-4be5-8f57-32eb478a3ca5");
groupTO = createGroup(groupTO).getEntity();
assertNotNull(groupTO);
assertNotNull(groupTO.getVirAttr("rvirtualdata").get().getValues());
assertFalse(groupTO.getVirAttr("rvirtualdata").get().getValues().isEmpty());
assertEquals("rvirtualvalue", groupTO.getVirAttr("rvirtualdata").get().getValues().get(0));
assertTrue(groupTO.getResources().contains(RESOURCE_NAME_LDAP));
ConnObjectTO connObjectTO = resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey());
assertNotNull(connObjectTO);
assertNotNull(connObjectTO.getAttr("owner"));
// SYNCOPE-515: remove ownership
GroupPatch groupPatch = new GroupPatch();
groupPatch.setKey(groupTO.getKey());
groupPatch.setGroupOwner(new StringReplacePatchItem());
assertNull(updateGroup(groupPatch).getEntity().getGroupOwner());
}
use of org.apache.syncope.common.lib.to.ConnObjectTO 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.ConnObjectTO in project syncope by apache.
the class UserITCase method suspendReactivateOnResource.
@Test
public void suspendReactivateOnResource() {
// Assert resources are present
ResourceTO dbTable = resourceService.read(RESOURCE_NAME_TESTDB);
assertNotNull(dbTable);
ResourceTO ldap = resourceService.read(RESOURCE_NAME_LDAP);
assertNotNull(ldap);
// Create user with reference to resources
UserTO userTO = getUniqueSampleTO("suspreactonresource@syncope.apache.org");
userTO.getMemberships().clear();
userTO.getResources().clear();
userTO.getResources().add(RESOURCE_NAME_TESTDB);
userTO.getResources().add(RESOURCE_NAME_LDAP);
userTO = createUser(userTO).getEntity();
assertNotNull(userTO);
assertEquals(FlowableDetector.isFlowableEnabledForUsers(syncopeService) ? "active" : "created", userTO.getStatus());
String userKey = userTO.getKey();
// Suspend with effect on syncope, ldap and db => user should be suspended in syncope and all resources
StatusPatch statusPatch = new StatusPatch.Builder().key(userKey).type(StatusPatchType.SUSPEND).onSyncope(true).resources(RESOURCE_NAME_TESTDB, RESOURCE_NAME_LDAP).build();
userTO = userService.status(statusPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertNotNull(userTO);
assertEquals("suspended", userTO.getStatus());
ConnObjectTO connObjectTO = resourceService.readConnObject(RESOURCE_NAME_TESTDB, AnyTypeKind.USER.name(), userKey);
assertFalse(getBooleanAttribute(connObjectTO, OperationalAttributes.ENABLE_NAME));
connObjectTO = resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.USER.name(), userKey);
assertNotNull(connObjectTO);
// Suspend and reactivate only on ldap => db and syncope should still show suspended
statusPatch = new StatusPatch.Builder().key(userKey).type(StatusPatchType.SUSPEND).onSyncope(false).resources(RESOURCE_NAME_LDAP).build();
userService.status(statusPatch);
statusPatch.setType(StatusPatchType.REACTIVATE);
userTO = userService.status(statusPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertNotNull(userTO);
assertEquals("suspended", userTO.getStatus());
connObjectTO = resourceService.readConnObject(RESOURCE_NAME_TESTDB, AnyTypeKind.USER.name(), userKey);
assertFalse(getBooleanAttribute(connObjectTO, OperationalAttributes.ENABLE_NAME));
// Reactivate on syncope and db => syncope and db should show the user as active
statusPatch = new StatusPatch.Builder().key(userKey).type(StatusPatchType.REACTIVATE).onSyncope(true).resources(RESOURCE_NAME_TESTDB).build();
userTO = userService.status(statusPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertNotNull(userTO);
assertEquals("active", userTO.getStatus());
connObjectTO = resourceService.readConnObject(RESOURCE_NAME_TESTDB, AnyTypeKind.USER.name(), userKey);
assertTrue(getBooleanAttribute(connObjectTO, OperationalAttributes.ENABLE_NAME));
}
use of org.apache.syncope.common.lib.to.ConnObjectTO in project syncope by apache.
the class UserIssuesITCase method issueSYNCOPE267.
@Test
public void issueSYNCOPE267() {
// ----------------------------------
// create user and check virtual attribute value propagation
// ----------------------------------
UserTO userTO = UserITCase.getUniqueSampleTO("syncope267@apache.org");
userTO.getVirAttrs().add(attrTO("virtualdata", "virtualvalue"));
userTO.getResources().clear();
userTO.getResources().add(RESOURCE_NAME_DBVIRATTR);
ProvisioningResult<UserTO> result = createUser(userTO);
assertNotNull(result);
assertFalse(result.getPropagationStatuses().isEmpty());
assertEquals(RESOURCE_NAME_DBVIRATTR, result.getPropagationStatuses().get(0).getResource());
assertEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(0).getStatus());
userTO = result.getEntity();
ConnObjectTO connObjectTO = resourceService.readConnObject(RESOURCE_NAME_DBVIRATTR, AnyTypeKind.USER.name(), userTO.getKey());
assertNotNull(connObjectTO);
assertEquals("virtualvalue", connObjectTO.getAttr("USERNAME").get().getValues().get(0));
// ----------------------------------
userTO = userService.read(userTO.getKey());
assertNotNull(userTO);
assertEquals(1, userTO.getVirAttrs().size());
assertEquals("virtualvalue", userTO.getVirAttrs().iterator().next().getValues().get(0));
}
use of org.apache.syncope.common.lib.to.ConnObjectTO in project syncope by apache.
the class UserIssuesITCase method issueSYNCOPE391.
@Test
public void issueSYNCOPE391() {
// 1. create user on Syncope with null password
UserTO userTO = UserITCase.getUniqueSampleTO("syncope391@syncope.apache.org");
userTO.setPassword(null);
userTO = createUser(userTO, false).getEntity();
assertNotNull(userTO);
assertNull(userTO.getPassword());
// 2. create existing user on csv and check that password on Syncope is null and that password on resource
// doesn't change
userTO = new UserTO();
userTO.setRealm(SyncopeConstants.ROOT_REALM);
userTO.setPassword(null);
userTO.setUsername("syncope391@syncope.apache.org");
userTO.getPlainAttrs().add(attrTO("fullname", "fullname"));
userTO.getPlainAttrs().add(attrTO("firstname", "nome0"));
userTO.getPlainAttrs().add(attrTO("surname", "cognome0"));
userTO.getPlainAttrs().add(attrTO("userId", "syncope391@syncope.apache.org"));
userTO.getPlainAttrs().add(attrTO("email", "syncope391@syncope.apache.org"));
userTO.getAuxClasses().add("csv");
userTO.getResources().add(RESOURCE_NAME_CSV);
userTO = createUser(userTO, false).getEntity();
assertNotNull(userTO);
ConnObjectTO connObjectTO = resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), userTO.getKey());
assertNotNull(connObjectTO);
// check if password has not changed
assertEquals("password0", connObjectTO.getAttr(OperationalAttributes.PASSWORD_NAME).get().getValues().get(0));
assertNull(userTO.getPassword());
// 3. create user with not null password and propagate onto resource-csv, specify not to save password on
// Syncope local storage
userTO = UserITCase.getUniqueSampleTO("syncope391@syncope.apache.org");
userTO.setPassword("passwordTESTNULL1");
userTO.getVirAttrs().clear();
userTO.getAuxClasses().add("csv");
userTO.getResources().add(RESOURCE_NAME_CSV);
userTO = createUser(userTO, false).getEntity();
assertNotNull(userTO);
connObjectTO = resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), userTO.getKey());
assertNotNull(connObjectTO);
// check if password has been propagated and that saved userTO's password is null
assertEquals("passwordTESTNULL1", connObjectTO.getAttr(OperationalAttributes.PASSWORD_NAME).get().getValues().get(0));
assertNull(userTO.getPassword());
// 4. create user and propagate password on resource-csv and on Syncope local storage
userTO = UserITCase.getUniqueSampleTO("syncope391@syncope.apache.org");
userTO.setPassword("passwordTESTNULL1");
userTO.getVirAttrs().clear();
userTO.getAuxClasses().add("csv");
userTO.getResources().add(RESOURCE_NAME_CSV);
// storePassword true by default
userTO = createUser(userTO).getEntity();
assertNotNull(userTO);
connObjectTO = resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), userTO.getKey());
assertNotNull(connObjectTO);
// check if password has been correctly propagated on Syncope and resource-csv as usual
assertEquals("passwordTESTNULL1", connObjectTO.getAttr(OperationalAttributes.PASSWORD_NAME).get().getValues().get(0));
Pair<Map<String, Set<String>>, UserTO> self = clientFactory.create(userTO.getUsername(), "passwordTESTNULL1").self();
assertNotNull(self);
// 4. add password policy to resource with passwordNotStore to false --> must store password
ResourceTO csv = resourceService.read(RESOURCE_NAME_CSV);
assertNotNull(csv);
try {
csv.setPasswordPolicy("55e5de0b-c79c-4e66-adda-251b6fb8579a");
resourceService.update(csv);
csv = resourceService.read(RESOURCE_NAME_CSV);
assertEquals("55e5de0b-c79c-4e66-adda-251b6fb8579a", csv.getPasswordPolicy());
userTO = UserITCase.getUniqueSampleTO("syncope391@syncope.apache.org");
userTO.setPassword(null);
userTO.getVirAttrs().clear();
userTO.getAuxClasses().add("csv");
userTO.getResources().add(RESOURCE_NAME_CSV);
createUser(userTO, false);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.InvalidUser, e.getType());
assertTrue(e.getMessage().contains("Password mandatory"));
} finally {
// resource csv with null password policy
csv.setPasswordPolicy(null);
resourceService.update(csv);
}
}
Aggregations