use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserIssuesITCase method issue234.
@Test
public void issue234() {
UserTO inUserTO = UserITCase.getUniqueSampleTO("issue234@syncope.apache.org");
inUserTO.getResources().add(RESOURCE_NAME_LDAP);
UserTO userTO = createUser(inUserTO).getEntity();
assertNotNull(userTO);
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.setUsername(new StringReplacePatchItem.Builder().value("1" + userTO.getUsername()).build());
userTO = updateUser(userPatch).getEntity();
assertNotNull(userTO);
assertEquals("1" + inUserTO.getUsername(), userTO.getUsername());
}
use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserIssuesITCase method issueSYNCOPE647.
@Test
public void issueSYNCOPE647() {
UserTO userTO = UserITCase.getUniqueSampleTO("syncope647@syncope.apache.org");
userTO.getResources().clear();
userTO.getMemberships().clear();
userTO.getVirAttrs().clear();
userTO.getAuxClasses().add("csv");
userTO.getAuxClasses().add("generic membership");
userTO.getPlainAttrs().add(attrTO("postalAddress", "postalAddress"));
userTO.getResources().add(RESOURCE_NAME_LDAP);
UserTO actual = createUser(userTO).getEntity();
assertNotNull(actual);
assertNotNull(actual.getDerAttr("csvuserid"));
ConnObjectTO connObjectTO = resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.USER.name(), actual.getKey());
assertNotNull(connObjectTO);
assertEquals("postalAddress", connObjectTO.getAttr("postalAddress").get().getValues().get(0));
UserPatch userPatch = new UserPatch();
userPatch.setKey(actual.getKey());
userPatch.getPlainAttrs().add(attrAddReplacePatch("postalAddress", "newPostalAddress"));
actual = updateUser(userPatch).getEntity();
connObjectTO = resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.USER.name(), actual.getKey());
assertNotNull(connObjectTO);
assertEquals("newPostalAddress", connObjectTO.getAttr("postalAddress").get().getValues().get(0));
}
use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserIssuesITCase method issueSYNCOPE686.
@Test
public void issueSYNCOPE686() {
// 1. read configured cipher algorithm in order to be able to restore it at the end of test
AttrTO pwdCipherAlgo = configurationService.get("password.cipher.algorithm");
String origpwdCipherAlgo = pwdCipherAlgo.getValues().get(0);
// 2. set AES password cipher algorithm
pwdCipherAlgo.getValues().set(0, "AES");
configurationService.set(pwdCipherAlgo);
try {
// 3. create group with LDAP resource assigned
GroupTO group = GroupITCase.getBasicSampleTO("syncope686");
group.getResources().add(RESOURCE_NAME_LDAP);
group = createGroup(group).getEntity();
assertNotNull(group);
// 4. create user with no resources
UserTO userTO = UserITCase.getUniqueSampleTO("syncope686@apache.org");
userTO.getResources().clear();
userTO = createUser(userTO).getEntity();
assertNotNull(userTO);
// 5. update user with the new group, and don't provide any password
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.getMemberships().add(new MembershipPatch.Builder().operation(PatchOperation.ADD_REPLACE).group(group.getKey()).build());
ProvisioningResult<UserTO> result = updateUser(userPatch);
assertNotNull(result);
// 5. verify that propagation was successful
List<PropagationStatus> props = result.getPropagationStatuses();
assertNotNull(props);
assertEquals(1, props.size());
PropagationStatus prop = props.iterator().next();
assertNotNull(prop);
assertEquals(RESOURCE_NAME_LDAP, prop.getResource());
assertEquals(PropagationTaskExecStatus.SUCCESS, prop.getStatus());
} finally {
// restore initial cipher algorithm
pwdCipherAlgo.getValues().set(0, origpwdCipherAlgo);
configurationService.set(pwdCipherAlgo);
}
}
use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserIssuesITCase method issueSYNCOPE122.
@Test
public void issueSYNCOPE122() {
// 1. create user on testdb and testdb2
UserTO userTO = UserITCase.getUniqueSampleTO("syncope122@apache.org");
userTO.getResources().clear();
userTO.getResources().add(RESOURCE_NAME_TESTDB);
userTO.getResources().add(RESOURCE_NAME_TESTDB2);
userTO = createUser(userTO).getEntity();
assertNotNull(userTO);
assertTrue(userTO.getResources().contains(RESOURCE_NAME_TESTDB));
assertTrue(userTO.getResources().contains(RESOURCE_NAME_TESTDB2));
String pwdOnSyncope = userTO.getPassword();
ConnObjectTO userOnDb = resourceService.readConnObject(RESOURCE_NAME_TESTDB, AnyTypeKind.USER.name(), userTO.getKey());
AttrTO pwdOnTestDbAttr = userOnDb.getAttr(OperationalAttributes.PASSWORD_NAME).get();
assertNotNull(pwdOnTestDbAttr);
assertNotNull(pwdOnTestDbAttr.getValues());
assertFalse(pwdOnTestDbAttr.getValues().isEmpty());
String pwdOnTestDb = pwdOnTestDbAttr.getValues().iterator().next();
ConnObjectTO userOnDb2 = resourceService.readConnObject(RESOURCE_NAME_TESTDB2, AnyTypeKind.USER.name(), userTO.getKey());
AttrTO pwdOnTestDb2Attr = userOnDb2.getAttr(OperationalAttributes.PASSWORD_NAME).get();
assertNotNull(pwdOnTestDb2Attr);
assertNotNull(pwdOnTestDb2Attr.getValues());
assertFalse(pwdOnTestDb2Attr.getValues().isEmpty());
String pwdOnTestDb2 = pwdOnTestDb2Attr.getValues().iterator().next();
// 2. request to change password only on testdb (no Syncope, no testdb2)
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.setPassword(new PasswordPatch.Builder().value(getUUIDString()).onSyncope(false).resource(RESOURCE_NAME_TESTDB).build());
ProvisioningResult<UserTO> result = updateUser(userPatch);
userTO = result.getEntity();
// 3a. Chech that only a single propagation took place
assertNotNull(result.getPropagationStatuses());
assertEquals(1, result.getPropagationStatuses().size());
assertEquals(RESOURCE_NAME_TESTDB, result.getPropagationStatuses().iterator().next().getResource());
// 3b. verify that password hasn't changed on Syncope
assertEquals(pwdOnSyncope, userTO.getPassword());
// 3c. verify that password *has* changed on testdb
userOnDb = resourceService.readConnObject(RESOURCE_NAME_TESTDB, AnyTypeKind.USER.name(), userTO.getKey());
AttrTO pwdOnTestDbAttrAfter = userOnDb.getAttr(OperationalAttributes.PASSWORD_NAME).get();
assertNotNull(pwdOnTestDbAttrAfter);
assertNotNull(pwdOnTestDbAttrAfter.getValues());
assertFalse(pwdOnTestDbAttrAfter.getValues().isEmpty());
assertNotEquals(pwdOnTestDb, pwdOnTestDbAttrAfter.getValues().iterator().next());
// 3d. verify that password hasn't changed on testdb2
userOnDb2 = resourceService.readConnObject(RESOURCE_NAME_TESTDB2, AnyTypeKind.USER.name(), userTO.getKey());
AttrTO pwdOnTestDb2AttrAfter = userOnDb2.getAttr(OperationalAttributes.PASSWORD_NAME).get();
assertNotNull(pwdOnTestDb2AttrAfter);
assertNotNull(pwdOnTestDb2AttrAfter.getValues());
assertFalse(pwdOnTestDb2AttrAfter.getValues().isEmpty());
assertEquals(pwdOnTestDb2, pwdOnTestDb2AttrAfter.getValues().iterator().next());
}
use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserIssuesITCase method issueSYNCOPE354.
@Test
public void issueSYNCOPE354() {
// change resource-ldap group mapping for including uniqueMember (need for assertions below)
ResourceTO ldap = resourceService.read(RESOURCE_NAME_LDAP);
ldap.getProvision(AnyTypeKind.GROUP.name()).get().getMapping().getItems().stream().filter(item -> ("description".equals(item.getExtAttrName()))).forEachOrdered(item -> {
item.setExtAttrName("uniqueMember");
});
resourceService.update(ldap);
// 1. create group with LDAP resource
GroupTO groupTO = new GroupTO();
groupTO.setName("SYNCOPE354-" + getUUIDString());
groupTO.setRealm("/");
groupTO.getResources().add(RESOURCE_NAME_LDAP);
groupTO = createGroup(groupTO).getEntity();
assertNotNull(groupTO);
// 2. create user with LDAP resource and membership of the above group
UserTO userTO = UserITCase.getUniqueSampleTO("syncope354@syncope.apache.org");
userTO.getResources().add(RESOURCE_NAME_LDAP);
userTO.getMemberships().add(new MembershipTO.Builder().group(groupTO.getKey()).build());
userTO = createUser(userTO).getEntity();
assertTrue(userTO.getResources().contains(RESOURCE_NAME_LDAP));
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.USER.name(), userTO.getKey()));
// 3. read group on resource, check that user DN is included in uniqueMember
ConnObjectTO connObj = resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey());
assertNotNull(connObj);
assertTrue(connObj.getAttr("uniqueMember").get().getValues().contains("uid=" + userTO.getUsername() + ",ou=people,o=isp"));
// 4. remove membership
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.getMemberships().add(new MembershipPatch.Builder().operation(PatchOperation.DELETE).group(userTO.getMemberships().get(0).getGroupKey()).build());
userTO = updateUser(userPatch).getEntity();
assertTrue(userTO.getResources().contains(RESOURCE_NAME_LDAP));
// 5. read group on resource, check that user DN was removed from uniqueMember
connObj = resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey());
assertNotNull(connObj);
assertFalse(connObj.getAttr("uniqueMember").get().getValues().contains("uid=" + userTO.getUsername() + ",ou=people,o=isp"));
// 6. user has still the LDAP resource assigned - SYNCOPE-1222
userTO = userService.read(userTO.getKey());
assertTrue(userTO.getResources().contains(RESOURCE_NAME_LDAP));
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.USER.name(), userTO.getKey()));
// 7. restore original resource-ldap group mapping
ldap.getProvision(AnyTypeKind.GROUP.name()).get().getMapping().getItems().stream().filter(item -> ("uniqueMember".equals(item.getExtAttrName()))).forEachOrdered(item -> {
item.setExtAttrName("description");
});
resourceService.update(ldap);
}
Aggregations