use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto in project CzechIdMng by bcvsolutions.
the class ChangeIdentityPermissionTest method cancelWfOnRoleRequestDeleteTest.
@Test
public void cancelWfOnRoleRequestDeleteTest() {
ZonedDateTime now = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
getHelper().waitForResult(null, 1, 1);
// We are logged as admin. By default is all approve tasks assigned to Admin.
// All this tasks will be skipped.
loginAsAdmin();
IdmIdentityDto test1 = identityService.getByUsername(InitTestDataProcessor.TEST_USER_1);
IdmRoleDto adminRole = roleConfiguration.getAdminRole();
IdmIdentityContractDto contract = getHelper().getPrimeContract(test1.getId());
IdmRoleRequestDto request = createRoleRequest(test1);
request = roleRequestService.save(request);
IdmConceptRoleRequestDto concept = createRoleConcept(adminRole, contract, request);
concept = conceptRoleRequestService.save(concept);
roleRequestService.startRequestInternal(request.getId(), true);
request = roleRequestService.get(request.getId());
assertEquals(RoleRequestState.IN_PROGRESS, request.getState());
WorkflowFilterDto taskFilter = new WorkflowFilterDto();
taskFilter.setCreatedAfter(now);
taskFilter.setCandidateOrAssigned(securityService.getCurrentUsername());
List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
assertEquals(0, tasks.size());
// HELPDESK - must be skipped
// MANAGER
loginAsAdmin(InitTestDataProcessor.TEST_USER_2);
taskFilter.setCandidateOrAssigned(InitTestDataProcessor.TEST_USER_2);
tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
assertEquals(1, tasks.size());
concept = conceptRoleRequestService.get(concept.getId());
String conceptWf = concept.getWfProcessId();
assertNull(conceptWf);
request = roleRequestService.get(request.getId());
String requestWf = request.getWfProcessId();
assertNotNull(requestWf);
assertNotNull(workflowProcessInstanceService.get(requestWf));
// Delete the request
roleRequestService.delete(request);
// WF have to be cancelled
assertNull(roleRequestService.get(request.getId()));
assertNull(workflowProcessInstanceService.get(requestWf));
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto in project CzechIdMng by bcvsolutions.
the class ChangeIdentityPermissionTest method addSuperAdminRoleSkipTest.
@Test
public void addSuperAdminRoleSkipTest() {
ZonedDateTime now = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
getHelper().waitForResult(null, 1, 1);
// We are logged as admin. By default is all approve tasks assigned to Admin.
// All this tasks will be skipped.
loginAsAdmin();
IdmIdentityDto test1 = identityService.getByUsername(InitTestDataProcessor.TEST_USER_1);
IdmRoleDto adminRole = roleConfiguration.getAdminRole();
IdmIdentityContractDto contract = getHelper().getPrimeContract(test1.getId());
IdmRoleRequestDto request = createRoleRequest(test1);
request = roleRequestService.save(request);
IdmConceptRoleRequestDto concept = createRoleConcept(adminRole, contract, request);
concept = conceptRoleRequestService.save(concept);
roleRequestService.startRequestInternal(request.getId(), true);
request = roleRequestService.get(request.getId());
assertEquals(RoleRequestState.IN_PROGRESS, request.getState());
WorkflowFilterDto taskFilter = new WorkflowFilterDto();
taskFilter.setCreatedAfter(now);
taskFilter.setCandidateOrAssigned(securityService.getCurrentUsername());
List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
assertEquals(0, tasks.size());
// HELPDESK - must be skipped
// MANAGER
loginAsAdmin(InitTestDataProcessor.TEST_USER_2);
taskFilter.setCandidateOrAssigned(InitTestDataProcessor.TEST_USER_2);
checkAndCompleteOneTask(taskFilter, InitTestDataProcessor.TEST_USER_1, "approve");
// USER MANAGER
loginAsAdmin();
taskFilter.setCandidateOrAssigned(InitTestDataProcessor.TEST_ADMIN_USERNAME);
checkAndCompleteOneTask(taskFilter, InitTestDataProcessor.TEST_USER_1, "approve");
// SECURITY - must be skipped
request = roleRequestService.get(request.getId());
assertEquals(RoleRequestState.EXECUTED, request.getState());
assertNotNull(request.getWfProcessId());
concept = conceptRoleRequestService.get(concept.getId());
assertNotNull(concept.getWfProcessId());
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto in project CzechIdMng by bcvsolutions.
the class ChangeIdentityPermissionTest method addSuperAdminRoleTest.
@Test
public void addSuperAdminRoleTest() {
ZonedDateTime now = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
getHelper().waitForResult(null, 1, 1);
loginAsAdmin(InitTestDataProcessor.TEST_USER_1);
IdmIdentityDto test1 = identityService.getByUsername(InitTestDataProcessor.TEST_USER_1);
IdmRoleDto adminRole = roleConfiguration.getAdminRole();
IdmIdentityContractDto contract = getHelper().getPrimeContract(test1);
IdmRoleRequestDto request = createRoleRequest(test1);
request = roleRequestService.save(request);
IdmConceptRoleRequestDto concept = createRoleConcept(adminRole, contract, request);
concept = conceptRoleRequestService.save(concept);
roleRequestService.startRequestInternal(request.getId(), true);
request = roleRequestService.get(request.getId());
assertEquals(RoleRequestState.IN_PROGRESS, request.getState());
WorkflowFilterDto taskFilter = new WorkflowFilterDto();
taskFilter.setCreatedAfter(now);
taskFilter.setCandidateOrAssigned(securityService.getCurrentUsername());
List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
assertEquals(0, tasks.size());
loginAsAdmin();
// HELPDESK
taskFilter.setCandidateOrAssigned(InitTestDataProcessor.TEST_ADMIN_USERNAME);
checkAndCompleteOneTask(taskFilter, InitTestDataProcessor.TEST_USER_1, "approve");
// MANAGER
loginAsAdmin(InitTestDataProcessor.TEST_USER_2);
taskFilter.setCandidateOrAssigned(InitTestDataProcessor.TEST_USER_2);
checkAndCompleteOneTask(taskFilter, InitTestDataProcessor.TEST_USER_1, "approve");
// USER MANAGER
loginAsAdmin();
taskFilter.setCandidateOrAssigned(InitTestDataProcessor.TEST_ADMIN_USERNAME);
checkAndCompleteOneTask(taskFilter, InitTestDataProcessor.TEST_USER_1, "approve");
// SECURITY
taskFilter.setCandidateOrAssigned(InitTestDataProcessor.TEST_ADMIN_USERNAME);
checkAndCompleteOneTask(taskFilter, InitTestDataProcessor.TEST_USER_1, "approve");
request = roleRequestService.get(request.getId());
assertEquals(RoleRequestState.EXECUTED, request.getState());
assertNotNull(request.getWfProcessId());
concept = conceptRoleRequestService.get(concept.getId());
assertNotNull(concept.getWfProcessId());
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto in project CzechIdMng by bcvsolutions.
the class ChangeIdentityPermissionTest method addSuperAdminRoleWithSubprocessSecurityTest.
@Test
public void addSuperAdminRoleWithSubprocessSecurityTest() {
ZonedDateTime now = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
getHelper().waitForResult(null, 1, 1);
loginAsAdmin(InitTestDataProcessor.TEST_USER_2);
IdmIdentityDto test1 = identityService.getByUsername(InitTestDataProcessor.TEST_USER_1);
IdmIdentityDto test2 = identityService.getByUsername(InitTestDataProcessor.TEST_USER_2);
// Guarantee
int priority = 500;
IdmRoleDto adminRole = roleConfiguration.getAdminRole();
adminRole.setPriority(priority);
getHelper().createRoleGuarantee(adminRole, test2);
adminRole = roleService.save(adminRole);
configurationService.setValue(IdmRoleService.WF_BY_ROLE_PRIORITY_PREFIX + priority, APPROVE_ROLE_BY_SECURITY_KEY);
getHelper().setConfigurationValue(APPROVE_BY_SECURITY_ENABLE, true);
IdmIdentityContractDto contract = getHelper().getPrimeContract(test1.getId());
IdmRoleRequestDto request = createRoleRequest(test1);
request = roleRequestService.save(request);
IdmConceptRoleRequestDto concept = createRoleConcept(adminRole, contract, request);
concept = conceptRoleRequestService.save(concept);
roleRequestService.startRequestInternal(request.getId(), true);
request = roleRequestService.get(request.getId());
assertEquals(RoleRequestState.IN_PROGRESS, request.getState());
WorkflowFilterDto taskFilter = new WorkflowFilterDto();
taskFilter.setCreatedAfter(now);
taskFilter.setCandidateOrAssigned(securityService.getCurrentUsername());
List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
assertEquals(0, tasks.size());
// Help Desk
request = roleRequestService.get(request.getId());
loginAsAdmin();
taskFilter.setCandidateOrAssigned(InitTestDataProcessor.TEST_ADMIN_USERNAME);
checkAndCompleteOneTask(taskFilter, InitTestDataProcessor.TEST_USER_1, "approve");
// Manager
request = roleRequestService.get(request.getId());
loginAsAdmin(InitTestDataProcessor.TEST_USER_2);
taskFilter.setCandidateOrAssigned(InitTestDataProcessor.TEST_USER_2);
checkAndCompleteOneTask(taskFilter, InitTestDataProcessor.TEST_USER_1, "approve");
// User Manager
request = roleRequestService.get(request.getId());
loginAsAdmin();
taskFilter.setCandidateOrAssigned(InitTestDataProcessor.TEST_ADMIN_USERNAME);
checkAndCompleteOneTask(taskFilter, InitTestDataProcessor.TEST_USER_1, "approve");
// Role Guarantee - subprocess
request = roleRequestService.get(request.getId());
loginAsAdmin(InitTestDataProcessor.TEST_USER_2);
taskFilter.setCandidateOrAssigned(InitTestDataProcessor.TEST_USER_2);
checkAndCompleteOneTask(taskFilter, InitTestDataProcessor.TEST_USER_1, "approve");
// Security - subprocess
request = roleRequestService.get(request.getId());
loginAsAdmin();
taskFilter.setCandidateOrAssigned(InitTestDataProcessor.TEST_ADMIN_USERNAME);
checkAndCompleteOneTask(taskFilter, InitTestDataProcessor.TEST_USER_1, "approve");
// Security
request = roleRequestService.get(request.getId());
loginAsAdmin();
taskFilter.setCandidateOrAssigned(InitTestDataProcessor.TEST_ADMIN_USERNAME);
checkAndCompleteOneTask(taskFilter, InitTestDataProcessor.TEST_USER_1, "approve");
request = roleRequestService.get(request.getId());
assertEquals(RoleRequestState.EXECUTED, request.getState());
assertNotNull(request.getWfProcessId());
concept = conceptRoleRequestService.get(concept.getId());
assertNotNull(concept.getWfProcessId());
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto in project CzechIdMng by bcvsolutions.
the class ChangeIdentityPermissionTest method addSuperAdminRoleDisapproveTest.
@Test
public void addSuperAdminRoleDisapproveTest() {
ZonedDateTime now = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
getHelper().waitForResult(null, 1, 1);
// We are logged as admin. By default is all approve tasks assigned to Admin.
// All this tasks will be skipped.
loginAsAdmin();
IdmIdentityDto test1 = identityService.getByUsername(InitTestDataProcessor.TEST_USER_1);
IdmRoleDto adminRole = roleConfiguration.getAdminRole();
IdmIdentityContractDto contract = getHelper().getPrimeContract(test1.getId());
IdmRoleRequestDto request = createRoleRequest(test1);
request = roleRequestService.save(request);
IdmConceptRoleRequestDto concept = createRoleConcept(adminRole, contract, request);
concept = conceptRoleRequestService.save(concept);
roleRequestService.startRequestInternal(request.getId(), true);
request = roleRequestService.get(request.getId());
assertEquals(RoleRequestState.IN_PROGRESS, request.getState());
WorkflowFilterDto taskFilter = new WorkflowFilterDto();
taskFilter.setCreatedAfter(now);
taskFilter.setCandidateOrAssigned(securityService.getCurrentUsername());
List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
assertEquals(0, tasks.size());
// HELPDESK - must be skipped
// MANAGER
loginAsAdmin(InitTestDataProcessor.TEST_USER_2);
taskFilter.setCandidateOrAssigned(InitTestDataProcessor.TEST_USER_2);
checkAndCompleteOneTask(taskFilter, InitTestDataProcessor.TEST_USER_1, "disapprove");
request = roleRequestService.get(request.getId());
assertEquals(RoleRequestState.DISAPPROVED, request.getState());
assertNotNull(request.getWfProcessId());
concept = conceptRoleRequestService.get(concept.getId());
assertEquals(null, concept.getWfProcessId());
}
Aggregations