Search in sources :

Example 21 with SysSyncRoleConfigDto

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

the class RoleWorkflowAdSyncTest method doCreateSyncConfig.

private SysSyncRoleConfigDto doCreateSyncConfig(SysSystemDto system) {
    SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
    mappingFilter.setEntityType(SystemEntityType.ROLE);
    mappingFilter.setSystemId(system.getId());
    mappingFilter.setOperationType(SystemOperationType.SYNCHRONIZATION);
    List<SysSystemMappingDto> mappings = systemMappingService.find(mappingFilter, null).getContent();
    Assert.assertEquals(1, mappings.size());
    SysSystemMappingDto mapping = mappings.get(0);
    SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
    attributeMappingFilter.setSystemMappingId(mapping.getId());
    List<SysSystemAttributeMappingDto> attributes = schemaAttributeMappingService.find(attributeMappingFilter, null).getContent();
    SysSystemAttributeMappingDto uidAttribute = attributes.stream().filter(attribute -> {
        return attribute.isUid();
    }).findFirst().orElse(null);
    // Create default synchronization config
    SysSyncRoleConfigDto syncConfigCustom = new SysSyncRoleConfigDto();
    syncConfigCustom.setReconciliation(true);
    syncConfigCustom.setCustomFilter(false);
    syncConfigCustom.setSystemMapping(mapping.getId());
    syncConfigCustom.setCorrelationAttribute(uidAttribute.getId());
    syncConfigCustom.setName(SYNC_CONFIG_NAME);
    syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
    syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.LINK_AND_UPDATE_ENTITY);
    syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
    syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.DELETE_ENTITY);
    syncConfigCustom = (SysSyncRoleConfigDto) syncConfigService.save(syncConfigCustom);
    SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
    configFilter.setSystemId(system.getId());
    Assert.assertEquals(1, syncConfigService.find(configFilter, null).getTotalElements());
    return syncConfigCustom;
}
Also used : SysSyncRoleConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncRoleConfigDto) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)

Example 22 with SysSyncRoleConfigDto

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

the class RoleWorkflowAdSyncTest method n5_testSyncWithWfSituationUnlinked.

@Test
public void n5_testSyncWithWfSituationUnlinked() {
    SysSystemDto system = initData();
    IdmRoleFilter roleFilter = new IdmRoleFilter();
    roleFilter.setText(ROLE_NAME);
    List<IdmRoleDto> roles = roleService.find(roleFilter, null).getContent();
    Assert.assertEquals(0, roles.size());
    IdmRoleDto role = new IdmRoleDto();
    role.setCode(ROLE_NAME);
    roleService.save(role);
    Assert.assertNotNull(system);
    SysSyncRoleConfigDto config = doCreateSyncConfig(system);
    config.setLinkedActionWfKey(wfExampleKey);
    config.setMissingAccountActionWfKey(wfExampleKey);
    config.setMissingEntityActionWfKey(wfExampleKey);
    config.setUnlinkedActionWfKey(wfExampleKey);
    config = (SysSyncRoleConfigDto) syncConfigService.save(config);
    // Start sync
    helper.startSynchronization(config);
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.UNLINKED, 1, OperationResultType.WF);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    roles = roleService.find(roleFilter, null).getContent();
    Assert.assertEquals(1, roles.size());
    role = roles.get(0);
    List<IdmFormValueDto> dnValues = formService.getValues(role, ATTRIBUTE_DN);
    Assert.assertEquals(1, dnValues.size());
    Assert.assertEquals(ATTRIBUTE_DN_VALUE, dnValues.get(0).getValue());
    IdmRoleCatalogueDto catalogueFirst = getCatalogueByCode(CATALOGUE_CODE_FIRST);
    IdmRoleCatalogueDto catalogueSecond = getCatalogueByCode(CATALOGUE_CODE_SECOND);
    Assert.assertNotNull(catalogueFirst);
    Assert.assertNotNull(catalogueSecond);
    // Delete log
    syncLogService.delete(log);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSyncRoleConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncRoleConfigDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 23 with SysSyncRoleConfigDto

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

the class AdGroupConnectorTypeTest method testOfFullSync.

@Test
public void testOfFullSync() {
    ConnectorType connectorType = connectorManager.getConnectorType(MockAdGroupConnectorType.NAME);
    ConnectorTypeDto connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
    SysSystemDto systemDto = createSystem(this.getHelper().createName(), connectorTypeDto);
    connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.SYSTEM_DTO_KEY, systemDto.getId().toString());
    // Create system with members.
    SysSystemDto memberSystemDto = createMemberSystem();
    SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
    mappingFilter.setSystemId(memberSystemDto.getId());
    mappingFilter.setOperationType(SystemOperationType.PROVISIONING);
    mappingFilter.setEntityType(SystemEntityType.IDENTITY);
    SysSystemMappingDto mappingDto = mappingService.find(mappingFilter, null).getContent().stream().findFirst().orElse(null);
    assertNotNull(mappingDto);
    StringBuilder sb = new StringBuilder();
    sb.append(this.getHelper().createName());
    sb.append(AdGroupConnectorType.LINE_SEPARATOR);
    sb.append(this.getHelper().createName());
    String groupContainersMock = sb.toString();
    connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.GROUP_CONTAINER_KEY, groupContainersMock);
    connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.MEMBER_SYSTEM_MAPPING, mappingDto.getId().toString());
    connectorTypeDto.setWizardStepName(MockAdGroupConnectorType.STEP_FOUR);
    // Generate mock schema.
    generateMockSchema(systemDto);
    IdmRoleCatalogueDto mainCatalog = getHelper().createRoleCatalogue(getHelper().createName());
    // Enable wizard switches.
    connectorTypeDto.getMetadata().put(SysSyncRoleConfig_.membershipSwitch.getName(), Boolean.TRUE.toString());
    connectorTypeDto.getMetadata().put(SysSyncRoleConfig_.assignCatalogueSwitch.getName(), Boolean.TRUE.toString());
    connectorTypeDto.getMetadata().put(SysSyncRoleConfig_.assignRoleSwitch.getName(), Boolean.TRUE.toString());
    connectorTypeDto.getMetadata().put(SysSyncRoleConfig_.assignRoleRemoveSwitch.getName(), Boolean.TRUE.toString());
    connectorTypeDto.getMetadata().put(SysSyncRoleConfig_.removeCatalogueRoleSwitch.getName(), Boolean.TRUE.toString());
    connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.MAIN_ROLE_CATALOG, mainCatalog.getId().toString());
    // Execute step four.
    connectorManager.execute(connectorTypeDto);
    SysSyncConfigFilter syncConfigFilter = new SysSyncConfigFilter();
    syncConfigFilter.setSystemId(systemDto.getId());
    AbstractSysSyncConfigDto syncConfigDto = syncConfigService.find(syncConfigFilter, null).getContent().stream().findFirst().orElse(null);
    assertTrue(syncConfigDto instanceof SysSyncRoleConfigDto);
    SysSyncRoleConfigDto syncRoleConfigDto = (SysSyncRoleConfigDto) syncConfigDto;
    assertTrue(syncRoleConfigDto.isMembershipSwitch());
    assertTrue(syncRoleConfigDto.isRemoveCatalogueRoleSwitch());
    assertTrue(syncRoleConfigDto.isAssignRoleRemoveSwitch());
    assertTrue(syncRoleConfigDto.isAssignRoleSwitch());
    assertTrue(syncRoleConfigDto.isAssignCatalogueSwitch());
    assertNotNull(syncRoleConfigDto.getAssignCatalogueMappingAttribute());
    assertNotNull(syncRoleConfigDto.getSkipValueIfExcludedMappingAttribute());
    assertNotNull(syncRoleConfigDto.getForwardAcmMappingAttribute());
    assertNotNull(syncRoleConfigDto.getRoleMembersMappingAttribute());
    assertNotNull(syncRoleConfigDto.getRoleIdentifiersMappingAttribute());
    assertNotNull(syncRoleConfigDto.getMemberIdentifierAttribute());
    assertNotNull(syncRoleConfigDto.getMemberOfAttribute());
    // Clean
    systemService.delete(systemDto);
    systemService.delete(memberSystemDto);
}
Also used : ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncRoleConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncRoleConfigDto) AdGroupConnectorType(eu.bcvsolutions.idm.acc.connector.AdGroupConnectorType) MockAdUserConnectorType(eu.bcvsolutions.idm.acc.service.impl.mock.MockAdUserConnectorType) ConnectorType(eu.bcvsolutions.idm.acc.service.api.ConnectorType) MockAdGroupConnectorType(eu.bcvsolutions.idm.acc.service.impl.mock.MockAdGroupConnectorType) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 24 with SysSyncRoleConfigDto

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

the class AdGroupConnectorTypeTest method testOfDefaultSync.

@Test
public void testOfDefaultSync() {
    ConnectorType connectorType = connectorManager.getConnectorType(MockAdGroupConnectorType.NAME);
    ConnectorTypeDto connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
    SysSystemDto systemDto = createSystem(this.getHelper().createName(), connectorTypeDto);
    connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.SYSTEM_DTO_KEY, systemDto.getId().toString());
    StringBuilder sb = new StringBuilder();
    sb.append(this.getHelper().createName());
    sb.append(AdGroupConnectorType.LINE_SEPARATOR);
    sb.append(this.getHelper().createName());
    String groupContainersMock = sb.toString();
    connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.GROUP_CONTAINER_KEY, groupContainersMock);
    connectorTypeDto.setWizardStepName(MockAdGroupConnectorType.STEP_FOUR);
    // Generate mock schema.
    generateMockSchema(systemDto);
    // Execute step four.
    connectorManager.execute(connectorTypeDto);
    SysSyncConfigFilter syncConfigFilter = new SysSyncConfigFilter();
    syncConfigFilter.setSystemId(systemDto.getId());
    AbstractSysSyncConfigDto syncConfigDto = syncConfigService.find(syncConfigFilter, null).getContent().stream().findFirst().orElse(null);
    assertTrue(syncConfigDto instanceof SysSyncRoleConfigDto);
    SysSyncRoleConfigDto syncRoleConfigDto = (SysSyncRoleConfigDto) syncConfigDto;
    assertFalse(syncRoleConfigDto.isMembershipSwitch());
    assertFalse(syncRoleConfigDto.isAssignRoleSwitch());
    assertFalse(syncRoleConfigDto.isAssignCatalogueSwitch());
    assertFalse(syncRoleConfigDto.isForwardAcmSwitch());
    assertFalse(syncRoleConfigDto.isSkipValueIfExcludedSwitch());
    assertNotNull(syncRoleConfigDto.getAssignCatalogueMappingAttribute());
    assertNotNull(syncRoleConfigDto.getSkipValueIfExcludedMappingAttribute());
    assertNotNull(syncRoleConfigDto.getForwardAcmMappingAttribute());
    assertNotNull(syncRoleConfigDto.getRoleMembersMappingAttribute());
    assertNotNull(syncRoleConfigDto.getRoleIdentifiersMappingAttribute());
    assertNull(syncRoleConfigDto.getMemberIdentifierAttribute());
    assertNull(syncRoleConfigDto.getMemberOfAttribute());
    // Clean
    systemService.delete(systemDto);
}
Also used : ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncRoleConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncRoleConfigDto) AdGroupConnectorType(eu.bcvsolutions.idm.acc.connector.AdGroupConnectorType) MockAdUserConnectorType(eu.bcvsolutions.idm.acc.service.impl.mock.MockAdUserConnectorType) ConnectorType(eu.bcvsolutions.idm.acc.service.api.ConnectorType) MockAdGroupConnectorType(eu.bcvsolutions.idm.acc.service.impl.mock.MockAdGroupConnectorType) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 25 with SysSyncRoleConfigDto

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

the class DefaultSysSyncConfigService method toDto.

@Override
protected AbstractSysSyncConfigDto toDto(SysSyncConfig entity, AbstractSysSyncConfigDto dto, SysSyncConfigFilter filter) {
    AbstractSysSyncConfigDto result = super.toDto(entity, dto, filter);
    // in the table of sync -> UX)
    if (filter != null && filter.getIncludeLastLog() != null && filter.getIncludeLastLog()) {
        Assert.notNull(result.getId(), "Result identifier is required.");
        SysSyncLogFilter syncLogFilter = new SysSyncLogFilter();
        syncLogFilter.setSynchronizationConfigId(result.getId());
        List<SysSyncLogDto> logs = syncLogService.find(syncLogFilter, PageRequest.of(0, 1, Direction.DESC, SysSyncLog_.created.getName())).getContent();
        if (!logs.isEmpty()) {
            result.setLastSyncLog(logs.get(0));
        }
    }
    if (result instanceof SysSyncRoleConfigDto) {
        SysSyncRoleConfigDto roleConfigDto = (SysSyncRoleConfigDto) result;
        SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
        attributeMappingFilter.setSystemMappingId(roleConfigDto.getSystemMapping());
        attributeMappingFilter.setDisabledAttribute(Boolean.FALSE);
        // Check if exist mapping attribute for 'Forward ACM'.
        attributeMappingFilter.setIdmPropertyName(RoleSynchronizationExecutor.ROLE_FORWARD_ACM_FIELD);
        SysSystemAttributeMappingDto attributeMappingDto = systemAttributeMappingService.find(attributeMappingFilter, null).getContent().stream().findFirst().orElse(null);
        if (attributeMappingDto != null) {
            roleConfigDto.setForwardAcmMappingAttribute(attributeMappingDto.getId());
            roleConfigDto.getEmbedded().put("forwardAcmMappingAttribute", attributeMappingDto);
        }
        // Check if exist mapping attribute for 'Skip value if excluded'.
        attributeMappingFilter.setIdmPropertyName(RoleSynchronizationExecutor.ROLE_SKIP_VALUE_IF_EXCLUDED_FIELD);
        attributeMappingDto = systemAttributeMappingService.find(attributeMappingFilter, null).getContent().stream().findFirst().orElse(null);
        if (attributeMappingDto != null) {
            roleConfigDto.setSkipValueIfExcludedMappingAttribute(attributeMappingDto.getId());
            roleConfigDto.getEmbedded().put("skipValueIfExcludedMappingAttribute", attributeMappingDto);
        }
        // Check if exist mapping attribute for 'role catalog'.
        attributeMappingFilter.setIdmPropertyName(RoleSynchronizationExecutor.ROLE_CATALOGUE_FIELD);
        attributeMappingDto = systemAttributeMappingService.find(attributeMappingFilter, null).getContent().stream().findFirst().orElse(null);
        if (attributeMappingDto != null) {
            roleConfigDto.setAssignCatalogueMappingAttribute(attributeMappingDto.getId());
            roleConfigDto.getEmbedded().put("assignCatalogueMappingAttribute", attributeMappingDto);
        }
        // Check if exist mapping attribute for 'role members'.
        attributeMappingFilter.setIdmPropertyName(RoleSynchronizationExecutor.ROLE_MEMBERS_FIELD);
        attributeMappingDto = systemAttributeMappingService.find(attributeMappingFilter, null).getContent().stream().findFirst().orElse(null);
        if (attributeMappingDto != null) {
            roleConfigDto.setRoleMembersMappingAttribute(attributeMappingDto.getId());
            roleConfigDto.getEmbedded().put("roleMembersMappingAttribute", attributeMappingDto);
        }
        // Check if exist mapping attribute for 'role identifier'.
        attributeMappingFilter.setIdmPropertyName(RoleSynchronizationExecutor.ROLE_MEMBERSHIP_ID_FIELD);
        attributeMappingDto = systemAttributeMappingService.find(attributeMappingFilter, null).getContent().stream().findFirst().orElse(null);
        if (attributeMappingDto != null) {
            roleConfigDto.setRoleIdentifiersMappingAttribute(attributeMappingDto.getId());
            roleConfigDto.getEmbedded().put("roleIdentifiersMappingAttribute", attributeMappingDto);
        }
    }
    return result;
}
Also used : AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncRoleConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncRoleConfigDto) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSyncLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)

Aggregations

SysSyncRoleConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncRoleConfigDto)34 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)26 Test (org.junit.Test)23 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)22 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)21 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)20 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)20 UUID (java.util.UUID)18 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)15 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)15 IdmRoleCatalogueDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto)15 AccRoleAccountDto (eu.bcvsolutions.idm.acc.dto.AccRoleAccountDto)14 AccRoleAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccRoleAccountFilter)14 SysSyncLogFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter)13 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)12 AbstractBulkActionTest (eu.bcvsolutions.idm.test.api.AbstractBulkActionTest)12 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)11 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)11 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)10 SysRoleSystemFilter (eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter)10