use of eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleGuaranteeServiceIntegrationTest method testFindRoleGuaranteeByRole.
@Test
public void testFindRoleGuaranteeByRole() {
IdmIdentityDto guarantee1 = testHelper.createIdentity();
IdmIdentityDto guarantee2 = testHelper.createIdentity();
IdmIdentityDto guarantee3 = testHelper.createIdentity();
//
IdmRoleDto role = testHelper.createRole();
//
IdmRoleGuaranteeDto roleGuarantee = new IdmRoleGuaranteeDto();
roleGuarantee.setRole(role.getId());
roleGuarantee.setGuarantee(guarantee1.getId());
roleGuaranteeService.save(roleGuarantee);
//
roleGuarantee = new IdmRoleGuaranteeDto();
roleGuarantee.setRole(role.getId());
roleGuarantee.setGuarantee(guarantee2.getId());
roleGuaranteeService.save(roleGuarantee);
//
roleGuarantee = new IdmRoleGuaranteeDto();
roleGuarantee.setRole(role.getId());
roleGuarantee.setGuarantee(guarantee3.getId());
roleGuaranteeService.save(roleGuarantee);
//
IdmRoleGuaranteeFilter filter = new IdmRoleGuaranteeFilter();
filter.setRole(role.getId());
List<IdmRoleGuaranteeDto> list = roleGuaranteeService.find(filter, null).getContent();
assertEquals(3, list.size());
//
List<UUID> guarantees = list.stream().map(IdmRoleGuaranteeDto::getGuarantee).collect(Collectors.toList());
roleGuarantee = list.get(0);
assertEquals(role.getId(), roleGuarantee.getRole());
assertTrue(guarantees.contains(guarantee3.getId()));
assertTrue(guarantees.contains(guarantee2.getId()));
assertTrue(guarantees.contains(guarantee1.getId()));
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleGuaranteeServiceIntegrationTest method testFindRoleGuaranteeByGuarantee.
@Test
public void testFindRoleGuaranteeByGuarantee() {
IdmIdentityDto guarantee = testHelper.createIdentity();
//
IdmRoleDto role1 = testHelper.createRole();
IdmRoleDto role2 = testHelper.createRole();
IdmRoleDto role3 = testHelper.createRole();
//
IdmRoleGuaranteeDto roleGuarantee = new IdmRoleGuaranteeDto();
roleGuarantee.setRole(role1.getId());
roleGuarantee.setGuarantee(guarantee.getId());
roleGuaranteeService.save(roleGuarantee);
//
roleGuarantee = new IdmRoleGuaranteeDto();
roleGuarantee.setRole(role2.getId());
roleGuarantee.setGuarantee(guarantee.getId());
roleGuaranteeService.save(roleGuarantee);
//
roleGuarantee = new IdmRoleGuaranteeDto();
roleGuarantee.setRole(role3.getId());
roleGuarantee.setGuarantee(guarantee.getId());
roleGuaranteeService.save(roleGuarantee);
//
IdmRoleGuaranteeFilter filter = new IdmRoleGuaranteeFilter();
filter.setGuarantee(guarantee.getId());
List<IdmRoleGuaranteeDto> list = roleGuaranteeService.find(filter, null).getContent();
assertEquals(3, list.size());
//
List<UUID> roles = list.stream().map(IdmRoleGuaranteeDto::getRole).collect(Collectors.toList());
roleGuarantee = list.get(0);
assertEquals(guarantee.getId(), roleGuarantee.getGuarantee());
assertTrue(roles.contains(role1.getId()));
assertTrue(roles.contains(role2.getId()));
assertTrue(roles.contains(role3.getId()));
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleServiceIntegrationTest method testReferentialIntegrity.
@Test
public void testReferentialIntegrity() {
IdmIdentityDto identity = new IdmIdentityDto();
String username = "delete_test_" + System.currentTimeMillis();
identity.setUsername(username);
// confidential storage
identity.setPassword(new GuardedString("heslo"));
identity.setFirstName("Test");
identity.setLastName("Identity");
identity = identityService.save(identity);
// role
IdmRoleDto role = new IdmRoleDto();
String roleName = "test_r_" + System.currentTimeMillis();
role.setName(roleName);
IdmRoleGuaranteeDto roleGuarantee = new IdmRoleGuaranteeDto();
roleGuarantee.setRole(role.getId());
roleGuarantee.setGuarantee(identity.getId());
role.setGuarantees(Lists.newArrayList(roleGuarantee));
role = roleService.save(role);
assertNotNull(roleService.getByCode(roleName));
assertEquals(1, roleGuaranteeRepository.findAllByRole_Id(role.getId()).size());
roleService.delete(role);
assertNull(roleService.getByCode(roleName));
assertEquals(0, roleGuaranteeRepository.findAllByRole_Id(role.getId()).size());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleServiceIntegrationTest method guaranteeFilterTest.
@Test
public void guaranteeFilterTest() {
IdmIdentityDto identity = helper.createIdentity();
IdmRoleDto role = new IdmRoleDto();
role.setName("IgnacMikinaRole");
helper.createRole();
IdmRoleGuaranteeDto roleGuarantee = new IdmRoleGuaranteeDto();
roleGuarantee.setRole(role.getId());
roleGuarantee.setGuarantee(identity.getId());
role.setGuarantees(Lists.newArrayList(roleGuarantee));
role = roleService.save(role);
IdmRoleFilter filter = new IdmRoleFilter();
filter.setGuaranteeId(identity.getId());
Page<IdmRoleDto> result = roleService.find(filter, null);
assertEquals("Wrong guarantee", 1, result.getTotalElements());
assertEquals("Wrong guarantee id", role.getId(), result.getContent().get(0).getId());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto in project CzechIdMng by bcvsolutions.
the class ChangeIdentityPermissionTest method testTaskCount.
@Test
@Transactional
public void testTaskCount() {
configurationService.setValue(APPROVE_BY_SECURITY_ENABLE, "false");
configurationService.setValue(APPROVE_BY_MANAGER_ENABLE, "false");
configurationService.setValue(APPROVE_BY_HELPDESK_ENABLE, "true");
configurationService.setValue(APPROVE_BY_USERMANAGER_ENABLE, "false");
//
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
IdmIdentityDto test1 = helper.createIdentity();
IdmIdentityDto guarantee = helper.createIdentity();
// Guarantee
int priority = 500;
IdmRoleDto role = helper.createRole();
role.setPriority(priority);
IdmRoleGuaranteeDto roleGuarantee = new IdmRoleGuaranteeDto();
roleGuarantee.setRole(role.getId());
roleGuarantee.setGuarantee(guarantee.getId());
role.getGuarantees().add(roleGuarantee);
role = roleService.save(role);
// set approve by guarantee
configurationService.setValue(IdmRoleService.WF_BY_ROLE_PRIORITY_PREFIX + priority, APPROVE_ROLE_BY_GUARANTEE_KEY);
// helpdesk role and identity
IdmRoleDto helpdeskRole = helper.createRole();
IdmIdentityDto helpdeskIdentity = helper.createIdentity();
// add role directly
helper.createIdentityRole(helpdeskIdentity, helpdeskRole);
configurationService.setValue(APPROVE_BY_HELPDESK_ROLE, helpdeskRole.getCode());
IdmIdentityContractDto contract = helper.getPrimeContract(test1.getId());
// check task before create request
loginAsAdmin(test1.getUsername());
int taskCount = getHistoricProcess().size();
IdmRoleRequestDto request = createRoleRequest(test1);
request = roleRequestService.save(request);
IdmConceptRoleRequestDto concept = createRoleConcept(role, 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.setCandidateOrAssigned(securityService.getCurrentUsername());
List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
assertEquals(0, tasks.size());
// check tasks after create request, must be +1
loginAsAdmin(test1.getUsername());
int taksCountAfter = getHistoricProcess().size();
assertEquals(taskCount + 1, taksCountAfter);
// HELPDESK
loginAsAdmin(helpdeskIdentity.getUsername());
taskFilter.setCandidateOrAssigned(helpdeskIdentity.getUsername());
checkAndCompleteOneTask(taskFilter, test1.getUsername(), "approve");
// check tasks by identity, must be + 2 (main process + sub process)
loginAsAdmin(test1.getUsername());
taksCountAfter = getHistoricProcess().size();
assertEquals(taskCount + 2, taksCountAfter);
// Subprocess - approve by GUARANTEE
loginAsAdmin(guarantee.getUsername());
taskFilter.setCandidateOrAssigned(guarantee.getUsername());
checkAndCompleteOneTask(taskFilter, test1.getUsername(), "approve");
request = roleRequestService.get(request.getId());
assertEquals(RoleRequestState.EXECUTED, request.getState());
assertNotNull(request.getWfProcessId());
concept = conceptRoleRequestService.get(concept.getId());
assertNotNull(concept.getWfProcessId());
// check task on the end (same as before)
loginAsAdmin(test1.getUsername());
taksCountAfter = getHistoricProcess().size();
assertEquals(taskCount + 2, taksCountAfter);
}
Aggregations