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