use of org.apache.syncope.common.lib.to.ProvisioningResult in project syncope by apache.
the class UserIssuesITCase method issueSYNCOPE1099.
@Test
public void issueSYNCOPE1099() {
// 1. create group with dynamic condition and resource
GroupTO group = GroupITCase.getSampleTO("syncope1099G");
group.getResources().clear();
group.getResources().add(RESOURCE_NAME_TESTDB);
group.setUDynMembershipCond("firstname==issueSYNCOPE1099");
group = createGroup(group).getEntity();
assertNotNull(group);
// 2. create user matching the condition above
UserTO user = UserITCase.getUniqueSampleTO("syncope1099U@apache.org");
user.getPlainAttr("firstname").get().getValues().set(0, "issueSYNCOPE1099");
ProvisioningResult<UserTO> created = createUser(user);
assertNotNull(created);
// 3. verify that dynamic membership is set and that resource is consequently assigned
user = created.getEntity();
String groupKey = group.getKey();
assertTrue(user.getDynMemberships().stream().anyMatch(m -> m.getGroupKey().equals(groupKey)));
assertTrue(user.getResources().contains(RESOURCE_NAME_TESTDB));
// 4. verify that propagation happened towards the resource of the dynamic group
assertFalse(created.getPropagationStatuses().isEmpty());
assertEquals(RESOURCE_NAME_TESTDB, created.getPropagationStatuses().get(0).getResource());
}
use of org.apache.syncope.common.lib.to.ProvisioningResult in project syncope by apache.
the class VirAttrITCase method issueSYNCOPE397.
@Test
public void issueSYNCOPE397() {
ResourceTO csv = resourceService.read(RESOURCE_NAME_CSV);
// change mapping of resource-csv
MappingTO origMapping = SerializationUtils.clone(csv.getProvisions().get(0).getMapping());
try {
// remove this mapping
Optional<ItemTO> email = csv.getProvisions().get(0).getMapping().getItems().stream().filter(item -> "email".equals(item.getIntAttrName())).findFirst();
if (email.isPresent()) {
csv.getProvisions().get(0).getMapping().getItems().remove(email.get());
}
resourceService.update(csv);
csv = resourceService.read(RESOURCE_NAME_CSV);
assertNotNull(csv.getProvisions().get(0).getMapping());
// create new virtual schema for the resource below
ProvisionTO provision = csv.getProvision(AnyTypeKind.USER.name()).get();
assertNotNull(provision);
VirSchemaTO virSchema = new VirSchemaTO();
virSchema.setKey("syncope397" + getUUIDString());
virSchema.setExtAttrName("email");
virSchema.setResource(RESOURCE_NAME_CSV);
virSchema.setAnyType(provision.getAnyType());
virSchema = createSchema(SchemaType.VIRTUAL, virSchema);
assertNotNull(virSchema);
AnyTypeClassTO newClass = new AnyTypeClassTO();
newClass.setKey("syncope397" + getUUIDString());
newClass.getVirSchemas().add(virSchema.getKey());
Response response = anyTypeClassService.create(newClass);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusInfo().getStatusCode());
newClass = getObject(response.getLocation(), AnyTypeClassService.class, AnyTypeClassTO.class);
// create a new user
UserTO userTO = UserITCase.getUniqueSampleTO("397@syncope.apache.org");
userTO.getAuxClasses().add("csv");
userTO.getAuxClasses().add(newClass.getKey());
userTO.getResources().clear();
userTO.getMemberships().clear();
userTO.getVirAttrs().clear();
userTO.getVirAttrs().add(attrTO(virSchema.getKey(), "test@testone.org"));
// assign resource-csv to user
userTO.getResources().add(RESOURCE_NAME_CSV);
// save user
userTO = createUser(userTO).getEntity();
// make std controls about user
assertNotNull(userTO);
assertTrue(RESOURCE_NAME_CSV.equals(userTO.getResources().iterator().next()));
assertEquals("test@testone.org", userTO.getVirAttrs().iterator().next().getValues().get(0));
// update user
UserTO toBeUpdated = userService.read(userTO.getKey());
UserPatch userPatch = new UserPatch();
userPatch.setKey(toBeUpdated.getKey());
userPatch.setPassword(new PasswordPatch.Builder().value("password234").build());
// assign new resource to user
userPatch.getResources().add(new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(RESOURCE_NAME_WS2).build());
// modify virtual attribute
userPatch.getVirAttrs().add(attrTO(virSchema.getKey(), "test@testoneone.com"));
// check Syncope change password
userPatch.setPassword(new PasswordPatch.Builder().value("password234").onSyncope(true).resource(RESOURCE_NAME_WS2).build());
ProvisioningResult<UserTO> result = updateUser(userPatch);
assertNotNull(result);
toBeUpdated = result.getEntity();
assertTrue(toBeUpdated.getVirAttrs().iterator().next().getValues().contains("test@testoneone.com"));
// check if propagates correctly with assertEquals on size of tasks list
assertEquals(2, result.getPropagationStatuses().size());
} finally {
// restore mapping of resource-csv
csv.getProvisions().get(0).setMapping(origMapping);
resourceService.update(csv);
}
}
use of org.apache.syncope.common.lib.to.ProvisioningResult in project syncope by apache.
the class MultitenancyITCase method createUser.
@Test
public void createUser() {
assertNull(adminClient.getService(RealmService.class).list().get(0).getPasswordPolicy());
UserTO user = new UserTO();
user.setRealm(SyncopeConstants.ROOT_REALM);
user.setUsername(getUUIDString());
user.setPassword("password");
Response response = adminClient.getService(UserService.class).create(user, true);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
user = response.readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertNotNull(user);
}
use of org.apache.syncope.common.lib.to.ProvisioningResult in project syncope by apache.
the class GroupITCase method update.
@Test
public void update() {
GroupTO groupTO = getSampleTO("latestGroup" + getUUIDString());
groupTO = createGroup(groupTO).getEntity();
assertEquals(1, groupTO.getPlainAttrs().size());
GroupPatch groupPatch = new GroupPatch();
groupPatch.setKey(groupTO.getKey());
String modName = "finalGroup" + getUUIDString();
groupPatch.setName(new StringReplacePatchItem.Builder().value(modName).build());
groupPatch.getPlainAttrs().add(attrAddReplacePatch("show", "FALSE"));
groupTO = updateGroup(groupPatch).getEntity();
assertEquals(modName, groupTO.getName());
assertEquals(2, groupTO.getPlainAttrs().size());
groupTO.getPlainAttr("show").get().getValues().clear();
groupTO = groupService.update(groupTO).readEntity(new GenericType<ProvisioningResult<GroupTO>>() {
}).getEntity();
assertFalse(groupTO.getPlainAttr("show").isPresent());
}
use of org.apache.syncope.common.lib.to.ProvisioningResult in project syncope by apache.
the class AbstractAnyLogic method afterDelete.
protected ProvisioningResult<TO> afterDelete(final TO input, final List<PropagationStatus> statuses, final List<LogicActions> actions) {
TO any = input;
for (LogicActions action : actions) {
any = action.afterDelete(any);
}
ProvisioningResult<TO> result = new ProvisioningResult<>();
result.setEntity(any);
result.getPropagationStatuses().addAll(statuses);
return result;
}
Aggregations