Search in sources :

Example 6 with IdmRoleRequestDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmRoleRequestServiceIntegrationTest method changePermissionViaRoleRequestTest.

@Test
@Transactional()
public void changePermissionViaRoleRequestTest() {
    this.addPermissionViaRoleRequestTest();
    IdmIdentityDto testA = identityService.getByUsername(USER_TEST_A);
    IdmIdentityContractDto contractA = identityContractService.getPrimeContract(testA.getId());
    IdmRoleRequestDto request = new IdmRoleRequestDto();
    request.setApplicant(testA.getId());
    request.setExecuteImmediately(true);
    request.setRequestedByType(RoleRequestedByType.MANUALLY);
    request = roleRequestService.save(request);
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByIdentity(testA.getId());
    Assert.assertEquals(1, identityRoles.size());
    LocalDate validFrom = new LocalDate().minusDays(1);
    IdmConceptRoleRequestDto conceptA = new IdmConceptRoleRequestDto();
    conceptA.setRoleRequest(request.getId());
    conceptA.setRole(identityRoles.get(0).getRole());
    conceptA.setOperation(ConceptRoleRequestOperation.UPDATE);
    conceptA.setValidFrom(validFrom);
    conceptA.setValidTill(null);
    conceptA.setIdentityContract(contractA.getId());
    conceptA.setIdentityRole(identityRoles.get(0).getId());
    conceptA = conceptRoleRequestService.save(conceptA);
    roleRequestService.startRequestInternal(request.getId(), true);
    request = roleRequestService.get(request.getId());
    Assert.assertEquals(RoleRequestState.EXECUTED, request.getState());
    identityRoles = identityRoleService.findAllByIdentity(testA.getId());
    Assert.assertEquals(1, identityRoles.size());
    Assert.assertEquals(validFrom, identityRoles.get(0).getValidFrom());
    Assert.assertEquals(null, identityRoles.get(0).getValidTill());
    Assert.assertEquals(contractA.getId(), identityRoles.get(0).getIdentityContract());
    Assert.assertEquals(roleA.getId(), identityRoles.get(0).getRole());
}
Also used : IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) LocalDate(org.joda.time.LocalDate) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with IdmRoleRequestDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto in project CzechIdMng by bcvsolutions.

the class RoleRequestByIdentityEvaluatorIntegrationTest method testCannotReadRoleRequestByIdentity.

@Test(expected = ForbiddenEntityException.class)
public void testCannotReadRoleRequestByIdentity() {
    IdmIdentityDto identityOne = helper.createIdentity();
    IdmIdentityDto identityTwo = helper.createIdentity();
    // 
    IdmRoleDto role = helper.createRole();
    helper.createIdentityRole(identityTwo, role);
    IdmRoleRequestDto roleRequest = helper.assignRoles(helper.getPrimeContract(identityOne.getId()), role);
    // 
    try {
        loginService.login(new LoginDto(identityTwo.getUsername(), identityTwo.getPassword()));
        // 
        roleRequestService.get(roleRequest.getId(), IdmBasePermission.READ);
    } finally {
        logout();
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 8 with IdmRoleRequestDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto in project CzechIdMng by bcvsolutions.

the class RoleRequestByIdentityEvaluatorIntegrationTest method testCreateRoleRequestForOtherIdentity.

@Test
public void testCreateRoleRequestForOtherIdentity() {
    IdmIdentityDto identityOne = helper.createIdentity();
    IdmIdentityDto identityTwo = helper.createIdentity();
    // create policy
    IdmRoleDto role = helper.createRole();
    helper.createUuidPolicy(role.getId(), identityTwo.getId(), IdentityBasePermission.CHANGEPERMISSION);
    helper.createIdentityRole(identityOne, role);
    // assign default role
    helper.createIdentityRole(identityOne, roleService.getByCode(InitDemoData.DEFAULT_ROLE_NAME));
    // 
    try {
        loginService.login(new LoginDto(identityOne.getUsername(), identityOne.getPassword()));
        // 
        IdmRoleRequestDto roleRequest = new IdmRoleRequestDto();
        roleRequest.setApplicant(identityTwo.getId());
        roleRequest.setRequestedByType(RoleRequestedByType.MANUALLY);
        roleRequest = roleRequestService.save(roleRequest, IdmBasePermission.CREATE);
        // 
        Assert.notNull(roleRequest.getId());
    } finally {
        logout();
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 9 with IdmRoleRequestDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto in project CzechIdMng by bcvsolutions.

the class SelfRoleRequestEvaluatorIntegrationTest method testCanReadSelfRoleRequest.

@Test
public void testCanReadSelfRoleRequest() {
    IdmRoleDto role = roleService.getByCode(InitDemoData.DEFAULT_ROLE_NAME);
    // prepare identity
    IdmIdentityDto identity = helper.createIdentity();
    // assign role request
    IdmRoleRequestDto roleRequest = helper.assignRoles(helper.getPrimeContract(identity.getId()), role);
    // 
    try {
        loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
        // 
        IdmRoleRequestDto read = roleRequestService.get(roleRequest.getId(), IdmBasePermission.READ);
        assertEquals(roleRequest, read);
        // 
        IdmConceptRoleRequestFilter filter = new IdmConceptRoleRequestFilter();
        filter.setRoleRequestId(roleRequest.getId());
        Page<IdmConceptRoleRequestDto> concepts = conceptRoleRequestController.find(filter, null, IdmBasePermission.READ);
        assertEquals(1, concepts.getTotalElements());
    } finally {
        logout();
    }
}
Also used : IdmConceptRoleRequestFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmConceptRoleRequestFilter) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 10 with IdmRoleRequestDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto in project CzechIdMng by bcvsolutions.

the class SelfRoleRequestEvaluatorIntegrationTest method testCreateRoleRequestForSelf.

@Test
public void testCreateRoleRequestForSelf() {
    IdmIdentityDto identityOne = helper.createIdentity();
    // assign default role
    helper.createIdentityRole(identityOne, roleService.getByCode(InitDemoData.DEFAULT_ROLE_NAME));
    // 
    try {
        loginService.login(new LoginDto(identityOne.getUsername(), identityOne.getPassword()));
        // 
        IdmRoleRequestDto roleRequest = new IdmRoleRequestDto();
        roleRequest.setApplicant(identityOne.getId());
        roleRequest.setRequestedByType(RoleRequestedByType.MANUALLY);
        roleRequest = roleRequestService.save(roleRequest, IdmBasePermission.CREATE);
        // 
        Assert.notNull(roleRequest.getId());
    } finally {
        logout();
    }
}
Also used : IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Aggregations

IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)69 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)54 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)52 Test (org.junit.Test)52 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)51 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)49 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)44 WorkflowFilterDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto)37 WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)35 List (java.util.List)27 ArrayList (java.util.ArrayList)26 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)24 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)24 Transactional (org.springframework.transaction.annotation.Transactional)20 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)9 IdmConceptRoleRequestFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmConceptRoleRequestFilter)9 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)9 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)8 IdmRoleGuaranteeDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto)7 LoginDto (eu.bcvsolutions.idm.core.security.api.dto.LoginDto)7