use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserIssuesITCase method issueSYNCOPE710.
@Test
public void issueSYNCOPE710() {
// 1. create groups for indirect resource assignment
GroupTO ldapGroup = GroupITCase.getBasicSampleTO("syncope710.ldap");
ldapGroup.getResources().add(RESOURCE_NAME_LDAP);
ldapGroup = createGroup(ldapGroup).getEntity();
GroupTO dbGroup = GroupITCase.getBasicSampleTO("syncope710.db");
dbGroup.getResources().add(RESOURCE_NAME_TESTDB);
dbGroup = createGroup(dbGroup).getEntity();
// 2. create user with memberships for the groups created above
UserTO userTO = UserITCase.getUniqueSampleTO("syncope710@syncope.apache.org");
userTO.getResources().clear();
userTO.getMemberships().clear();
userTO.getMemberships().add(new MembershipTO.Builder().group(ldapGroup.getKey()).build());
userTO.getMemberships().add(new MembershipTO.Builder().group(dbGroup.getKey()).build());
ProvisioningResult<UserTO> result = createUser(userTO);
assertEquals(2, result.getPropagationStatuses().size());
userTO = result.getEntity();
// 3. request to propagate passwod only to db
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.setPassword(new PasswordPatch.Builder().onSyncope(false).resource(RESOURCE_NAME_TESTDB).value("newpassword123").build());
result = updateUser(userPatch);
assertEquals(1, result.getPropagationStatuses().size());
assertEquals(RESOURCE_NAME_TESTDB, result.getPropagationStatuses().get(0).getResource());
}
use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserIssuesITCase method issueSYNCOPE420.
@Test
public void issueSYNCOPE420() throws IOException {
ImplementationTO logicActions = new ImplementationTO();
logicActions.setKey("DoubleValueLogicActions");
logicActions.setEngine(ImplementationEngine.GROOVY);
logicActions.setType(ImplementationType.LOGIC_ACTIONS);
logicActions.setBody(org.apache.commons.io.IOUtils.toString(getClass().getResourceAsStream("/DoubleValueLogicActions.groovy"), StandardCharsets.UTF_8));
Response response = implementationService.create(logicActions);
logicActions = implementationService.read(logicActions.getType(), response.getHeaderString(RESTHeaders.RESOURCE_KEY));
assertNotNull(logicActions);
RealmTO realm = realmService.list("/even/two").iterator().next();
assertNotNull(realm);
realm.getActions().add(logicActions.getKey());
realmService.update(realm);
UserTO userTO = UserITCase.getUniqueSampleTO("syncope420@syncope.apache.org");
userTO.setRealm(realm.getFullPath());
userTO.getPlainAttrs().add(attrTO("makeItDouble", "3"));
userTO = createUser(userTO).getEntity();
assertEquals("6", userTO.getPlainAttr("makeItDouble").get().getValues().get(0));
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.getPlainAttrs().add(attrAddReplacePatch("makeItDouble", "7"));
userTO = updateUser(userPatch).getEntity();
assertEquals("14", userTO.getPlainAttr("makeItDouble").get().getValues().get(0));
}
use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserIssuesITCase method issueSYNCOPE383.
@Test
public void issueSYNCOPE383() {
// 1. create user without resources
UserTO userTO = UserITCase.getUniqueSampleTO("syncope383@apache.org");
userTO.getResources().clear();
userTO = createUser(userTO).getEntity();
assertNotNull(userTO);
// 2. assign resource without specifying a new pwd and check propagation failure
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.getResources().add(new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(RESOURCE_NAME_TESTDB).build());
ProvisioningResult<UserTO> result = updateUser(userPatch);
assertNotNull(result);
userTO = result.getEntity();
assertEquals(RESOURCE_NAME_TESTDB, userTO.getResources().iterator().next());
assertNotEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(0).getStatus());
assertNotNull(result.getPropagationStatuses().get(0).getFailureReason());
userTO = result.getEntity();
// 3. request to change password only on testdb
userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.setPassword(new PasswordPatch.Builder().value(getUUIDString() + "abbcbcbddd123").resource(RESOURCE_NAME_TESTDB).build());
result = updateUser(userPatch);
assertEquals(RESOURCE_NAME_TESTDB, userTO.getResources().iterator().next());
assertEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(0).getStatus());
}
use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserIssuesITCase method issueSYNCOPE1166.
@Test
public void issueSYNCOPE1166() {
UserTO userTO = UserITCase.getUniqueSampleTO("syncope1166@apache.org");
userTO = createUser(userTO).getEntity();
assertNotNull(userTO);
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
// resource-ldap has password mapped, resource-db-virattr does not
userPatch.setPassword(new PasswordPatch.Builder().onSyncope(true).resource(RESOURCE_NAME_LDAP).value("new2Password").build());
userPatch.getResources().add(new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(RESOURCE_NAME_LDAP).build());
userPatch.getResources().add(new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(RESOURCE_NAME_DBVIRATTR).build());
ProvisioningResult<UserTO> result = updateUser(userPatch);
assertNotNull(result);
assertEquals(2, result.getPropagationStatuses().size());
assertEquals(RESOURCE_NAME_LDAP, result.getPropagationStatuses().get(0).getResource());
assertEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(0).getStatus());
assertEquals(RESOURCE_NAME_DBVIRATTR, result.getPropagationStatuses().get(1).getResource());
assertEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(1).getStatus());
}
use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserIssuesITCase method issueSYNCOPE265.
@Test
public void issueSYNCOPE265() {
String[] userKeys = new String[] { "1417acbe-cbf6-4277-9372-e75e04f97000", "74cd8ece-715a-44a4-a736-e17b46c4e7e6", "b3cbc78d-32e6-4bd4-92e0-bbe07566a2ee", "c9b2dec2-00a7-4855-97c0-d854842b4b24", "823074dc-d280-436d-a7dd-07399fae48ec" };
for (String userKey : userKeys) {
UserPatch userPatch = new UserPatch();
userPatch.setKey(userKey);
userPatch.getPlainAttrs().add(attrAddReplacePatch("ctype", "a type"));
UserTO userTO = updateUser(userPatch).getEntity();
assertEquals("a type", userTO.getPlainAttr("ctype").get().getValues().get(0));
}
}
Aggregations