use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserITCase method updatePasswordOnly.
@Test
public void updatePasswordOnly() {
int beforeTasks = taskService.search(new TaskQuery.Builder(TaskType.PROPAGATION).page(1).size(1).build()).getTotalCount();
assertFalse(beforeTasks <= 0);
UserTO userTO = getUniqueSampleTO("pwdonly@t.com");
userTO.getMemberships().add(new MembershipTO.Builder().group("f779c0d4-633b-4be5-8f57-32eb478a3ca5").build());
userTO = createUser(userTO).getEntity();
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.setPassword(new PasswordPatch.Builder().value("newPassword123").resource(RESOURCE_NAME_WS2).build());
userTO = updateUser(userPatch).getEntity();
// check for changePwdDate
assertNotNull(userTO.getChangePwdDate());
int afterTasks = taskService.search(new TaskQuery.Builder(TaskType.PROPAGATION).page(1).size(1).build()).getTotalCount();
assertFalse(afterTasks <= 0);
assertTrue(beforeTasks < afterTasks);
}
use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserITCase method async.
@Test
public void async() {
SyncopeClient asyncClient = clientFactory.create(ADMIN_UNAME, ADMIN_PWD);
UserService asyncService = asyncClient.nullPriorityAsync(asyncClient.getService(UserService.class), true);
UserTO user = getUniqueSampleTO("async@syncope.apache.org");
user.getResources().add(RESOURCE_NAME_TESTDB);
user.getResources().add(RESOURCE_NAME_TESTDB2);
user.getResources().add(RESOURCE_NAME_LDAP);
ProvisioningResult<UserTO> result = asyncService.create(user, true).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
});
assertNotNull(result);
verifyAsyncResult(result.getPropagationStatuses());
UserPatch userPatch = new UserPatch();
userPatch.setKey(result.getEntity().getKey());
userPatch.setPassword(new PasswordPatch.Builder().onSyncope(true).resources(RESOURCE_NAME_LDAP, RESOURCE_NAME_TESTDB, RESOURCE_NAME_TESTDB2).value("password321").build());
result = asyncService.update(userPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
});
assertNotNull(result);
verifyAsyncResult(result.getPropagationStatuses());
result = asyncService.delete(result.getEntity().getKey()).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
});
assertNotNull(result);
verifyAsyncResult(result.getPropagationStatuses());
}
use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserITCase method updateInvalidPassword.
@Test
public void updateInvalidPassword() {
assertThrows(SyncopeClientException.class, () -> {
UserTO userTO = getSampleTO("updateinvalid@password.com");
userTO = createUser(userTO).getEntity();
assertNotNull(userTO);
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.setPassword(new PasswordPatch.Builder().value("pass").build());
userService.update(userPatch);
});
}
use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserITCase method restResource.
@Test
public void restResource() {
UserTO userTO = getUniqueSampleTO("rest@syncope.apache.org");
userTO.getResources().clear();
userTO.getResources().add("rest-target-resource");
// 1. create
ProvisioningResult<UserTO> result = userService.create(userTO, true).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
});
assertEquals(1, result.getPropagationStatuses().size());
assertEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(0).getStatus());
assertEquals("rest-target-resource", result.getPropagationStatuses().get(0).getResource());
assertEquals("surname", userTO.getPlainAttr("surname").get().getValues().get(0));
// verify user exists on the backend REST service
WebClient webClient = WebClient.create("http://localhost:9080/syncope-fit-build-tools/cxf/rest/users/" + result.getEntity().getKey());
Response response = webClient.get();
assertEquals(200, response.getStatus());
assertNotNull(response.getEntity());
// 2. update
UserPatch patch = new UserPatch();
patch.setKey(result.getEntity().getKey());
patch.getPlainAttrs().add(new AttrPatch.Builder().attrTO(new AttrTO.Builder().schema("surname").value("surname2").build()).build());
result = userService.update(patch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
});
assertEquals(1, result.getPropagationStatuses().size());
assertEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(0).getStatus());
assertEquals("rest-target-resource", result.getPropagationStatuses().get(0).getResource());
assertEquals("surname2", result.getEntity().getPlainAttr("surname").get().getValues().get(0));
// verify user still exists on the backend REST service
response = webClient.get();
assertEquals(200, response.getStatus());
assertNotNull(response.getEntity());
// 3. delete
result = userService.delete(result.getEntity().getKey()).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
});
assertEquals(1, result.getPropagationStatuses().size());
assertEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(0).getStatus());
assertEquals("rest-target-resource", result.getPropagationStatuses().get(0).getResource());
// verify user was removed by the backend REST service
assertEquals(404, webClient.get().getStatus());
}
use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserIssuesITCase method issueSYNCOPE426.
@Test
public void issueSYNCOPE426() {
UserTO userTO = UserITCase.getUniqueSampleTO("syncope426@syncope.apache.org");
userTO = createUser(userTO).getEntity();
assertNotNull(userTO);
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.setPassword(new PasswordPatch.Builder().value("anotherPassword123").build());
userTO = userService.update(userPatch).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertNotNull(userTO);
}
Aggregations