use of org.apache.syncope.common.lib.to.WorkflowFormTO in project syncope by apache.
the class AuthenticationITCase method issueSYNCOPE434.
@Test
public void issueSYNCOPE434() {
assumeTrue(FlowableDetector.isFlowableEnabledForUsers(syncopeService));
// 1. create user with group 'groupForWorkflowApproval'
// (users with group groupForWorkflowApproval are defined in workflow as subject to approval)
UserTO userTO = UserITCase.getUniqueSampleTO("createWithReject@syncope.apache.org");
userTO.getMemberships().add(new MembershipTO.Builder().group("0cbcabd2-4410-4b6b-8f05-a052b451d18f").build());
userTO = createUser(userTO).getEntity();
assertNotNull(userTO);
assertEquals("createApproval", userTO.getStatus());
// 2. try to authenticate: fail
try {
clientFactory.create(userTO.getUsername(), "password123").self();
fail("This should not happen");
} catch (AccessControlException e) {
assertNotNull(e);
}
// 3. approve user
WorkflowFormTO form = userWorkflowService.getFormForUser(userTO.getKey());
form = userWorkflowService.claimForm(form.getTaskId());
form.getProperty("approveCreate").get().setValue(Boolean.TRUE.toString());
userTO = userWorkflowService.submitForm(form);
assertNotNull(userTO);
assertEquals("active", userTO.getStatus());
// 4. try to authenticate again: success
Pair<Map<String, Set<String>>, UserTO> self = clientFactory.create(userTO.getUsername(), "password123").self();
assertNotNull(self);
assertNotNull(self.getLeft());
assertNotNull(self.getRight());
}
use of org.apache.syncope.common.lib.to.WorkflowFormTO in project syncope by apache.
the class IdentityRecertificationITCase method recertification.
@Test
public void recertification() {
execTask(taskService, TaskType.SCHEDULED, "e95555d2-1b09-42c8-b25b-f4c4ec598989", "JOB_FIRED", 50, false);
List<WorkflowFormTO> forms = userWorkflowService.getForms();
assertFalse(forms.isEmpty());
for (WorkflowFormTO form : forms) {
userWorkflowService.claimForm(form.getTaskId());
WorkflowFormPropertyTO approve = form.getProperty("approve").get();
approve.setValue("true");
userWorkflowService.submitForm(form);
}
forms = userWorkflowService.getForms();
assertTrue(forms.isEmpty());
}
use of org.apache.syncope.common.lib.to.WorkflowFormTO in project syncope by apache.
the class UserSelfITCase method createAndApprove.
@Test
public void createAndApprove() {
assumeTrue(FlowableDetector.isFlowableEnabledForUsers(syncopeService));
// self-create user with membership: goes 'createApproval' with resources and membership but no propagation
UserTO userTO = UserITCase.getUniqueSampleTO("anonymous@syncope.apache.org");
userTO.getMemberships().add(new MembershipTO.Builder().group("29f96485-729e-4d31-88a1-6fc60e4677f3").build());
userTO.getResources().add(RESOURCE_NAME_TESTDB);
SyncopeClient anonClient = clientFactory.create();
userTO = anonClient.getService(UserSelfService.class).create(userTO, true).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
assertNotNull(userTO);
assertEquals("createApproval", userTO.getStatus());
assertFalse(userTO.getMemberships().isEmpty());
assertFalse(userTO.getResources().isEmpty());
try {
resourceService.readConnObject(RESOURCE_NAME_TESTDB, AnyTypeKind.USER.name(), userTO.getKey());
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.NotFound, e.getType());
}
// now approve and verify that propagation has happened
WorkflowFormTO form = userWorkflowService.getFormForUser(userTO.getKey());
form = userWorkflowService.claimForm(form.getTaskId());
form.getProperty("approveCreate").get().setValue(Boolean.TRUE.toString());
userTO = userWorkflowService.submitForm(form);
assertNotNull(userTO);
assertEquals("active", userTO.getStatus());
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_TESTDB, AnyTypeKind.USER.name(), userTO.getKey()));
}
use of org.apache.syncope.common.lib.to.WorkflowFormTO in project syncope by apache.
the class UserWorkflowITCase method issueSYNCOPE15.
@Test
public void issueSYNCOPE15() {
assumeTrue(FlowableDetector.isFlowableEnabledForUsers(syncopeService));
// read forms *before* any operation
List<WorkflowFormTO> forms = userWorkflowService.getForms();
assertNotNull(forms);
int preForms = forms.size();
UserTO userTO = UserITCase.getUniqueSampleTO("issueSYNCOPE15@syncope.apache.org");
userTO.getResources().clear();
userTO.getVirAttrs().clear();
userTO.getDerAttrs().clear();
userTO.getMemberships().clear();
// Users with group 0cbcabd2-4410-4b6b-8f05-a052b451d18f are defined in workflow as subject to approval
userTO.getMemberships().add(new MembershipTO.Builder().group("0cbcabd2-4410-4b6b-8f05-a052b451d18f").build());
// 1. create user with group 9 (and verify that no propagation occurred)
userTO = createUser(userTO).getEntity();
assertNotNull(userTO);
assertNotEquals(0L, userTO.getKey());
assertNotNull(userTO.getCreationDate());
assertNotNull(userTO.getCreator());
assertNotNull(userTO.getLastChangeDate());
assertNotNull(userTO.getLastModifier());
assertEquals(userTO.getCreationDate(), userTO.getLastChangeDate());
// 2. request if there is any pending form for user just created
forms = userWorkflowService.getForms();
assertEquals(preForms + 1, forms.size());
WorkflowFormTO form = userWorkflowService.getFormForUser(userTO.getKey());
assertNotNull(form);
// 3. first claim by bellini ....
UserWorkflowService userService3 = clientFactory.create("bellini", ADMIN_PWD).getService(UserWorkflowService.class);
form = userService3.claimForm(form.getTaskId());
assertNotNull(form);
assertNotNull(form.getTaskId());
assertNotNull(form.getOwner());
// 4. second claim task by admin
form = userWorkflowService.claimForm(form.getTaskId());
assertNotNull(form);
// 5. approve user
form.getProperty("approveCreate").get().setValue(Boolean.TRUE.toString());
// 6. submit approve
userTO = userWorkflowService.submitForm(form);
assertNotNull(userTO);
assertEquals(preForms, userWorkflowService.getForms().size());
assertNull(userWorkflowService.getFormForUser(userTO.getKey()));
// 7.check that no more forms are still to be processed
forms = userWorkflowService.getForms();
assertEquals(preForms, forms.size());
}
use of org.apache.syncope.common.lib.to.WorkflowFormTO in project syncope by apache.
the class FlowableUserWorkflowAdapter method getForms.
@Transactional(readOnly = true)
@Override
public List<WorkflowFormTO> getForms() {
List<WorkflowFormTO> forms = new ArrayList<>();
String authUser = AuthContextUtils.getUsername();
if (adminUser.equals(authUser)) {
forms.addAll(getForms(engine.getTaskService().createTaskQuery().taskVariableValueEquals(TASK_IS_FORM, Boolean.TRUE)));
} else {
User user = userDAO.findByUsername(authUser);
if (user == null) {
throw new NotFoundException("Syncope User " + authUser);
}
forms.addAll(getForms(engine.getTaskService().createTaskQuery().taskVariableValueEquals(TASK_IS_FORM, Boolean.TRUE).taskCandidateOrAssigned(user.getKey())));
List<String> candidateGroups = new ArrayList<>();
userDAO.findAllGroupNames(user).forEach(group -> {
candidateGroups.add(group);
});
if (!candidateGroups.isEmpty()) {
forms.addAll(getForms(engine.getTaskService().createTaskQuery().taskVariableValueEquals(TASK_IS_FORM, Boolean.TRUE).taskCandidateGroupIn(candidateGroups)));
}
}
return forms;
}
Aggregations