Search in sources :

Example 1 with SysSyncRoleConfigDto

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

the class AdGroupConnectorTypeTest method testReuseNewCatalog.

@Test
public void testReuseNewCatalog() {
    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.NEW_ROLE_CATALOG, mainCatalog.getCode());
    // 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.isRemoveCatalogueRoleSwitch());
    assertTrue(syncRoleConfigDto.isAssignCatalogueSwitch());
    UUID mainCatalogueRoleNode = syncRoleConfigDto.getMainCatalogueRoleNode();
    assertEquals(mainCatalog.getId(), mainCatalogueRoleNode);
    UUID removeCatalogueRoleParentNode = syncRoleConfigDto.getRemoveCatalogueRoleParentNode();
    assertEquals(mainCatalog.getId(), removeCatalogueRoleParentNode);
    // 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) UUID(java.util.UUID) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 2 with SysSyncRoleConfigDto

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

the class AdGroupConnectorTypeTest method testCreateNewCatalog.

@Test
public void testCreateNewCatalog() {
    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);
    String mainCatalog = 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.NEW_ROLE_CATALOG, mainCatalog);
    // 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.isRemoveCatalogueRoleSwitch());
    assertTrue(syncRoleConfigDto.isAssignCatalogueSwitch());
    IdmRoleCatalogueDto roleCatalogueDto = roleCatalogueService.getByCode(mainCatalog);
    assertNotNull(roleCatalogueDto);
    UUID mainCatalogueRoleNode = syncRoleConfigDto.getMainCatalogueRoleNode();
    assertEquals(roleCatalogueDto.getId(), mainCatalogueRoleNode);
    UUID removeCatalogueRoleParentNode = syncRoleConfigDto.getRemoveCatalogueRoleParentNode();
    assertEquals(roleCatalogueDto.getId(), removeCatalogueRoleParentNode);
    // 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) UUID(java.util.UUID) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 3 with SysSyncRoleConfigDto

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

the class RoleWorkflowAdSyncTest method n91_testSyncWithWfSituationMissingResolveMember.

@Test
public void n91_testSyncWithWfSituationMissingResolveMember() {
    String valueOfMemberAtt = getHelper().createName();
    String nameOfEav = "externalIdentifier";
    configurationService.setValue("idm.pub.acc.syncRole.identity.eav.externalIdentifier.code", nameOfEav);
    configurationService.setValue("idm.pub.acc.syncRole.roles.attributeNameOfMembership", helper.getSchemaColumnName(ATTRIBUTE_MEMBER));
    IdmIdentityDto identity = this.getHelper().createIdentity();
    IdmFormAttributeDto attribute = helper.createEavAttribute(nameOfEav, IdmIdentity.class, PersistentType.SHORTTEXT);
    helper.setEavValue(identity, attribute, IdmIdentity.class, valueOfMemberAtt, PersistentType.SHORTTEXT);
    SysSystemDto system = initData();
    this.getBean().deleteAllResourceData();
    this.getBean().addRoleToResource(ROLE_NAME, ATTRIBUTE_DN, valueOfMemberAtt);
    IdmRoleFilter roleFilter = new IdmRoleFilter();
    roleFilter.setText(ROLE_NAME);
    List<IdmRoleDto> roles = roleService.find(roleFilter, null).getContent();
    Assert.assertEquals(0, roles.size());
    IdmIdentityRoleFilter filter = new IdmIdentityRoleFilter();
    filter.setIdentityId(identity.getId());
    List<IdmIdentityRoleDto> content = identityRoleService.find(filter, null).getContent();
    Assert.assertEquals(0, content.size());
    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.MISSING_ENTITY, 1, OperationResultType.WF);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    roles = roleService.find(roleFilter, null).getContent();
    Assert.assertEquals(1, roles.size());
    content = identityRoleService.find(filter, null).getContent();
    Assert.assertEquals(1, content.size());
    identityRoleService.delete(content.get(0));
    // Delete log
    syncLogService.delete(log);
    configurationService.deleteValue("idm.pub.acc.syncRole.provisioningOfIdentities.system.code");
    configurationService.deleteValue("idm.pub.acc.syncRole.system.mapping.attributeMemberOf");
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSyncRoleConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncRoleConfigDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) 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 4 with SysSyncRoleConfigDto

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

the class RoleWorkflowAdSyncTest method n1_testSyncWithWfSituationMissingEntityDoNotCreateCatalog.

@Test
public void n1_testSyncWithWfSituationMissingEntityDoNotCreateCatalog() {
    configurationService.setBooleanValue("idm.pub.acc.syncRole.roleCatalog.ResolveCatalog", false);
    SysSystemDto system = initData();
    IdmRoleFilter roleFilter = new IdmRoleFilter();
    roleFilter.setText(ROLE_NAME);
    List<IdmRoleDto> roles = roleService.find(roleFilter, null).getContent();
    Assert.assertEquals(0, roles.size());
    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.MISSING_ENTITY, 1, OperationResultType.WF);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    roles = roleService.find(roleFilter, null).getContent();
    Assert.assertEquals(1, roles.size());
    IdmRoleDto 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.assertNull(catalogueFirst);
    Assert.assertNull(catalogueSecond);
    // Delete log
    syncLogService.delete(log);
    configurationService.setBooleanValue("idm.pub.acc.syncRole.roleCatalog.ResolveCatalog", true);
}
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 5 with SysSyncRoleConfigDto

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

the class RoleWorkflowAdSyncTest method n8_testSyncWithWfSituationMissingEntityOneFolderCatalog.

@Test
public void n8_testSyncWithWfSituationMissingEntityOneFolderCatalog() {
    configurationService.setValue("idm.pub.acc.syncRole.roles.allToOneCatalog", CATALOG_FOLDER);
    SysSystemDto system = initData();
    IdmRoleFilter roleFilter = new IdmRoleFilter();
    roleFilter.setText(ROLE_NAME);
    List<IdmRoleDto> roles = roleService.find(roleFilter, null).getContent();
    Assert.assertEquals(0, roles.size());
    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.MISSING_ENTITY, 1, OperationResultType.WF);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    roles = roleService.find(roleFilter, null).getContent();
    Assert.assertEquals(1, roles.size());
    IdmRoleDto 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(CATALOG_FOLDER);
    Assert.assertNotNull(catalogueFirst);
    Assert.assertFalse(!isRoleInCatalogue(role.getId(), CATALOG_FOLDER));
    // 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)

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