Search in sources :

Example 61 with SysRoleSystemAttributeDto

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

the class DefaultSysRoleSystemAttributeService method getSystemAttribute.

/**
 * Returns existing system attribute or null
 */
private SysRoleSystemAttributeDto getSystemAttribute(UUID roleSystem, String attributeName) {
    SysRoleSystemAttributeFilter filter = new SysRoleSystemAttributeFilter();
    filter.setRoleSystemId(roleSystem);
    List<SysRoleSystemAttributeDto> content = this.find(filter, null).getContent();
    for (SysRoleSystemAttributeDto attribute : content) {
        if (attribute.getName().equals(attributeName)) {
            return attribute;
        }
    }
    return null;
}
Also used : SysRoleSystemAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemAttributeFilter) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)

Example 62 with SysRoleSystemAttributeDto

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

the class DefaultRoleSynchronizationExecutorTest method testSyncRolesMembership.

@Test
public void testSyncRolesMembership() {
    AbstractSysSyncConfigDto syncConfigCustom = createSyncConfig();
    SysSystemDto userSystem = helper.createTestResourceSystem(true);
    List<SysSystemMappingDto> userSystemMappings = systemMappingService.findBySystem(userSystem, SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY);
    Assert.assertNotNull(userSystemMappings);
    Assert.assertEquals(1, userSystemMappings.size());
    SysSystemMappingDto userMappingDto = userSystemMappings.get(0);
    // Switch to the sync.
    userMappingDto.setOperationType(SystemOperationType.SYNCHRONIZATION);
    userMappingDto = systemMappingService.save(userMappingDto);
    List<SysSystemAttributeMappingDto> attributeMappingDtos = schemaAttributeMappingService.findBySystemMapping(userMappingDto);
    SysSystemAttributeMappingDto userEmailAttribute = attributeMappingDtos.stream().filter(attribute -> attribute.getName().equalsIgnoreCase(TestHelper.ATTRIBUTE_MAPPING_EMAIL)).findFirst().orElse(null);
    Assert.assertNotNull(userEmailAttribute);
    Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
    Assert.assertTrue(syncConfigCustom instanceof SysSyncRoleConfigDto);
    SysSyncRoleConfigDto roleConfigDto = (SysSyncRoleConfigDto) syncConfigCustom;
    SysSystemMappingDto systemMappingDto = DtoUtils.getEmbedded(syncConfigCustom, SysSyncConfig_.systemMapping, SysSystemMappingDto.class);
    SysSchemaObjectClassDto schemaObjectClassDto = DtoUtils.getEmbedded(systemMappingDto, SysSystemMapping_.objectClass, SysSchemaObjectClassDto.class);
    UUID roleSystemId = schemaObjectClassDto.getSystem();
    Assert.assertNotNull(roleSystemId);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(roleSystemId);
    schemaAttributeFilter.setObjectClassId(schemaObjectClassDto.getId());
    SysSchemaAttributeDto schemaAttributeDto = schemaAttributeService.find(schemaAttributeFilter, null).getContent().stream().filter(attribute -> attribute.getName().equalsIgnoreCase("name")).findFirst().orElse(null);
    Assert.assertNotNull(schemaAttributeDto);
    SysSystemDto roleSystemDto = new SysSystemDto();
    roleSystemDto.setId(roleSystemId);
    List<SysSystemMappingDto> roleSystemMappings = systemMappingService.findBySystem(roleSystemDto, SystemOperationType.SYNCHRONIZATION, SystemEntityType.ROLE);
    Assert.assertNotNull(roleSystemMappings);
    Assert.assertEquals(1, roleSystemMappings.size());
    SysSystemMappingDto roleMappingDto = roleSystemMappings.get(0);
    // Create mapping attribute for get ID of role.
    SysSystemAttributeMappingDto roleIdAttribute = new SysSystemAttributeMappingDto();
    roleIdAttribute.setEntityAttribute(true);
    roleIdAttribute.setUid(false);
    roleIdAttribute.setSystemMapping(roleMappingDto.getId());
    roleIdAttribute.setExtendedAttribute(false);
    roleIdAttribute.setIdmPropertyName(RoleSynchronizationExecutor.ROLE_MEMBERSHIP_ID_FIELD);
    roleIdAttribute.setSchemaAttribute(schemaAttributeDto.getId());
    roleIdAttribute.setName(helper.createName());
    attributeMappingService.save(roleIdAttribute);
    // Enable membership and use the user system.
    roleConfigDto.setMembershipSwitch(true);
    roleConfigDto.setMemberSystemMapping(userMappingDto.getId());
    roleConfigDto.setMemberOfAttribute(userEmailAttribute.getId());
    syncConfigCustom = syncConfigService.save(roleConfigDto);
    // 
    helper.startSynchronization(syncConfigCustom);
    // 
    SysSyncLogFilter logFilter = new SysSyncLogFilter();
    logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
    List<SysSyncLogDto> logs = syncLogService.find(logFilter, null).getContent();
    Assert.assertEquals(1, logs.size());
    SysSyncLogDto log = logs.get(0);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    helper.checkSyncLog(syncConfigCustom, SynchronizationActionType.CREATE_ENTITY, 5, OperationResultType.SUCCESS);
    AccRoleAccountFilter roleAccountFilter = new AccRoleAccountFilter();
    roleAccountFilter.setSystemId(roleSystemId);
    List<AccRoleAccountDto> roleAccountDtos = roleAccountService.find(roleAccountFilter, null).getContent();
    Assert.assertEquals(5, roleAccountDtos.size());
    roleAccountDtos.forEach(roleAccountDto -> {
        SysRoleSystemFilter roleSystemFilter = new SysRoleSystemFilter();
        roleSystemFilter.setRoleId(roleAccountDto.getRole());
        List<SysRoleSystemDto> roleSystemDtos = roleSystemService.find(roleSystemFilter, null).getContent();
        Assert.assertEquals(1, roleSystemDtos.size());
        SysRoleSystemDto roleSystem = roleSystemDtos.get(0);
        // Check mapping attribute (should be email).
        SysRoleSystemAttributeFilter roleSystemAttributeFilter = new SysRoleSystemAttributeFilter();
        roleSystemAttributeFilter.setRoleSystemId(roleSystem.getId());
        List<SysRoleSystemAttributeDto> roleSystemAttributeDtos = roleSystemAttributeService.find(roleSystemAttributeFilter, null).getContent();
        Assert.assertEquals(1, roleSystemAttributeDtos.size());
        Assert.assertEquals(userEmailAttribute.getId(), roleSystemAttributeDtos.get(0).getSystemAttributeMapping());
    });
    cleanAfterTest(syncConfigCustom, roleSystemId, log, roleAccountDtos);
}
Also used : SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) AccRoleAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccRoleAccountFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) SysRoleSystemAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemAttributeFilter) SysRoleSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncRoleConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncRoleConfigDto) AccRoleAccountDto(eu.bcvsolutions.idm.acc.dto.AccRoleAccountDto) SysSyncLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 63 with SysRoleSystemAttributeDto

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

the class DefaultRoleSynchronizationExecutorTest method testSyncUpdateRolesMembership.

@Test
public void testSyncUpdateRolesMembership() {
    AbstractSysSyncConfigDto syncConfigCustom = createSyncConfig();
    SysSystemDto userSystem = helper.createTestResourceSystem(true);
    List<SysSystemMappingDto> userSystemMappings = systemMappingService.findBySystem(userSystem, SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY);
    Assert.assertNotNull(userSystemMappings);
    Assert.assertEquals(1, userSystemMappings.size());
    SysSystemMappingDto userMappingDto = userSystemMappings.get(0);
    // Switch to the sync.
    userMappingDto.setOperationType(SystemOperationType.SYNCHRONIZATION);
    userMappingDto = systemMappingService.save(userMappingDto);
    List<SysSystemAttributeMappingDto> attributeMappingDtos = schemaAttributeMappingService.findBySystemMapping(userMappingDto);
    SysSystemAttributeMappingDto userEmailAttribute = attributeMappingDtos.stream().filter(attribute -> attribute.getName().equalsIgnoreCase(TestHelper.ATTRIBUTE_MAPPING_EMAIL)).findFirst().orElse(null);
    Assert.assertNotNull(userEmailAttribute);
    Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
    Assert.assertTrue(syncConfigCustom instanceof SysSyncRoleConfigDto);
    SysSyncRoleConfigDto roleConfigDto = (SysSyncRoleConfigDto) syncConfigCustom;
    SysSystemMappingDto systemMappingDto = DtoUtils.getEmbedded(syncConfigCustom, SysSyncConfig_.systemMapping, SysSystemMappingDto.class);
    SysSchemaObjectClassDto schemaObjectClassDto = DtoUtils.getEmbedded(systemMappingDto, SysSystemMapping_.objectClass, SysSchemaObjectClassDto.class);
    UUID roleSystemId = schemaObjectClassDto.getSystem();
    Assert.assertNotNull(roleSystemId);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(roleSystemId);
    schemaAttributeFilter.setObjectClassId(schemaObjectClassDto.getId());
    SysSchemaAttributeDto schemaAttributeDto = schemaAttributeService.find(schemaAttributeFilter, null).getContent().stream().filter(attribute -> attribute.getName().equalsIgnoreCase("name")).findFirst().orElse(null);
    Assert.assertNotNull(schemaAttributeDto);
    SysSystemDto roleSystemDto = new SysSystemDto();
    roleSystemDto.setId(roleSystemId);
    List<SysSystemMappingDto> roleSystemMappings = systemMappingService.findBySystem(roleSystemDto, SystemOperationType.SYNCHRONIZATION, SystemEntityType.ROLE);
    Assert.assertNotNull(roleSystemMappings);
    Assert.assertEquals(1, roleSystemMappings.size());
    SysSystemMappingDto roleMappingDto = roleSystemMappings.get(0);
    // Create mapping attribute for get ID of role.
    SysSystemAttributeMappingDto roleIdAttribute = new SysSystemAttributeMappingDto();
    roleIdAttribute.setEntityAttribute(true);
    roleIdAttribute.setUid(false);
    roleIdAttribute.setSystemMapping(roleMappingDto.getId());
    roleIdAttribute.setExtendedAttribute(false);
    roleIdAttribute.setIdmPropertyName(RoleSynchronizationExecutor.ROLE_MEMBERSHIP_ID_FIELD);
    roleIdAttribute.setSchemaAttribute(schemaAttributeDto.getId());
    roleIdAttribute.setName(helper.createName());
    roleIdAttribute = attributeMappingService.save(roleIdAttribute);
    // Enable membership and use the user system.
    roleConfigDto.setMembershipSwitch(true);
    roleConfigDto.setMemberSystemMapping(userMappingDto.getId());
    roleConfigDto.setMemberOfAttribute(userEmailAttribute.getId());
    syncConfigCustom = syncConfigService.save(roleConfigDto);
    // 
    helper.startSynchronization(syncConfigCustom);
    // 
    SysSyncLogFilter logFilter = new SysSyncLogFilter();
    logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
    List<SysSyncLogDto> logs = syncLogService.find(logFilter, null).getContent();
    Assert.assertEquals(1, logs.size());
    SysSyncLogDto log = logs.get(0);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    helper.checkSyncLog(syncConfigCustom, SynchronizationActionType.CREATE_ENTITY, 5, OperationResultType.SUCCESS);
    AccRoleAccountFilter roleAccountFilter = new AccRoleAccountFilter();
    roleAccountFilter.setSystemId(roleSystemId);
    List<AccRoleAccountDto> roleAccountDtos = roleAccountService.find(roleAccountFilter, null).getContent();
    Assert.assertEquals(5, roleAccountDtos.size());
    // Delete a log.
    syncLogService.delete(log);
    // Transformation will return new random value -> memberships should be updated.
    String updatedScriptValue = getHelper().createName();
    roleIdAttribute.setTransformFromResourceScript("return '" + updatedScriptValue + "';");
    attributeMappingService.save(roleIdAttribute);
    // Start sync again - for update.
    helper.startSynchronization(syncConfigCustom);
    // 
    logFilter = new SysSyncLogFilter();
    logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
    logs = syncLogService.find(logFilter, null).getContent();
    Assert.assertEquals(1, logs.size());
    log = logs.get(0);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    helper.checkSyncLog(syncConfigCustom, SynchronizationActionType.UPDATE_ENTITY, 5, OperationResultType.SUCCESS);
    roleAccountFilter = new AccRoleAccountFilter();
    roleAccountFilter.setSystemId(roleSystemId);
    roleAccountDtos = roleAccountService.find(roleAccountFilter, null).getContent();
    Assert.assertEquals(5, roleAccountDtos.size());
    roleAccountDtos.forEach(roleAccountDto -> {
        SysRoleSystemFilter roleSystemFilter = new SysRoleSystemFilter();
        roleSystemFilter.setRoleId(roleAccountDto.getRole());
        List<SysRoleSystemDto> roleSystemDtos = roleSystemService.find(roleSystemFilter, null).getContent();
        Assert.assertEquals(1, roleSystemDtos.size());
        SysRoleSystemDto roleSystem = roleSystemDtos.get(0);
        // Check mapping attribute (should be email).
        SysRoleSystemAttributeFilter roleSystemAttributeFilter = new SysRoleSystemAttributeFilter();
        roleSystemAttributeFilter.setRoleSystemId(roleSystem.getId());
        List<SysRoleSystemAttributeDto> roleSystemAttributeDtos = roleSystemAttributeService.find(roleSystemAttributeFilter, null).getContent();
        Assert.assertEquals(1, roleSystemAttributeDtos.size());
        Assert.assertEquals(userEmailAttribute.getId(), roleSystemAttributeDtos.get(0).getSystemAttributeMapping());
        String transformScript = roleSystemAttributeDtos.get(0).getTransformScript();
        Assert.assertTrue(transformScript.contains(updatedScriptValue));
    });
    cleanAfterTest(syncConfigCustom, roleSystemId, log, roleAccountDtos);
}
Also used : SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) AccRoleAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccRoleAccountFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) SysRoleSystemAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemAttributeFilter) SysRoleSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncRoleConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncRoleConfigDto) AccRoleAccountDto(eu.bcvsolutions.idm.acc.dto.AccRoleAccountDto) SysSyncLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 64 with SysRoleSystemAttributeDto

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

the class DefaultRoleSynchronizationExecutorTest method testSyncUpdateRolesMembershipDiffSync.

@Test
public void testSyncUpdateRolesMembershipDiffSync() {
    AbstractSysSyncConfigDto syncConfigCustom = createSyncConfig();
    // Enable a diff sync.
    syncConfigCustom.setDifferentialSync(true);
    syncConfigCustom = syncConfigService.save(syncConfigCustom);
    SysSystemDto userSystem = helper.createTestResourceSystem(true);
    List<SysSystemMappingDto> userSystemMappings = systemMappingService.findBySystem(userSystem, SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY);
    Assert.assertNotNull(userSystemMappings);
    Assert.assertEquals(1, userSystemMappings.size());
    SysSystemMappingDto userMappingDto = userSystemMappings.get(0);
    // Switch to the sync.
    userMappingDto.setOperationType(SystemOperationType.SYNCHRONIZATION);
    userMappingDto = systemMappingService.save(userMappingDto);
    List<SysSystemAttributeMappingDto> attributeMappingDtos = schemaAttributeMappingService.findBySystemMapping(userMappingDto);
    SysSystemAttributeMappingDto userEmailAttribute = attributeMappingDtos.stream().filter(attribute -> attribute.getName().equalsIgnoreCase(TestHelper.ATTRIBUTE_MAPPING_EMAIL)).findFirst().orElse(null);
    Assert.assertNotNull(userEmailAttribute);
    Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
    Assert.assertTrue(syncConfigCustom instanceof SysSyncRoleConfigDto);
    SysSyncRoleConfigDto roleConfigDto = (SysSyncRoleConfigDto) syncConfigCustom;
    SysSystemMappingDto systemMappingDto = DtoUtils.getEmbedded(syncConfigCustom, SysSyncConfig_.systemMapping, SysSystemMappingDto.class);
    SysSchemaObjectClassDto schemaObjectClassDto = DtoUtils.getEmbedded(systemMappingDto, SysSystemMapping_.objectClass, SysSchemaObjectClassDto.class);
    UUID roleSystemId = schemaObjectClassDto.getSystem();
    Assert.assertNotNull(roleSystemId);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(roleSystemId);
    schemaAttributeFilter.setObjectClassId(schemaObjectClassDto.getId());
    SysSchemaAttributeDto schemaAttributeDto = schemaAttributeService.find(schemaAttributeFilter, null).getContent().stream().filter(attribute -> attribute.getName().equalsIgnoreCase("name")).findFirst().orElse(null);
    Assert.assertNotNull(schemaAttributeDto);
    SysSystemDto roleSystemDto = new SysSystemDto();
    roleSystemDto.setId(roleSystemId);
    List<SysSystemMappingDto> roleSystemMappings = systemMappingService.findBySystem(roleSystemDto, SystemOperationType.SYNCHRONIZATION, SystemEntityType.ROLE);
    Assert.assertNotNull(roleSystemMappings);
    Assert.assertEquals(1, roleSystemMappings.size());
    SysSystemMappingDto roleMappingDto = roleSystemMappings.get(0);
    // Create mapping attribute for get ID of role.
    SysSystemAttributeMappingDto roleIdAttribute = new SysSystemAttributeMappingDto();
    roleIdAttribute.setEntityAttribute(true);
    roleIdAttribute.setUid(false);
    roleIdAttribute.setSystemMapping(roleMappingDto.getId());
    roleIdAttribute.setExtendedAttribute(false);
    roleIdAttribute.setIdmPropertyName(RoleSynchronizationExecutor.ROLE_MEMBERSHIP_ID_FIELD);
    roleIdAttribute.setSchemaAttribute(schemaAttributeDto.getId());
    roleIdAttribute.setName(helper.createName());
    roleIdAttribute = attributeMappingService.save(roleIdAttribute);
    // Enable membership and use the user system.
    roleConfigDto.setMembershipSwitch(true);
    roleConfigDto.setMemberSystemMapping(userMappingDto.getId());
    roleConfigDto.setMemberOfAttribute(userEmailAttribute.getId());
    syncConfigCustom = syncConfigService.save(roleConfigDto);
    // 
    helper.startSynchronization(syncConfigCustom);
    // 
    SysSyncLogFilter logFilter = new SysSyncLogFilter();
    logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
    List<SysSyncLogDto> logs = syncLogService.find(logFilter, null).getContent();
    Assert.assertEquals(1, logs.size());
    SysSyncLogDto log = logs.get(0);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    helper.checkSyncLog(syncConfigCustom, SynchronizationActionType.CREATE_ENTITY, 5, OperationResultType.SUCCESS);
    AccRoleAccountFilter roleAccountFilter = new AccRoleAccountFilter();
    roleAccountFilter.setSystemId(roleSystemId);
    List<AccRoleAccountDto> roleAccountDtos = roleAccountService.find(roleAccountFilter, null).getContent();
    Assert.assertEquals(5, roleAccountDtos.size());
    // Delete the log.
    syncLogService.delete(log);
    // Transformation will return new random value -> memberships should be updated.
    String updatedScriptValue = getHelper().createName();
    roleIdAttribute.setTransformFromResourceScript("return '" + updatedScriptValue + "';");
    attributeMappingService.save(roleIdAttribute);
    // Start sync again - for update.
    helper.startSynchronization(syncConfigCustom);
    // 
    logFilter = new SysSyncLogFilter();
    logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
    logs = syncLogService.find(logFilter, null).getContent();
    Assert.assertEquals(1, logs.size());
    log = logs.get(0);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    helper.checkSyncLog(syncConfigCustom, SynchronizationActionType.UPDATE_ENTITY, 5, OperationResultType.SUCCESS);
    roleAccountFilter = new AccRoleAccountFilter();
    roleAccountFilter.setSystemId(roleSystemId);
    roleAccountDtos = roleAccountService.find(roleAccountFilter, null).getContent();
    Assert.assertEquals(5, roleAccountDtos.size());
    roleAccountDtos.forEach(roleAccountDto -> {
        SysRoleSystemFilter roleSystemFilter = new SysRoleSystemFilter();
        roleSystemFilter.setRoleId(roleAccountDto.getRole());
        List<SysRoleSystemDto> roleSystemDtos = roleSystemService.find(roleSystemFilter, null).getContent();
        Assert.assertEquals(1, roleSystemDtos.size());
        SysRoleSystemDto roleSystem = roleSystemDtos.get(0);
        // Check mapping attribute (should be email).
        SysRoleSystemAttributeFilter roleSystemAttributeFilter = new SysRoleSystemAttributeFilter();
        roleSystemAttributeFilter.setRoleSystemId(roleSystem.getId());
        List<SysRoleSystemAttributeDto> roleSystemAttributeDtos = roleSystemAttributeService.find(roleSystemAttributeFilter, null).getContent();
        Assert.assertEquals(1, roleSystemAttributeDtos.size());
        Assert.assertEquals(userEmailAttribute.getId(), roleSystemAttributeDtos.get(0).getSystemAttributeMapping());
        String transformScript = roleSystemAttributeDtos.get(0).getTransformScript();
        Assert.assertTrue(transformScript.contains(updatedScriptValue));
    });
    // Delete old log.
    syncLogService.delete(log);
    // Run sync again. Sync has enabled diff feature -> all changes should be ignored.
    helper.startSynchronization(syncConfigCustom);
    // 
    logFilter = new SysSyncLogFilter();
    logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
    logs = syncLogService.find(logFilter, null).getContent();
    Assert.assertEquals(1, logs.size());
    log = logs.get(0);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    helper.checkSyncLog(syncConfigCustom, SynchronizationActionType.UPDATE_ENTITY, 5, OperationResultType.IGNORE);
    cleanAfterTest(syncConfigCustom, roleSystemId, log, roleAccountDtos);
}
Also used : SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) AccRoleAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccRoleAccountFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) SysRoleSystemAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemAttributeFilter) SysRoleSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncRoleConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncRoleConfigDto) AccRoleAccountDto(eu.bcvsolutions.idm.acc.dto.AccRoleAccountDto) SysSyncLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 65 with SysRoleSystemAttributeDto

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

the class DefaultSysProvisioningServiceTest method initOverloadedAttributes.

private void initOverloadedAttributes(List<SysRoleSystemAttributeDto> overloadingAttributes, List<AttributeMapping> defaultAttributes) {
    SysSchemaAttributeDto attOne = new SysSchemaAttributeDto();
    attOne.setName("attOne");
    attOne.setObjectClass(objectClasses.get(0).getId());
    attOne.setClassType(String.class.getName());
    attOne = schemaAttributeService.save(attOne);
    SysSchemaAttributeDto attTwo = new SysSchemaAttributeDto();
    attTwo.setName("attTwo");
    attTwo.setObjectClass(objectClasses.get(0).getId());
    attTwo.setClassType(String.class.getName());
    attTwo = schemaAttributeService.save(attTwo);
    SysSystemAttributeMappingDto defOne = new SysSystemAttributeMappingDto();
    defOne.setEntityAttribute(true);
    defOne.setIdmPropertyName("one");
    defOne.setName("defOne");
    defOne.setDisabledAttribute(true);
    defOne.setSchemaAttribute(attOne.getId());
    defOne.setSystemMapping(systemMapping.getId());
    defOne = systemAttributeMappingService.save(defOne);
    defaultAttributes.add(defOne);
    SysSystemAttributeMappingDto defTwo = new SysSystemAttributeMappingDto();
    defTwo.setEntityAttribute(true);
    defTwo.setIdmPropertyName("two");
    defTwo.setName("defTwo");
    defTwo.setSchemaAttribute(attTwo.getId());
    defTwo.setSystemMapping(systemMapping.getId());
    defTwo = systemAttributeMappingService.save(defTwo);
    defaultAttributes.add(defTwo);
    IdmRoleDto roleTwo = new IdmRoleDto();
    roleTwo.setCode("roleTwo");
    roleTwo.setPriority(100);
    roleTwo = roleService.save(roleTwo);
    IdmRoleDto roleOne = new IdmRoleDto();
    roleOne.setCode("roleOne");
    roleOne.setPriority(100);
    roleOne = roleService.save(roleOne);
    SysRoleSystemDto roleSystemTwo = new SysRoleSystemDto();
    roleSystemTwo.setRole(roleTwo.getId());
    roleSystemTwo.setSystem(system.getId());
    roleSystemTwo.setSystemMapping(systemMapping.getId());
    roleSystemTwo = roleSystemService.save(roleSystemTwo);
    SysRoleSystemDto roleSystemOne = new SysRoleSystemDto();
    roleSystemOne.setRole(roleOne.getId());
    roleSystemOne.setSystem(system.getId());
    roleSystemOne.setSystemMapping(systemMapping.getId());
    roleSystemOne = roleSystemService.save(roleSystemOne);
    SysRoleSystemAttributeDto overloadedRoleOne = new SysRoleSystemAttributeDto();
    overloadedRoleOne.setSystemAttributeMapping(defOne.getId());
    overloadedRoleOne.setEntityAttribute(true);
    overloadedRoleOne.setIdmPropertyName("one");
    overloadedRoleOne.setName("defOneOverloaded");
    overloadedRoleOne.setDisabledDefaultAttribute(false);
    overloadedRoleOne.setRoleSystem(roleSystemOne.getId());
    overloadedRoleOne = roleSystemAttributeService.save(overloadedRoleOne);
    overloadingAttributes.add(overloadedRoleOne);
    SysRoleSystemAttributeDto overloadedRoleTwo = new SysRoleSystemAttributeDto();
    overloadedRoleTwo.setSystemAttributeMapping(defOne.getId());
    overloadedRoleTwo.setEntityAttribute(true);
    overloadedRoleTwo.setIdmPropertyName("one");
    overloadedRoleTwo.setName("defOneOverloadedRoleTwo");
    overloadedRoleTwo.setDisabledDefaultAttribute(false);
    overloadedRoleTwo.setRoleSystem(roleSystemTwo.getId());
    overloadedRoleTwo = roleSystemAttributeService.save(overloadedRoleTwo);
    overloadingAttributes.add(overloadedRoleTwo);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)

Aggregations

SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)65 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)50 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)47 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)44 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)42 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)41 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)36 Test (org.junit.Test)34 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)30 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)25 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)20 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)20 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)19 UUID (java.util.UUID)19 ArrayList (java.util.ArrayList)17 SysRoleSystemAttributeService (eu.bcvsolutions.idm.acc.service.api.SysRoleSystemAttributeService)16 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)16 List (java.util.List)16 Autowired (org.springframework.beans.factory.annotation.Autowired)16 AttributeMappingStrategyType (eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType)15