Search in sources :

Example 71 with SysRoleSystemDto

use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.

the class ForwardAccountManagementTest method forwardAcmDisabledTest.

@Test
public void forwardAcmDisabledTest() {
    SysSystemDto system = initIdentityData();
    Assert.assertNotNull(system);
    SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
    Assert.assertNotNull(mapping);
    IdmIdentityDto identity = helper.createIdentity();
    AccIdentityAccountFilter roleAccountFilter = new AccIdentityAccountFilter();
    roleAccountFilter.setEntityId(identity.getId());
    roleAccountFilter.setOwnership(Boolean.TRUE);
    roleAccountFilter.setSystemId(system.getId());
    List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    // None role assigned
    Assert.assertEquals(0, identityAccounts.size());
    IdmRoleDto roleDefault = helper.createRole();
    SysRoleSystemDto roleSystemDefault = new SysRoleSystemDto();
    roleSystemDefault.setRole(roleDefault.getId());
    roleSystemDefault.setSystem(system.getId());
    roleSystemDefault.setSystemMapping(mapping.getId());
    // Forward ACM is disabled
    roleSystemDefault.setForwardAccountManagemen(false);
    // 
    roleSystemDefault = roleSystemService.save(roleSystemDefault);
    IdmIdentityRoleDto identityRole = new IdmIdentityRoleDto();
    identityRole.setIdentityContract(identityContractService.getPrimeContract(identity.getId()).getId());
    identityRole.setRole(roleDefault.getId());
    identityRole.setValidFrom(LocalDate.now().plusDays(10));
    identityRole = identityRoleService.save(identityRole);
    identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    // Role assigned, but is valid in the future and forward ACM is disabled
    Assert.assertEquals(0, identityAccounts.size());
    // Delete
    identityService.delete(identity);
    roleService.delete(roleDefault);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 72 with SysRoleSystemDto

use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.

the class ForwardAccountManagementTest method identityRoleIsValidInPastTest.

@Test
public void identityRoleIsValidInPastTest() {
    SysSystemDto system = initIdentityData();
    Assert.assertNotNull(system);
    SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
    Assert.assertNotNull(mapping);
    IdmIdentityDto identity = helper.createIdentity();
    AccIdentityAccountFilter roleAccountFilter = new AccIdentityAccountFilter();
    roleAccountFilter.setEntityId(identity.getId());
    roleAccountFilter.setOwnership(Boolean.TRUE);
    roleAccountFilter.setSystemId(system.getId());
    List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    // None role assigned
    Assert.assertEquals(0, identityAccounts.size());
    IdmRoleDto roleDefault = helper.createRole();
    SysRoleSystemDto roleSystemDefault = new SysRoleSystemDto();
    roleSystemDefault.setRole(roleDefault.getId());
    roleSystemDefault.setSystem(system.getId());
    roleSystemDefault.setSystemMapping(mapping.getId());
    // Forward ACM is enabled
    roleSystemDefault.setForwardAccountManagemen(true);
    // 
    roleSystemDefault = roleSystemService.save(roleSystemDefault);
    IdmIdentityRoleDto identityRole = new IdmIdentityRoleDto();
    identityRole.setIdentityContract(identityContractService.getPrimeContract(identity.getId()).getId());
    identityRole.setRole(roleDefault.getId());
    identityRole.setValidFrom(LocalDate.now().minusDays(10));
    // Assignment is expired
    identityRole.setValidTill(LocalDate.now().minusDays(1));
    identityRole = identityRoleService.save(identityRole);
    identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    // Role assigned - but is expired (forward ACM is enabled)
    Assert.assertEquals(0, identityAccounts.size());
    // Delete
    identityService.delete(identity);
    roleService.delete(roleDefault);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 73 with SysRoleSystemDto

use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.

the class IdentityPasswordProvisioningTest method initRole.

/**
 * Init role for system
 *
 * @param system
 * @return
 */
private IdmRoleDto initRole(SysSystemDto system) {
    // create role mapping to system
    SysSystemMappingDto systemMapping = helper.getDefaultMapping(system);
    IdmRoleDto role = helper.createRole();
    SysRoleSystemDto roleSystemDefault = new SysRoleSystemDto();
    roleSystemDefault.setRole(role.getId());
    roleSystemDefault.setSystem(system.getId());
    roleSystemDefault.setSystemMapping(systemMapping.getId());
    roleSystemService.save(roleSystemDefault);
    return role;
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)

Example 74 with SysRoleSystemDto

use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.

the class ComplexHrProcessIntegrationTest method createLdapGroupRoles.

private void createLdapGroupRoles(SysSystemDto system, SysSystemAttributeMappingDto mappingAttr) {
    IdmRoleDto role = roleService.getByCode(adUsersRole);
    SysRoleSystemDto roleSystem = accTestHelper.createRoleSystem(role, system);
    roleSystem.setForwardAccountManagemen(true);
    roleSystem = sysRoleService.save(roleSystem);
    // adding group roles
    Set<String> groupRoles = new HashSet<String>(Arrays.asList(adGroupAllRole, adGroupPkiRole, adGroupDep1Role, adGroupDep2Role, adGroupCons1Role, adGroupCons2Role, adGroupDirectorRole));
    groupRoles.stream().forEach(roleName -> {
        IdmRoleDto roleDto = roleService.getByCode(roleName);
        SysRoleSystemDto roleGroupSystem = accTestHelper.createRoleSystem(roleDto, system);
        // String roleDN = "cn="+roleName + ", " + ldapGroupOU + ", " + ldapBaseOU;
        SysRoleSystemAttributeDto roleSystemAttributeDto = new SysRoleSystemAttributeDto();
        roleSystemAttributeDto.setStrategyType(AttributeMappingStrategyType.MERGE);
        roleSystemAttributeDto.setRoleSystem(roleGroupSystem.getId());
        roleSystemAttributeDto.setSystemAttributeMapping(mappingAttr.getId());
        roleSystemAttributeDto.setSchemaAttribute(mappingAttr.getSchemaAttribute());
        roleSystemAttributeDto.setName(mappingAttr.getName());
        roleSystemAttributeDto.setEntityAttribute(false);
        roleSystemAttributeDto.setExtendedAttribute(false);
        roleSystemAttributeDto.setTransformToResourceScript("return '" + roleName + "';" + System.lineSeparator());
        roleSystemAttributeDto = roleSystemAttributeService.save(roleSystemAttributeDto);
    });
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) HashSet(java.util.HashSet)

Example 75 with SysRoleSystemDto

use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.

the class SystemExportBulkActionIntegrationTest method testExportAndImportRoleSystemAdvancedPairing.

@Test
public void testExportAndImportRoleSystemAdvancedPairing() {
    SysSystemDto system = createSystem();
    IdmRoleDto originalRoleOne = getHelper().createRole();
    IdmRoleDto originalRoleTwo = getHelper().createRole();
    // Set default mapping to provisioning (for easy creation of role-system)
    List<SysSystemMappingDto> mappings = findMappings(system);
    Assert.assertEquals(1, mappings.size());
    SysSystemMappingDto originalMapping = mappings.get(0);
    originalMapping.setOperationType(SystemOperationType.PROVISIONING);
    originalMapping = systemMappingService.save(originalMapping);
    helper.createRoleSystem(originalRoleOne, system);
    helper.createRoleSystem(originalRoleTwo, system);
    // Make export, upload, delete system and import
    IdmExportImportDto importBatch = executeExportAndImport(system, SystemExportBulkAction.NAME);
    system = systemService.get(system.getId());
    Assert.assertNotNull(system);
    List<SysRoleSystemDto> roleSystems = findRoleSystems(system);
    Assert.assertEquals(2, roleSystems.size());
    // Delete original role and create new with same code.
    roleService.delete(originalRoleOne);
    IdmRoleDto newRoleOne = getHelper().createRole(originalRoleOne.getCode());
    // Delete original roleTwo, for check optional relations feature (is set for
    // role-system).
    roleService.delete(originalRoleTwo);
    // Execute import (check advanced pairing)
    importBatch = importManager.executeImport(importBatch, false);
    Assert.assertNotNull(importBatch);
    Assert.assertEquals(ExportImportType.IMPORT, importBatch.getType());
    Assert.assertEquals(OperationState.EXECUTED, importBatch.getResult().getState());
    roleSystems = findRoleSystems(system);
    Assert.assertEquals(1, roleSystems.size());
    Assert.assertEquals(newRoleOne.getId(), roleSystems.get(0).getRole());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmExportImportDto(eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractExportBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractExportBulkActionTest) Test(org.junit.Test)

Aggregations

SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)110 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)82 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)80 Test (org.junit.Test)69 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)65 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)64 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)61 SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)59 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)50 SysRoleSystemFilter (eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter)48 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)43 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)40 UUID (java.util.UUID)35 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)34 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)33 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)27 SysProvisioningOperationFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter)27 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)26 List (java.util.List)26 SysRoleSystemAttributeService (eu.bcvsolutions.idm.acc.service.api.SysRoleSystemAttributeService)25