Search in sources :

Example 21 with IdmRoleTreeNodeDto

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

the class DefaultIdmIdentityContractServiceIntegrationTest method testFindAutomaticRoleWithoutRecursion.

@Test
public void testFindAutomaticRoleWithoutRecursion() {
    // prepare
    automaticRoleA = new IdmRoleTreeNodeDto();
    automaticRoleA.setRecursionType(RecursionType.NO);
    automaticRoleA.setRole(roleA.getId());
    automaticRoleA.setTreeNode(nodeD.getId());
    automaticRoleA = saveAutomaticRole(automaticRoleA, false);
    // 
    // test
    Set<IdmRoleTreeNodeDto> automaticRoles = roleTreeNodeService.getAutomaticRolesByTreeNode(nodeD.getId());
    assertEquals(1, automaticRoles.size());
    assertEquals(roleA.getId(), automaticRoles.iterator().next().getRole());
    assertTrue(roleTreeNodeService.getAutomaticRolesByTreeNode(nodeB.getId()).isEmpty());
    assertTrue(roleTreeNodeService.getAutomaticRolesByTreeNode(nodeF.getId()).isEmpty());
}
Also used : IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 22 with IdmRoleTreeNodeDto

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

the class DefaultIdmIdentityContractServiceIntegrationTest method testDontRemoveSameRole.

@Test
public void testDontRemoveSameRole() {
    automaticRoleF = new IdmRoleTreeNodeDto();
    automaticRoleF.setRecursionType(RecursionType.UP);
    automaticRoleF.setRole(roleA.getId());
    automaticRoleF.setTreeNode(nodeF.getId());
    automaticRoleF = saveAutomaticRole(automaticRoleF, false);
    // 
    automaticRoleE = new IdmRoleTreeNodeDto();
    automaticRoleE.setRecursionType(RecursionType.NO);
    automaticRoleE.setRole(roleA.getId());
    automaticRoleE.setTreeNode(nodeE.getId());
    automaticRoleE = saveAutomaticRole(automaticRoleE, false);
    // 
    // prepare identity and contract
    IdmIdentityDto identity = helper.createIdentity("test");
    IdmIdentityContractDto contract = new IdmIdentityContractDto();
    contract.setIdentity(identity.getId());
    contract.setWorkPosition(nodeF.getId());
    contract = service.save(contract);
    // 
    // check assigned role after creation
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contract.getId());
    assertEquals(1, identityRoles.size());
    assertEquals(roleA.getId(), identityRoles.get(0).getRole());
    assertEquals(automaticRoleF.getId(), identityRoles.get(0).getRoleTreeNode());
    // 
    UUID id = identityRoles.get(0).getId();
    // 
    // change
    contract.setWorkPosition(nodeE.getId());
    contract = service.save(contract);
    // 
    // check assigned role after creation
    identityRoles = identityRoleService.findAllByContract(contract.getId());
    assertEquals(1, identityRoles.size());
    assertEquals(roleA.getId(), identityRoles.get(0).getRole());
    assertEquals(automaticRoleE.getId(), identityRoles.get(0).getRoleTreeNode());
    assertEquals(id, identityRoles.get(0).getId());
}
Also used : IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) UUID(java.util.UUID) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 23 with IdmRoleTreeNodeDto

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

the class DefaultIdmIdentityContractServiceIntegrationTest method testReferentialIntegrityOnRole.

@Test
public void testReferentialIntegrityOnRole() {
    helper.setConfigurationValue(SchedulerConfiguration.PROPERTY_TASK_ASYNCHRONOUS_ENABLED, false);
    try {
        // prepare data
        IdmRoleDto role = helper.createRole();
        IdmTreeNodeDto treeNode = helper.createTreeNode();
        // automatic role
        IdmRoleTreeNodeDto roleTreeNode = helper.createRoleTreeNode(role, treeNode, false);
        // 
        assertNotNull(roleTreeNode.getId());
        assertEquals(roleTreeNode.getId(), roleTreeNodeService.get(roleTreeNode.getId()).getId());
        // 
        helper.deleteRole(role.getId());
        // 
        assertNull(roleTreeNodeService.get(roleTreeNode.getId()));
    } finally {
        helper.setConfigurationValue(SchedulerConfiguration.PROPERTY_TASK_ASYNCHRONOUS_ENABLED, true);
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 24 with IdmRoleTreeNodeDto

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

the class DefaultIdmIdentityContractServiceIntegrationTest method testAssingRoleByNewAutomaticRoleForExistingContracts.

@Test
public void testAssingRoleByNewAutomaticRoleForExistingContracts() {
    IdmIdentityDto identity = helper.createIdentity("test-exists");
    // 
    IdmIdentityContractDto contract = new IdmIdentityContractDto();
    contract.setIdentity(identity.getId());
    contract.setPosition("new position");
    contract = service.save(contract);
    // 
    IdmIdentityContractDto contractF = new IdmIdentityContractDto();
    contractF.setIdentity(identity.getId());
    contractF.setWorkPosition(nodeF.getId());
    contractF = service.save(contractF);
    // 
    IdmIdentityContractDto contractD = new IdmIdentityContractDto();
    contractD.setIdentity(identity.getId());
    contractD.setWorkPosition(nodeD.getId());
    contractD = service.save(contractD);
    // 
    IdmIdentityContractDto contractB = new IdmIdentityContractDto();
    contractB.setIdentity(identity.getId());
    contractB.setWorkPosition(nodeB.getId());
    contractB = service.save(contractB);
    // 
    // create new automatic role
    automaticRoleD = new IdmRoleTreeNodeDto();
    automaticRoleD.setRecursionType(RecursionType.DOWN);
    automaticRoleD.setRole(roleA.getId());
    automaticRoleD.setTreeNode(nodeD.getId());
    automaticRoleD = saveAutomaticRole(automaticRoleD, true);
    // 
    // check
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contractB.getId());
    assertTrue(identityRoles.isEmpty());
    // 
    identityRoles = identityRoleService.findAllByContract(contractD.getId());
    assertEquals(1, identityRoles.size());
    assertEquals(automaticRoleD.getId(), identityRoles.get(0).getRoleTreeNode());
    // 
    identityRoles = identityRoleService.findAllByContract(contractF.getId());
    assertEquals(1, identityRoles.size());
    assertEquals(automaticRoleD.getId(), identityRoles.get(0).getRoleTreeNode());
}
Also used : IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 25 with IdmRoleTreeNodeDto

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

the class DefaultIdmIdentityContractServiceIntegrationTest method testDontAssingRoleForDisabledContract.

@Test
public void testDontAssingRoleForDisabledContract() {
    IdmIdentityDto identity = helper.createIdentity();
    // 
    IdmIdentityContractDto contractD = new IdmIdentityContractDto();
    contractD.setIdentity(identity.getId());
    contractD.setWorkPosition(nodeD.getId());
    contractD.setState(ContractState.DISABLED);
    contractD = service.save(contractD);
    // 
    // create new automatic role
    automaticRoleD = new IdmRoleTreeNodeDto();
    automaticRoleD.setRecursionType(RecursionType.NO);
    automaticRoleD.setRole(roleA.getId());
    automaticRoleD.setTreeNode(nodeD.getId());
    automaticRoleD = saveAutomaticRole(automaticRoleD, true);
    // 
    // check
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contractD.getId());
    assertEquals(0, identityRoles.size());
}
Also used : IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmRoleTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto)29 Test (org.junit.Test)16 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)11 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)10 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)9 AcceptedException (eu.bcvsolutions.idm.core.api.exception.AcceptedException)7 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)6 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)6 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)6 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)6 UUID (java.util.UUID)6 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)5 IdmAutomaticRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleRequestDto)5 IdmRoleGuaranteeDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto)3 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)3 RoleRequestException (eu.bcvsolutions.idm.core.api.exception.RoleRequestException)3 IdmAutomaticRoleAttributeDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto)2 ApiOperation (io.swagger.annotations.ApiOperation)2 LocalDate (org.joda.time.LocalDate)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2