use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserIssuesITCase method issueSYNCOPE454.
@Test
public void issueSYNCOPE454() throws NamingException {
// 1. create user with LDAP resource (with 'Generate password if missing' enabled)
UserTO userTO = UserITCase.getUniqueSampleTO("syncope454@syncope.apache.org");
userTO.getResources().add(RESOURCE_NAME_LDAP);
userTO = createUser(userTO).getEntity();
assertNotNull(userTO);
// 2. read resource configuration for LDAP binding
ConnObjectTO connObject = resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.USER.name(), userTO.getKey());
// 3. try (and succeed) to perform simple LDAP binding with provided password ('password123')
assertNotNull(getLdapRemoteObject(connObject.getAttr(Name.NAME).get().getValues().get(0), "password123", connObject.getAttr(Name.NAME).get().getValues().get(0)));
// 4. update user without any password change request
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.setPassword(new PasswordPatch());
userPatch.getPlainAttrs().add(attrAddReplacePatch("surname", "surname2"));
userService.update(userPatch);
// 5. try (and succeed again) to perform simple LDAP binding: password has not changed
assertNotNull(getLdapRemoteObject(connObject.getAttr(Name.NAME).get().getValues().get(0), "password123", connObject.getAttr(Name.NAME).get().getValues().get(0)));
}
use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserIssuesITCase method issueSYNCOPE402.
@Test
public void issueSYNCOPE402() {
// 1. create an user with strict mandatory attributes only
UserTO userTO = new UserTO();
userTO.setRealm(SyncopeConstants.ROOT_REALM);
String userId = getUUIDString() + "syncope402@syncope.apache.org";
userTO.setUsername(userId);
userTO.setPassword("password123");
userTO.getPlainAttrs().add(attrTO("userId", userId));
userTO.getPlainAttrs().add(attrTO("fullname", userId));
userTO.getPlainAttrs().add(attrTO("surname", userId));
userTO = createUser(userTO).getEntity();
assertNotNull(userTO);
assertTrue(userTO.getResources().isEmpty());
// 2. update assigning a resource NOT forcing mandatory constraints
// AND priority: must fail with PropagationException
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.setPassword(new PasswordPatch.Builder().value("newPassword123").build());
userPatch.getResources().add(new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(RESOURCE_NAME_WS1).build());
userPatch.getResources().add(new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(RESOURCE_NAME_TESTDB).build());
ProvisioningResult<UserTO> result = updateUser(userPatch);
PropagationStatus ws1PropagationStatus = result.getPropagationStatuses().stream().filter(propStatus -> RESOURCE_NAME_WS1.equals(propStatus.getResource())).findFirst().orElse(null);
assertNotNull(ws1PropagationStatus);
assertEquals(RESOURCE_NAME_WS1, ws1PropagationStatus.getResource());
assertNotNull(ws1PropagationStatus.getFailureReason());
assertEquals(PropagationTaskExecStatus.FAILURE, ws1PropagationStatus.getStatus());
}
use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserIssuesITCase method issue186.
@Test
public void issue186() {
// 1. create an user with strict mandatory attributes only
UserTO userTO = new UserTO();
userTO.setRealm(SyncopeConstants.ROOT_REALM);
String userId = getUUIDString() + "issue186@syncope.apache.org";
userTO.setUsername(userId);
userTO.setPassword("password123");
userTO.getPlainAttrs().add(attrTO("userId", userId));
userTO.getPlainAttrs().add(attrTO("fullname", userId));
userTO.getPlainAttrs().add(attrTO("surname", userId));
userTO = createUser(userTO).getEntity();
assertNotNull(userTO);
assertTrue(userTO.getResources().isEmpty());
// 2. update assigning a resource forcing mandatory constraints: must fail with RequiredValuesMissing
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.setPassword(new PasswordPatch.Builder().value("newPassword123").build());
userPatch.getResources().add(new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(RESOURCE_NAME_WS2).build());
try {
userTO = updateUser(userPatch).getEntity();
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
}
// 3. update assigning a resource NOT forcing mandatory constraints
// AND priority: must fail with PropagationException
userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.setPassword(new PasswordPatch.Builder().value("newPassword123").build());
userPatch.getResources().add(new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(RESOURCE_NAME_WS1).build());
ProvisioningResult<UserTO> result = updateUser(userPatch);
assertNotNull(result.getPropagationStatuses().get(0).getFailureReason());
userTO = result.getEntity();
// 4. update assigning a resource NOT forcing mandatory constraints
// BUT not priority: must succeed
userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.setPassword(new PasswordPatch.Builder().value("newPassword123456").build());
userPatch.getResources().add(new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(RESOURCE_NAME_CSV).build());
updateUser(userPatch);
}
use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserIssuesITCase method issueSYNCOPE108.
@Test
public void issueSYNCOPE108() {
UserTO userTO = UserITCase.getUniqueSampleTO("syncope108@syncope.apache.org");
userTO.getResources().clear();
userTO.getMemberships().clear();
userTO.getVirAttrs().clear();
userTO.getAuxClasses().add("csv");
userTO.getMemberships().add(new MembershipTO.Builder().group("0626100b-a4ba-4e00-9971-86fad52a6216").build());
userTO.getMemberships().add(new MembershipTO.Builder().group("ba9ed509-b1f5-48ab-a334-c8530a6422dc").build());
userTO.getResources().add(RESOURCE_NAME_CSV);
userTO = createUser(userTO).getEntity();
assertNotNull(userTO);
assertEquals(2, userTO.getMemberships().size());
assertEquals(1, userTO.getResources().size());
ConnObjectTO connObjectTO = resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), userTO.getKey());
assertNotNull(connObjectTO);
// -----------------------------------
// Remove the first membership: de-provisioning shouldn't happen
// -----------------------------------
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();
assertNotNull(userTO);
assertEquals(1, userTO.getMemberships().size());
connObjectTO = resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), userTO.getKey());
assertNotNull(connObjectTO);
// -----------------------------------
// -----------------------------------
// Remove the resource assigned directly: de-provisioning shouldn't happen
// -----------------------------------
userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.getResources().add(new StringPatchItem.Builder().operation(PatchOperation.DELETE).value(userTO.getResources().iterator().next()).build());
userTO = updateUser(userPatch).getEntity();
assertNotNull(userTO);
assertEquals(1, userTO.getMemberships().size());
assertFalse(userTO.getResources().isEmpty());
connObjectTO = resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), userTO.getKey());
assertNotNull(connObjectTO);
// -----------------------------------
// -----------------------------------
// Remove the first membership: de-provisioning should happen
// -----------------------------------
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();
assertNotNull(userTO);
assertTrue(userTO.getMemberships().isEmpty());
assertTrue(userTO.getResources().isEmpty());
try {
resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), userTO.getKey());
fail("Read should not succeeed");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.NotFound, e.getType());
}
}
use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserIssuesITCase method issueSYNCOPE136AES.
@Test
public void issueSYNCOPE136AES() {
// 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);
UserTO userTO = null;
try {
// 3. create user with no resources
userTO = UserITCase.getUniqueSampleTO("syncope136_AES@apache.org");
userTO.getResources().clear();
userTO = createUser(userTO).getEntity();
assertNotNull(userTO);
// 4. update user, assign a propagation priority resource but don't provide any password
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.getResources().add(new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(RESOURCE_NAME_LDAP).build());
userPatch.setPassword(new PasswordPatch.Builder().onSyncope(false).resource(RESOURCE_NAME_LDAP).build());
ProvisioningResult<UserTO> result = updateUser(userPatch);
assertNotNull(result);
userTO = result.getEntity();
assertNotNull(userTO);
// 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);
if (userTO != null) {
deleteUser(userTO.getKey());
}
}
}
Aggregations