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);
}
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);
}
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;
}
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);
});
}
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());
}
Aggregations