use of org.apache.syncope.common.lib.policy.PullPolicyTO in project syncope by apache.
the class PolicyITCase method buildPullPolicyTO.
private PullPolicyTO buildPullPolicyTO() throws IOException {
ImplementationTO corrRule = null;
try {
corrRule = implementationService.read(ImplementationType.PULL_CORRELATION_RULE, "TestPullRule");
} catch (SyncopeClientException e) {
if (e.getType().getResponseStatus() == Response.Status.NOT_FOUND) {
corrRule = new ImplementationTO();
corrRule.setKey("TestPullRule");
corrRule.setEngine(ImplementationEngine.GROOVY);
corrRule.setType(ImplementationType.PULL_CORRELATION_RULE);
corrRule.setBody(IOUtils.toString(getClass().getResourceAsStream("/TestPullRule.groovy"), StandardCharsets.UTF_8));
Response response = implementationService.create(corrRule);
corrRule = implementationService.read(corrRule.getType(), response.getHeaderString(RESTHeaders.RESOURCE_KEY));
assertNotNull(corrRule);
}
}
assertNotNull(corrRule);
PullPolicyTO policy = new PullPolicyTO();
policy.getCorrelationRules().put(AnyTypeKind.USER.name(), corrRule.getKey());
policy.setDescription("Pull policy");
return policy;
}
use of org.apache.syncope.common.lib.policy.PullPolicyTO in project syncope by apache.
the class PolicyITCase method create.
@Test
public void create() throws IOException {
PullPolicyTO policyTO = createPolicy(PolicyType.PULL, buildPullPolicyTO());
assertNotNull(policyTO);
assertEquals("TestPullRule", policyTO.getCorrelationRules().get(AnyTypeKind.USER.name()));
}
use of org.apache.syncope.common.lib.policy.PullPolicyTO in project syncope by apache.
the class PolicyITCase method getPullPolicy.
@Test
public void getPullPolicy() {
PullPolicyTO policyTO = policyService.read(PolicyType.PULL, "66691e96-285f-4464-bc19-e68384ea4c85");
assertNotNull(policyTO);
assertTrue(policyTO.getUsedByRealms().isEmpty());
}
use of org.apache.syncope.common.lib.policy.PullPolicyTO in project syncope by apache.
the class PolicyITCase method delete.
@Test
public void delete() throws IOException {
PullPolicyTO policy = buildPullPolicyTO();
PullPolicyTO policyTO = createPolicy(PolicyType.PULL, policy);
assertNotNull(policyTO);
policyService.delete(PolicyType.PULL, policyTO.getKey());
try {
policyService.read(PolicyType.PULL, policyTO.getKey());
fail("This should not happen");
} catch (SyncopeClientException e) {
assertNotNull(e);
}
}
use of org.apache.syncope.common.lib.policy.PullPolicyTO in project syncope by apache.
the class PullTaskITCase method issueSYNCOPE258.
@Test
public void issueSYNCOPE258() throws IOException {
// -----------------------------
// Add a custom correlation rule
// -----------------------------
ImplementationTO corrRule = null;
try {
corrRule = implementationService.read(ImplementationType.PULL_CORRELATION_RULE, "TestPullRule");
} catch (SyncopeClientException e) {
if (e.getType().getResponseStatus() == Response.Status.NOT_FOUND) {
corrRule = new ImplementationTO();
corrRule.setKey("TestPullRule");
corrRule.setEngine(ImplementationEngine.GROOVY);
corrRule.setType(ImplementationType.PULL_CORRELATION_RULE);
corrRule.setBody(IOUtils.toString(getClass().getResourceAsStream("/TestPullRule.groovy"), StandardCharsets.UTF_8));
Response response = implementationService.create(corrRule);
corrRule = implementationService.read(corrRule.getType(), response.getHeaderString(RESTHeaders.RESOURCE_KEY));
assertNotNull(corrRule);
}
}
assertNotNull(corrRule);
PullPolicyTO policyTO = policyService.read(PolicyType.PULL, "9454b0d7-2610-400a-be82-fc23cf553dd6");
policyTO.getCorrelationRules().put(AnyTypeKind.USER.name(), corrRule.getKey());
policyService.update(PolicyType.PULL, policyTO);
// -----------------------------
PullTaskTO task = new PullTaskTO();
task.setDestinationRealm(SyncopeConstants.ROOT_REALM);
task.setName("Test Pull Rule");
task.setActive(true);
task.setResource(RESOURCE_NAME_WS2);
task.setPullMode(PullMode.FULL_RECONCILIATION);
task.setPerformCreate(true);
task.setPerformDelete(true);
task.setPerformUpdate(true);
Response response = taskService.create(TaskType.PULL, task);
task = getObject(response.getLocation(), TaskService.class, PullTaskTO.class);
UserTO userTO = UserITCase.getUniqueSampleTO("s258_1@apache.org");
userTO.getResources().clear();
userTO.getResources().add(RESOURCE_NAME_WS2);
createUser(userTO);
userTO = UserITCase.getUniqueSampleTO("s258_2@apache.org");
userTO.getResources().clear();
userTO.getResources().add(RESOURCE_NAME_WS2);
userTO = createUser(userTO).getEntity();
// change email in order to unmatch the second user
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.getPlainAttrs().add(attrAddReplacePatch("email", "s258@apache.org"));
userService.update(userPatch);
execProvisioningTask(taskService, TaskType.PULL, task.getKey(), 50, false);
PullTaskTO executed = taskService.read(TaskType.PULL, task.getKey(), true);
assertEquals(1, executed.getExecutions().size());
// asser for just one match
assertTrue(executed.getExecutions().get(0).getMessage().contains("[updated/failures]: 1/0"), executed.getExecutions().get(0).getMessage().substring(0, 55) + "...");
}
Aggregations