use of io.automatiko.engine.api.auth.SecurityPolicy in project automatiko-engine by automatiko-io.
the class UserTaskTest method testApprovalWithExcludedOwnerViaPhases.
@Test
public void testApprovalWithExcludedOwnerViaPhases() throws Exception {
Application app = generateCodeProcessesOnly("usertask/approval.bpmn2");
assertThat(app).isNotNull();
Process<? extends Model> p = app.processes().processById("approvals");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
m.fromMap(parameters);
ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start();
assertEquals(io.automatiko.engine.api.runtime.process.ProcessInstance.STATE_ACTIVE, processInstance.status());
StaticIdentityProvider identity = new StaticIdentityProvider("admin", Collections.singletonList("managers"));
SecurityPolicy policy = SecurityPolicy.of(identity);
processInstance.workItems(policy);
List<WorkItem> workItems = processInstance.workItems(policy);
assertEquals(1, workItems.size());
HumanTaskTransition transition = new HumanTaskTransition(Complete.ID, null, identity);
processInstance.transitionWorkItem(workItems.get(0).getId(), transition);
// actual owner of the first task is excluded owner on the second task so won't
// find it
workItems = processInstance.workItems(policy);
assertEquals(0, workItems.size());
identity = new StaticIdentityProvider("john", Collections.singletonList("managers"));
policy = SecurityPolicy.of(identity);
workItems = processInstance.workItems(policy);
assertEquals(1, workItems.size());
transition = new HumanTaskTransition(Complete.ID, null, identity);
processInstance.transitionWorkItem(workItems.get(0).getId(), transition);
assertEquals(io.automatiko.engine.api.runtime.process.ProcessInstance.STATE_COMPLETED, processInstance.status());
}
use of io.automatiko.engine.api.auth.SecurityPolicy in project automatiko-engine by automatiko-io.
the class UserTaskTest method testApprovalWithExcludedOwner.
@Test
public void testApprovalWithExcludedOwner() throws Exception {
Application app = generateCodeProcessesOnly("usertask/approval.bpmn2");
assertThat(app).isNotNull();
Process<? extends Model> p = app.processes().processById("approvals");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
m.fromMap(parameters);
ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start();
assertEquals(io.automatiko.engine.api.runtime.process.ProcessInstance.STATE_ACTIVE, processInstance.status());
StaticIdentityProvider identity = new StaticIdentityProvider("admin", Collections.singletonList("managers"));
SecurityPolicy policy = SecurityPolicy.of(identity);
processInstance.workItems(policy);
List<WorkItem> workItems = processInstance.workItems(policy);
assertEquals(1, workItems.size());
processInstance.completeWorkItem(workItems.get(0).getId(), null, policy);
// actual owner of the first task is excluded owner on the second task so won't
// find it
workItems = processInstance.workItems(policy);
assertEquals(0, workItems.size());
identity = new StaticIdentityProvider("john", Collections.singletonList("managers"));
policy = SecurityPolicy.of(identity);
workItems = processInstance.workItems(policy);
assertEquals(1, workItems.size());
processInstance.completeWorkItem(workItems.get(0).getId(), null, policy);
assertEquals(io.automatiko.engine.api.runtime.process.ProcessInstance.STATE_COMPLETED, processInstance.status());
}
Aggregations