Search in sources :

Example 41 with ConnectorTypeDto

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

the class AdGroupConnectorTypeTest method testReopenSystemWithoutOptionsAttributes.

@Test
public void testReopenSystemWithoutOptionsAttributes() {
    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());
    IdmFormDefinitionDto operationOptionsConnectorFormDefinition = systemService.getOperationOptionsConnectorFormDefinition(systemDto);
    // Try to find attribute for one of container. If exist -> change code = simulate delete.
    IdmFormAttributeDto userSearchContainerAttribute = operationOptionsConnectorFormDefinition.getMappedAttributeByCode(MockAdGroupConnectorType.USER_SEARCH_CONTAINER_KEY);
    if (userSearchContainerAttribute != null) {
        userSearchContainerAttribute.setCode(getHelper().createName());
        formService.saveAttribute(userSearchContainerAttribute);
    }
    connectorType = connectorManager.getConnectorType(MockAdGroupConnectorType.NAME);
    connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
    connectorTypeDto.setReopened(true);
    connectorTypeDto.getEmbedded().put(MockAdGroupConnectorType.SYSTEM_DTO_KEY, systemDto);
    connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.SYSTEM_DTO_KEY, systemDto.getId().toString());
    ConnectorTypeDto loadedConnectorTypeDto = connectorManager.load(connectorTypeDto);
    assertNotNull(loadedConnectorTypeDto);
    // Clean
    systemService.delete(systemDto);
}
Also used : ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) 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) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 42 with ConnectorTypeDto

use of eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto 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 43 with ConnectorTypeDto

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

the class AdGroupConnectorTypeTest method createSystem.

private SysSystemDto createSystem(String systemName, ConnectorTypeDto connectorTypeDto) {
    connectorTypeDto.setReopened(false);
    connectorManager.load(connectorTypeDto);
    assertNotNull(connectorTypeDto);
    String fakeHost = this.getHelper().createName();
    connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.HOST, fakeHost);
    connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.PORT, "636");
    connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.USER, fakeHost);
    connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.PASSWORD, fakeHost);
    connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.SSL_SWITCH, "false");
    connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.SYSTEM_NAME, systemName);
    connectorTypeDto.setWizardStepName(MockAdGroupConnectorType.STEP_ONE);
    // Execute the first step.
    ConnectorTypeDto stepExecutedResult = connectorManager.execute(connectorTypeDto);
    BaseDto systemDto = stepExecutedResult.getEmbedded().get(MockAdGroupConnectorType.SYSTEM_DTO_KEY);
    assertNotNull("System ID cannot be null!", systemDto);
    SysSystemDto system = systemService.get(systemDto.getId());
    assertNotNull(system);
    return system;
}
Also used : ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 44 with ConnectorTypeDto

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

the class DefaultConnectorManager method convertIcConnectorInfoToDto.

@Override
public ConnectorTypeDto convertIcConnectorInfoToDto(IcConnectorInfo info) {
    ConnectorTypeDto connectorTypeDto = new ConnectorTypeDto();
    connectorTypeDto.setId(info.getConnectorKey().getConnectorName());
    connectorTypeDto.setName(info.getConnectorDisplayName());
    connectorTypeDto.setModule(EntityUtils.getModule(this.getClass()));
    connectorTypeDto.setConnectorName(info.getConnectorKey().getConnectorName());
    connectorTypeDto.setIconKey("default-connector");
    connectorTypeDto.setVersion(info.getConnectorKey().getBundleVersion());
    connectorTypeDto.setHideParentConnector(true);
    connectorTypeDto.setOrder(1000);
    return connectorTypeDto;
}
Also used : ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto)

Example 45 with ConnectorTypeDto

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

the class CsvConnectorTypeTest method testCsvSecondStep.

@Test
public void testCsvSecondStep() {
    ConnectorTypeDto mockCsvConnectorTypeDto = new ConnectorTypeDto();
    mockCsvConnectorTypeDto.setReopened(false);
    mockCsvConnectorTypeDto.setId(CsvConnectorType.NAME);
    mockCsvConnectorTypeDto.setConnectorName(csvConnectorType.getConnectorName());
    ConnectorTypeDto csvConnectorTypeDto = connectorManager.load(mockCsvConnectorTypeDto);
    assertNotNull(csvConnectorTypeDto);
    csvConnectorTypeDto.getMetadata().put(CsvConnectorType.FILE_PATH, CSV_TEST_FILE);
    csvConnectorTypeDto.setWizardStepName(CsvConnectorType.STEP_ONE_CREATE_SYSTEM);
    // Execute the first step.
    ConnectorTypeDto stepExecutedResult = connectorManager.execute(csvConnectorTypeDto);
    // The system had to be created.
    BaseDto system = stepExecutedResult.getEmbedded().get(CsvConnectorType.SYSTEM_DTO_KEY);
    assertTrue(system instanceof SysSystemDto);
    SysSystemDto systemDto = systemService.get(system.getId());
    assertNotNull(systemDto);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(systemDto.getId());
    schemaAttributeFilter.setName("username");
    SysSchemaAttributeDto usernameAttributeDto = schemaAttributeService.find(schemaAttributeFilter, null).getContent().stream().findFirst().orElse(null);
    assertNotNull(usernameAttributeDto);
    // Set username attribute as primary attribute for second wizard step.
    stepExecutedResult.getMetadata().put(CsvConnectorType.PRIMARY_SCHEMA_ATTRIBUTE, usernameAttributeDto.getId().toString());
    // Execute the second step.
    csvConnectorTypeDto.setWizardStepName(CsvConnectorType.STEP_TWO_SELECT_PK);
    csvConnectorTypeDto.getMetadata().put(CsvConnectorType.SYSTEM_DTO_KEY, systemDto.getId().toString());
    connectorManager.execute(csvConnectorTypeDto);
    // Load connector properties from created system.
    IcConnectorConfiguration connectorConfiguration = systemService.getConnectorConfiguration(systemDto);
    IcConfigurationProperties configurationProperties = connectorConfiguration.getConfigurationProperties();
    // Check uid attribute.
    IcConfigurationProperty uidProperty = configurationProperties.getProperties().stream().filter(property -> CsvConnectorType.CONNECTOR_UID.equals(property.getName())).findFirst().orElse(null);
    assertNotNull(uidProperty);
    // UID attribute have to be "username" now.
    assertEquals(usernameAttributeDto.getName(), uidProperty.getValue());
    // Delete created system.
    systemService.delete(systemDto);
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) IcConfigurationProperty(eu.bcvsolutions.idm.ic.api.IcConfigurationProperty) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) IcConfigurationProperties(eu.bcvsolutions.idm.ic.api.IcConfigurationProperties) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

ConnectorTypeDto (eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto)51 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)43 Test (org.junit.Test)36 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)34 ConnectorType (eu.bcvsolutions.idm.acc.service.api.ConnectorType)33 MockAdUserConnectorType (eu.bcvsolutions.idm.acc.service.impl.mock.MockAdUserConnectorType)22 BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)18 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)16 AdGroupConnectorType (eu.bcvsolutions.idm.acc.connector.AdGroupConnectorType)14 MockAdGroupConnectorType (eu.bcvsolutions.idm.acc.service.impl.mock.MockAdGroupConnectorType)14 SysSystemMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter)13 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)11 AbstractConnectorType (eu.bcvsolutions.idm.acc.connector.AbstractConnectorType)8 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)8 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)8 CsvConnectorType (eu.bcvsolutions.idm.acc.connector.CsvConnectorType)7 DefaultConnectorType (eu.bcvsolutions.idm.acc.connector.DefaultConnectorType)7 PostgresqlConnectorType (eu.bcvsolutions.idm.acc.connector.PostgresqlConnectorType)7 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)7 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)7