use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.
the class IdmIdentityController method roles.
@ResponseBody
@RequestMapping(value = "/{backendId}/roles", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.IDENTITY_READ + "')")
@ApiOperation(value = "Assigned roles to identity", nickname = "getIdentityRoles", tags = { IdmIdentityController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.IDENTITY_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.IDENTITY_READ, description = "") }) })
public Resources<?> roles(@ApiParam(value = "Identity's uuid identifier or username.", required = true) @PathVariable String backendId) {
IdmIdentityDto identity = getDto(backendId);
if (identity == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
}
//
IdmIdentityRoleFilter filter = new IdmIdentityRoleFilter();
filter.setIdentityId(identity.getId());
Page<IdmIdentityRoleDto> identityRoles = identityRoleService.find(filter, null, IdmBasePermission.READ);
//
return toResources(identityRoles, IdmIdentityRoleDto.class);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.
the class ChangeIdentityPermissionTest method addSuperAdminRoleWithSubprocessDisapproveTest.
@Test
@Transactional
public void addSuperAdminRoleWithSubprocessDisapproveTest() {
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
IdmIdentityDto test1 = identityService.getByUsername(InitTestData.TEST_USER_1);
IdmIdentityDto test2 = identityService.getByUsername(InitTestData.TEST_USER_2);
// Guarantee
int priority = 500;
IdmRoleDto adminRole = roleService.getByCode(InitTestData.TEST_ADMIN_ROLE);
adminRole.setPriority(priority);
IdmRoleGuaranteeDto guarantee = new IdmRoleGuaranteeDto();
guarantee.setRole(adminRole.getId());
guarantee.setGuarantee(test2.getId());
adminRole.getGuarantees().add(guarantee);
adminRole = roleService.save(adminRole);
configurationService.setValue(IdmRoleService.WF_BY_ROLE_PRIORITY_PREFIX + priority, APPROVE_ROLE_BY_GUARANTEE_KEY);
IdmIdentityContractDto contract = identityContractService.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.setCandidateOrAssigned(securityService.getCurrentUsername());
List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
assertEquals(0, tasks.size());
// HELPDESK - must be skipped
// MANAGER
loginAsAdmin(InitTestData.TEST_USER_2);
taskFilter.setCandidateOrAssigned(InitTestData.TEST_USER_2);
checkAndCompleteOneTask(taskFilter, InitTestData.TEST_USER_1, "approve");
// USER MANAGER
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
taskFilter.setCandidateOrAssigned(InitTestData.TEST_ADMIN_USERNAME);
checkAndCompleteOneTask(taskFilter, InitTestData.TEST_USER_1, "approve");
// Subprocess - approve by GUARANTEE
loginAsAdmin(InitTestData.TEST_USER_2);
taskFilter.setCandidateOrAssigned(InitTestData.TEST_USER_2);
checkAndCompleteOneTask(taskFilter, InitTestData.TEST_USER_1, "disapprove");
// SECURITY
request = roleRequestService.get(request.getId());
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
taskFilter.setCandidateOrAssigned(InitTestData.TEST_ADMIN_USERNAME);
checkAndCompleteOneTask(taskFilter, InitTestData.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());
IdmIdentityRoleFilter filter = new IdmIdentityRoleFilter();
filter.setIdentityId(test1.getId());
Page<IdmIdentityRoleDto> page = identityRoleService.find(filter, null);
assertEquals(0, page.getSize());
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.
the class IdmIdentityRoleControllerRestTest method testFindByText.
@Test
public void testFindByText() {
// username
IdmIdentityDto identity = getHelper().createIdentity();
IdmIdentityRoleDto createIdentityRole = getHelper().createIdentityRole(identity, getHelper().createRole());
IdmIdentityDto other = getHelper().createIdentity();
getHelper().createIdentityRole(other, getHelper().createRole());
//
IdmIdentityRoleFilter filter = new IdmIdentityRoleFilter();
filter.setText(identity.getUsername());
List<IdmIdentityRoleDto> results = find(filter);
//
Assert.assertEquals(1, results.size());
Assert.assertTrue(results.stream().anyMatch(ir -> ir.getId().equals(createIdentityRole.getId())));
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.
the class IdmIdentityRoleControllerRestTest method findByContractPosition.
@Test
public void findByContractPosition() {
IdmIdentityDto identity = getHelper().createIdentity();
IdmIdentityContractDto contract = getHelper().getPrimeContract(identity.getId());
IdmContractPositionDto contractPositionOne = getHelper().createContractPosition(contract);
IdmContractPositionDto contractPositionOther = getHelper().createContractPosition(contract);
IdmIdentityRoleDto one = getHelper().createIdentityRole(contractPositionOne, getHelper().createRole());
// other
getHelper().createIdentityRole(contractPositionOther, getHelper().createRole());
//
IdmIdentityRoleFilter filter = new IdmIdentityRoleFilter();
filter.setIdentityId(identity.getId());
filter.setContractPositionId(contractPositionOne.getId());
List<IdmIdentityRoleDto> results = find(filter);
//
Assert.assertEquals(1, results.size());
Assert.assertTrue(results.stream().anyMatch(ir -> ir.getId().equals(one.getId())));
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.
the class IdmIdentityRoleControllerRestTest method testFindByRoleId.
@Test
public void testFindByRoleId() {
IdmIdentityDto identity = getHelper().createIdentity();
IdmRoleDto roleOne = getHelper().createRole();
IdmRoleDto roleTwo = getHelper().createRole();
IdmIdentityRoleDto createIdentityRole = getHelper().createIdentityRole(identity, roleOne);
getHelper().createIdentityRole(identity, roleTwo);
//
IdmIdentityRoleFilter filter = new IdmIdentityRoleFilter();
filter.setRoleId(roleOne.getId());
List<IdmIdentityRoleDto> results = find(filter);
Assert.assertEquals(1, results.size());
Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(createIdentityRole.getId())));
}
Aggregations