// add an attribute with no values: must be ignored
membershipTO.addAttribute(attributeTO("subscriptionDate", null));
// add an attribute with a non-existing schema: must be ignored
AttributeTO attrWithInvalidSchemaTO = attributeTO("invalid schema", "a value");
userTO.addAttribute(attrWithInvalidSchemaTO);
// add an attribute with null value: must be ignored
userTO.addAttribute(attributeTO("activationDate", null));
// 1. create user
UserTO newUserTO = createUser(userTO);
assertNotNull(newUserTO);
assertFalse(newUserTO.getAttributes().contains(attrWithInvalidSchemaTO));
// check for changePwdDate
assertNotNull(newUserTO.getCreationDate());
// 2. check for virtual attribute value
newUserTO = userService.read(newUserTO.getId());
assertNotNull(newUserTO);
assertNotNull(newUserTO.getVirtualAttributeMap());
assertNotNull(newUserTO.getVirtualAttributeMap().get("virtualdata").getValues());
assertFalse(newUserTO.getVirtualAttributeMap().get("virtualdata").getValues().isEmpty());
assertEquals("virtualvalue", newUserTO.getVirtualAttributeMap().get("virtualdata").getValues().get(0));
// get the new task list
tasks = (List<PropagationTaskTO>) taskService.list(TaskType.PROPAGATION);
assertNotNull(tasks);
assertFalse(tasks.isEmpty());
long newMaxId = getMaxTaskId(tasks);
// default configuration for ws-target-resource2:
// only failed executions have to be registered
// --> no more tasks/executions should be added
assertEquals(newMaxId, maxId);
// get last task
taskTO = taskService.read(TaskType.PROPAGATION, newMaxId);
assertNotNull(taskTO);
assertEquals(maxTaskExecutions, taskTO.getExecutions().size());
// 3. verify password
UserService userService1 = super.setupCredentials(userService, UserService.class, newUserTO.getUsername(),
"password123");
try {
UserTO user = userService1.readSelf();
assertNotNull(user);
} catch (AccessControlException e) {
fail("Credentials should be valid and not cause AccessControlException");
}
UserService userService2 = super.setupCredentials(userService, UserService.class, newUserTO.getUsername(),
"passwordXX");
try {
userService2.readSelf();
fail("Credentials are invalid, thus request should raise AccessControlException");
} catch (AccessControlException e) {
assertNotNull(e);
}
resetRestTemplate();
// 4. try (and fail) to create another user with same (unique) values
userTO = getSampleTO(userTO.getUsername());
AttributeTO userIdAttr = getManadatoryAttrByName(userTO.getAttributes(), "userId");
userIdAttr.getValues().clear();
userIdAttr.addValue("a.b@c.com");
SyncopeClientException sce = null;
try {
createUser(userTO);
} catch (SyncopeClientCompositeErrorException e) {