use of org.apache.syncope.common.lib.to.ExecTO in project syncope by apache.
the class PullTaskITCase method issueSYNCOPE313LDAP.
@Test
public void issueSYNCOPE313LDAP() throws Exception {
// First of all, clear any potential conflict with existing user / group
ldapCleanup();
UserTO user = null;
PullTaskTO pullTask = null;
ConnInstanceTO resourceConnector = null;
ConnConfProperty property = null;
try {
// 1. create user in LDAP
String oldCleanPassword = "security123";
user = UserITCase.getUniqueSampleTO("syncope313-ldap@syncope.apache.org");
user.setPassword(oldCleanPassword);
user.getResources().add(RESOURCE_NAME_LDAP);
user = createUser(user).getEntity();
assertNotNull(user);
assertFalse(user.getResources().isEmpty());
// 2. request to change password only on Syncope and not on LDAP
String newCleanPassword = "new-security123";
UserPatch userPatch = new UserPatch();
userPatch.setKey(user.getKey());
userPatch.setPassword(new PasswordPatch.Builder().value(newCleanPassword).build());
user = updateUser(userPatch).getEntity();
// 3. Check that the Syncope user now has the changed password
Pair<Map<String, Set<String>>, UserTO> self = clientFactory.create(user.getUsername(), newCleanPassword).self();
assertNotNull(self);
// 4. Check that the LDAP resource has the old password
ConnObjectTO connObject = resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.USER.name(), user.getKey());
assertNotNull(getLdapRemoteObject(connObject.getAttr(Name.NAME).get().getValues().get(0), oldCleanPassword, connObject.getAttr(Name.NAME).get().getValues().get(0)));
// 5. Update the LDAP Connector to retrieve passwords
ResourceTO ldapResource = resourceService.read(RESOURCE_NAME_LDAP);
resourceConnector = connectorService.read(ldapResource.getConnector(), Locale.ENGLISH.getLanguage());
property = resourceConnector.getConf("retrievePasswordsWithSearch").get();
property.getValues().clear();
property.getValues().add(Boolean.TRUE);
connectorService.update(resourceConnector);
// 6. Pull the user from the resource
ImplementationTO pullActions = new ImplementationTO();
pullActions.setKey(LDAPPasswordPullActions.class.getSimpleName());
pullActions.setEngine(ImplementationEngine.JAVA);
pullActions.setType(ImplementationType.PULL_ACTIONS);
pullActions.setBody(LDAPPasswordPullActions.class.getName());
Response response = implementationService.create(pullActions);
pullActions = implementationService.read(pullActions.getType(), response.getHeaderString(RESTHeaders.RESOURCE_KEY));
assertNotNull(pullActions);
pullTask = new PullTaskTO();
pullTask.setDestinationRealm(SyncopeConstants.ROOT_REALM);
pullTask.setName("LDAP Pull Task");
pullTask.setActive(true);
pullTask.setPerformCreate(true);
pullTask.setPerformUpdate(true);
pullTask.setPullMode(PullMode.FULL_RECONCILIATION);
pullTask.setResource(RESOURCE_NAME_LDAP);
pullTask.getActions().add(pullActions.getKey());
Response taskResponse = taskService.create(TaskType.PULL, pullTask);
pullTask = getObject(taskResponse.getLocation(), TaskService.class, PullTaskTO.class);
assertNotNull(pullTask);
ExecTO execution = execProvisioningTask(taskService, TaskType.PULL, pullTask.getKey(), 50, false);
assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(execution.getStatus()));
// 7. Test the pulled user
self = clientFactory.create(user.getUsername(), oldCleanPassword).self();
assertNotNull(self);
} catch (Exception e) {
fail(e.getMessage());
} finally {
// Delete PullTask + user + reset the connector
if (pullTask != null) {
taskService.delete(TaskType.PULL, pullTask.getKey());
}
if (resourceConnector != null && property != null) {
property.getValues().clear();
property.getValues().add(Boolean.FALSE);
connectorService.update(resourceConnector);
}
if (user != null) {
deleteUser(user.getKey());
}
}
}
use of org.apache.syncope.common.lib.to.ExecTO in project syncope by apache.
the class PushTaskITCase method orgUnit.
@Test
public void orgUnit() {
assertNull(getLdapRemoteObject(RESOURCE_LDAP_ADMIN_DN, RESOURCE_LDAP_ADMIN_PWD, "ou=odd,o=isp"));
assertNull(getLdapRemoteObject(RESOURCE_LDAP_ADMIN_DN, RESOURCE_LDAP_ADMIN_PWD, "ou=even,o=isp"));
assertNull(getLdapRemoteObject(RESOURCE_LDAP_ADMIN_DN, RESOURCE_LDAP_ADMIN_PWD, "ou=two,ou=even,o=isp"));
// 1. create task for pulling org units
PushTaskTO task = new PushTaskTO();
task.setName("For orgUnit");
task.setActive(true);
task.setResource(RESOURCE_NAME_LDAP_ORGUNIT);
task.setSourceRealm(SyncopeConstants.ROOT_REALM);
task.setPerformCreate(true);
task.setPerformDelete(true);
task.setPerformUpdate(true);
Response response = taskService.create(TaskType.PUSH, task);
PushTaskTO pushTask = getObject(response.getLocation(), TaskService.class, PushTaskTO.class);
assertNotNull(pushTask);
ExecTO exec = execProvisioningTask(taskService, TaskType.PUSH, pushTask.getKey(), 50, false);
assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(exec.getStatus()));
// 2. check
assertNotNull(getLdapRemoteObject(RESOURCE_LDAP_ADMIN_DN, RESOURCE_LDAP_ADMIN_PWD, "ou=odd,o=isp"));
assertNotNull(getLdapRemoteObject(RESOURCE_LDAP_ADMIN_DN, RESOURCE_LDAP_ADMIN_PWD, "ou=even,o=isp"));
assertNotNull(getLdapRemoteObject(RESOURCE_LDAP_ADMIN_DN, RESOURCE_LDAP_ADMIN_PWD, "ou=two,ou=even,o=isp"));
}
use of org.apache.syncope.common.lib.to.ExecTO in project syncope by apache.
the class ReportITCase method issueSYNCOPE43.
@Test
public void issueSYNCOPE43() {
ReportTO reportTO = new ReportTO();
reportTO.setName("issueSYNCOPE43" + getUUIDString());
reportTO.setActive(true);
reportTO.setTemplate("sample");
reportTO = createReport(reportTO);
assertNotNull(reportTO);
ExecTO execution = reportService.execute(new ExecuteQuery.Builder().key(reportTO.getKey()).build());
assertNotNull(execution);
int maxit = 50;
do {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
reportTO = reportService.read(reportTO.getKey());
maxit--;
} while (reportTO.getExecutions().isEmpty() && maxit > 0);
assertEquals(1, reportTO.getExecutions().size());
}
use of org.apache.syncope.common.lib.to.ExecTO in project syncope by apache.
the class ReportITCase method issueSYNCOPE102.
@Test
public void issueSYNCOPE102() throws IOException {
// Create
ReportTO reportTO = reportService.read("0062ea9c-924d-4ecf-9961-4492a8cc6d1b");
reportTO.setKey(null);
reportTO.setName("issueSYNCOPE102" + getUUIDString());
reportTO = createReport(reportTO);
assertNotNull(reportTO);
// Execute (multiple requests)
for (int i = 0; i < 10; i++) {
ExecTO execution = reportService.execute(new ExecuteQuery.Builder().key(reportTO.getKey()).build());
assertNotNull(execution);
}
// Wait for one execution
int maxit = 50;
do {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
reportTO = reportService.read(reportTO.getKey());
maxit--;
} while (reportTO.getExecutions().isEmpty() && maxit > 0);
assertFalse(reportTO.getExecutions().isEmpty());
}
use of org.apache.syncope.common.lib.to.ExecTO in project syncope by apache.
the class TaskDataBinderImpl method getExecTO.
@Override
public ExecTO getExecTO(final TaskExec execution) {
ExecTO execTO = new ExecTO();
BeanUtils.copyProperties(execution, execTO, IGNORE_TASK_EXECUTION_PROPERTIES);
if (execution.getKey() != null) {
execTO.setKey(execution.getKey());
}
if (execution.getTask() != null && execution.getTask().getKey() != null) {
execTO.setJobType(JobType.TASK);
execTO.setRefKey(execution.getTask().getKey());
execTO.setRefDesc(buildRefDesc(execution.getTask()));
}
return execTO;
}
Aggregations