use of eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto in project CzechIdMng by bcvsolutions.
the class AdUserConnectorTypeTest method testStepFour.
@Test
public void testStepFour() {
ConnectorType connectorType = connectorManager.getConnectorType(MockAdUserConnectorType.NAME);
ConnectorTypeDto connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
SysSystemDto systemDto = createSystem(this.getHelper().createName(), connectorTypeDto);
connectorTypeDto.getMetadata().put(MockAdUserConnectorType.SYSTEM_DTO_KEY, systemDto.getId().toString());
String newUserContainerMock = this.getHelper().createName();
connectorTypeDto.getMetadata().put(MockAdUserConnectorType.NEW_USER_CONTAINER_KEY, newUserContainerMock);
String userContainerMock = this.getHelper().createName();
connectorTypeDto.getMetadata().put(MockAdUserConnectorType.USER_SEARCH_CONTAINER_KEY, userContainerMock);
String deletedUserContainerMock = this.getHelper().createName();
connectorTypeDto.getMetadata().put(MockAdUserConnectorType.DELETE_USER_CONTAINER_KEY, deletedUserContainerMock);
String domainMock = this.getHelper().createName();
connectorTypeDto.getMetadata().put(MockAdUserConnectorType.DOMAIN_KEY, domainMock);
connectorTypeDto.setWizardStepName(MockAdUserConnectorType.STEP_FOUR);
// Generate mock schema.
generateMockSchema(systemDto);
// Execute step four.
connectorManager.execute(connectorTypeDto);
// Check containers on the system's operationOptions.
systemDto = systemService.get(systemDto.getId());
IdmFormDefinitionDto operationOptionsFormDefinition = systemService.getOperationOptionsConnectorFormDefinition(systemDto);
String newUserContainer = getValueFromConnectorInstance(MockAdUserConnectorType.NEW_USER_CONTAINER_KEY, systemDto, operationOptionsFormDefinition);
assertEquals(newUserContainerMock, newUserContainer);
String deletedUserContainer = getValueFromConnectorInstance(MockAdUserConnectorType.DELETE_USER_CONTAINER_KEY, systemDto, operationOptionsFormDefinition);
// Protected mode is not active -> delete user container should be null.
assertNull(deletedUserContainer);
String searchUserContainer = getValueFromConnectorInstance(MockAdUserConnectorType.USER_SEARCH_CONTAINER_KEY, systemDto, operationOptionsFormDefinition);
assertEquals(userContainerMock, searchUserContainer);
String domain = getValueFromConnectorInstance(MockAdUserConnectorType.DOMAIN_KEY, systemDto, operationOptionsFormDefinition);
assertEquals(domainMock, domain);
// Check created schema attributes.
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(systemDto.getId());
List<SysSchemaAttributeDto> attributes = schemaAttributeService.find(schemaAttributeFilter, null).getContent();
assertTrue(attributes.stream().anyMatch(attribute -> IcAttributeInfo.NAME.equals(attribute.getName())));
assertTrue(attributes.stream().anyMatch(attribute -> IcAttributeInfo.PASSWORD.equals(attribute.getName())));
assertTrue(attributes.stream().anyMatch(attribute -> IcAttributeInfo.ENABLE.equals(attribute.getName())));
assertTrue(attributes.stream().anyMatch(attribute -> MockAdUserConnectorType.LDAP_GROUPS_ATTRIBUTE.equals(attribute.getName())));
assertTrue(attributes.stream().anyMatch(attribute -> MockAdUserConnectorType.SAM_ACCOUNT_NAME_ATTRIBUTE.equals(attribute.getName())));
// Check created schema attributes.
SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
attributeMappingFilter.setSystemId(systemDto.getId());
List<SysSystemAttributeMappingDto> attributeMappingDtos = attributeMappingService.find(attributeMappingFilter, null).getContent();
assertTrue(attributeMappingDtos.stream().anyMatch(attribute -> IcAttributeInfo.NAME.equals(attribute.getName())));
assertTrue(attributeMappingDtos.stream().anyMatch(attribute -> IcAttributeInfo.PASSWORD.equals(attribute.getName())));
assertTrue(attributeMappingDtos.stream().anyMatch(attribute -> IcAttributeInfo.ENABLE.equals(attribute.getName())));
assertTrue(attributeMappingDtos.stream().anyMatch(attribute -> MockAdUserConnectorType.LDAP_GROUPS_ATTRIBUTE.equals(attribute.getName())));
assertTrue(attributeMappingDtos.stream().anyMatch(attribute -> MockAdUserConnectorType.LDAP_GROUPS_ATTRIBUTE.equals(attribute.getName()) && AttributeMappingStrategyType.MERGE == attribute.getStrategyType()));
assertTrue(attributeMappingDtos.stream().anyMatch(attribute -> MockAdUserConnectorType.SAM_ACCOUNT_NAME_ATTRIBUTE.equals(attribute.getName())));
// Pairing sync wasn't created.
SysSyncConfigFilter syncConfigFilter = new SysSyncConfigFilter();
syncConfigFilter.setSystemId(systemDto.getId());
int syncCount = syncConfigService.find(syncConfigFilter, null).getContent().size();
assertEquals(0, syncCount);
// Clean
systemService.delete(systemDto);
}
use of eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto in project CzechIdMng by bcvsolutions.
the class AdUserConnectorTypeTest method testPairingSync.
@Test
public void testPairingSync() {
ConnectorType connectorType = connectorManager.getConnectorType(MockAdUserConnectorType.NAME);
ConnectorTypeDto connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
SysSystemDto systemDto = createSystem(this.getHelper().createName(), connectorTypeDto);
connectorTypeDto.getMetadata().put(MockAdUserConnectorType.SYSTEM_DTO_KEY, systemDto.getId().toString());
String newUserContainerMock = this.getHelper().createName();
connectorTypeDto.getMetadata().put(MockAdUserConnectorType.NEW_USER_CONTAINER_KEY, newUserContainerMock);
String userContainerMock = this.getHelper().createName();
connectorTypeDto.getMetadata().put(MockAdUserConnectorType.USER_SEARCH_CONTAINER_KEY, userContainerMock);
String deletedUserContainerMock = this.getHelper().createName();
connectorTypeDto.getMetadata().put(MockAdUserConnectorType.DELETE_USER_CONTAINER_KEY, deletedUserContainerMock);
String domainMock = this.getHelper().createName();
connectorTypeDto.getMetadata().put(MockAdUserConnectorType.DOMAIN_KEY, domainMock);
String defaultRoleMock = this.getHelper().createName();
connectorTypeDto.getMetadata().put(MockAdUserConnectorType.NEW_ROLE_WITH_SYSTEM_CODE, defaultRoleMock);
connectorTypeDto.setWizardStepName(MockAdUserConnectorType.STEP_FOUR);
// Activate pairing sync.
connectorTypeDto.getMetadata().put(MockAdUserConnectorType.PAIRING_SYNC_SWITCH_KEY, "true");
// Activate protected sync.
connectorTypeDto.getMetadata().put(MockAdUserConnectorType.PROTECTED_MODE_SWITCH_KEY, "true");
// Generate mock schema.
generateMockSchema(systemDto);
// Execute step four.
connectorManager.execute(connectorTypeDto);
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setSystemId(systemDto.getId());
mappingFilter.setOperationType(SystemOperationType.PROVISIONING);
mappingFilter.setEntityType(SystemEntityType.IDENTITY);
List<SysSystemMappingDto> mappingDtos = mappingService.find(mappingFilter, null).getContent();
assertEquals(1, mappingDtos.size());
// Protected mode is activated.
assertTrue(mappingDtos.get(0).isProtectionEnabled());
// Provisioning context is used.
assertTrue(mappingDtos.get(0).isAddContextConnectorObject());
mappingFilter.setOperationType(SystemOperationType.SYNCHRONIZATION);
mappingFilter.setEntityType(SystemEntityType.IDENTITY);
mappingDtos = mappingService.find(mappingFilter, null).getContent();
// Sync mapping must exists.
assertEquals(1, mappingDtos.size());
// Pairing sync should be created.
SysSyncConfigFilter syncConfigFilter = new SysSyncConfigFilter();
syncConfigFilter.setSystemId(systemDto.getId());
List<AbstractSysSyncConfigDto> configDtos = syncConfigService.find(syncConfigFilter, null).getContent();
assertEquals(1, configDtos.size());
SysSyncIdentityConfigDto sync = (SysSyncIdentityConfigDto) configDtos.get(0);
// Protected mode is activated.
assertEquals(SynchronizationInactiveOwnerBehaviorType.LINK_PROTECTED, sync.getInactiveOwnerBehavior());
assertNotNull(sync.getDefaultRole());
// Clean
systemService.delete(systemDto);
}
use of eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto in project CzechIdMng by bcvsolutions.
the class CrossDomainAdUserConnectorTypeTest method initSystem.
private SysSystemDto initSystem(ConnectorType connectorType) {
ConnectorTypeDto connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
SysSystemDto systemDto = createSystem(connectorType.getId() + "_" + this.getHelper().createName(), connectorTypeDto);
connectorTypeDto.getMetadata().put(MockCrossDomainAdUserConnectorType.SYSTEM_DTO_KEY, systemDto.getId().toString());
String newUserContainerMock = this.getHelper().createName();
connectorTypeDto.getMetadata().put(MockCrossDomainAdUserConnectorType.NEW_USER_CONTAINER_KEY, newUserContainerMock);
String userContainerMock = this.getHelper().createName();
connectorTypeDto.getMetadata().put(MockCrossDomainAdUserConnectorType.USER_SEARCH_CONTAINER_KEY, userContainerMock);
String deletedUserContainerMock = this.getHelper().createName();
connectorTypeDto.getMetadata().put(MockCrossDomainAdUserConnectorType.DELETE_USER_CONTAINER_KEY, deletedUserContainerMock);
String domainMock = this.getHelper().createName();
connectorTypeDto.getMetadata().put(MockCrossDomainAdUserConnectorType.DOMAIN_KEY, domainMock);
String defaultRoleMock = this.getHelper().createName();
connectorTypeDto.getMetadata().put(MockCrossDomainAdUserConnectorType.NEW_ROLE_WITH_SYSTEM_CODE, defaultRoleMock);
connectorTypeDto.setWizardStepName(MockCrossDomainAdUserConnectorType.STEP_FOUR);
// Activate pairing sync.
connectorTypeDto.getMetadata().put(MockCrossDomainAdUserConnectorType.PAIRING_SYNC_SWITCH_KEY, "true");
// Activate protected sync.
connectorTypeDto.getMetadata().put(MockCrossDomainAdUserConnectorType.PROTECTED_MODE_SWITCH_KEY, "true");
// Generate mock schema.
generateMockSchema(systemDto);
// Execute step four.
connectorManager.execute(connectorTypeDto);
return systemDto;
}
use of eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto in project CzechIdMng by bcvsolutions.
the class AbstractJdbcConnectorTypeTest method testJdbcFirstStep.
public void testJdbcFirstStep() {
// If not, whole test will be skipped.
if (!getJdbcConnectorTypeDriverName().equals(getDriver())) {
// Skip test.
return;
}
ConnectorTypeDto mockPostgresqlConnectorTypeDto = getConnectorTypeDto();
mockPostgresqlConnectorTypeDto.setReopened(false);
mockPostgresqlConnectorTypeDto.setId(this.getJdbcConnectorType());
ConnectorTypeDto jdbcConnectorTypeDto = connectorManager.load(mockPostgresqlConnectorTypeDto);
assertNotNull(jdbcConnectorTypeDto);
jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.HOST, this.getHost());
jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.PORT, this.getPort());
jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.DATABASE, this.getDatabase());
jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.USER, this.getUsername());
jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.PASSWORD, this.getPassword());
jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.TABLE, "idm_identity");
jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.KEY_COLUMN, "username");
jdbcConnectorTypeDto.setWizardStepName(AbstractJdbcConnectorType.STEP_ONE_CREATE_SYSTEM);
// Execute the first step.
ConnectorTypeDto stepExecutedResult = connectorManager.execute(jdbcConnectorTypeDto);
// The system had to be created.
BaseDto system = stepExecutedResult.getEmbedded().get(AbstractJdbcConnectorType.SYSTEM_DTO_KEY);
assertTrue(system instanceof SysSystemDto);
SysSystemDto systemDto = systemService.get(system.getId());
assertNotNull(systemDto);
// Load connector properties from created system.
IcConnectorInstance connectorInstance = systemService.getConnectorInstance(systemDto);
assertEquals("net.tirasa.connid.bundles.db.table.DatabaseTableConnector", connectorInstance.getConnectorKey().getConnectorName());
IdmFormDefinitionDto connectorFormDef = this.systemService.getConnectorFormDefinition(systemDto);
// Check host.
Assert.assertEquals(this.getHost(), getValueFromConnectorInstance(AbstractJdbcConnectorType.HOST, systemDto, connectorFormDef));
// Check port.
Assert.assertEquals(this.getPort(), getValueFromConnectorInstance(AbstractJdbcConnectorType.PORT, systemDto, connectorFormDef));
// Check database.
Assert.assertEquals(this.getDatabase(), getValueFromConnectorInstance(AbstractJdbcConnectorType.DATABASE, systemDto, connectorFormDef));
// Check user.
Assert.assertEquals(this.getUsername(), getValueFromConnectorInstance(AbstractJdbcConnectorType.USER, systemDto, connectorFormDef));
// Check password.
assertEquals("idm_identity", getValueFromConnectorInstance(AbstractJdbcConnectorType.TABLE, systemDto, connectorFormDef));
// Delete created system.
systemService.delete(systemDto);
}
use of eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto in project CzechIdMng by bcvsolutions.
the class AbstractJdbcConnectorTypeTest method testReopenSystemInWizard.
public void testReopenSystemInWizard() {
// If not, whole test will be skipped.
if (!getJdbcConnectorTypeDriverName().equals(getDriver())) {
// Skip test.
return;
}
ConnectorTypeDto mockPostgresqlConnectorTypeDto = getConnectorTypeDto();
mockPostgresqlConnectorTypeDto.setReopened(false);
mockPostgresqlConnectorTypeDto.setId(this.getJdbcConnectorType());
ConnectorTypeDto jdbcConnectorTypeDto = connectorManager.load(mockPostgresqlConnectorTypeDto);
assertNotNull(jdbcConnectorTypeDto);
jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.HOST, this.getHost());
jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.PORT, this.getPort());
jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.DATABASE, this.getDatabase());
jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.USER, this.getUsername());
jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.PASSWORD, this.getPassword());
jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.TABLE, "idm_identity");
jdbcConnectorTypeDto.getMetadata().put(AbstractJdbcConnectorType.KEY_COLUMN, "username");
jdbcConnectorTypeDto.setWizardStepName(AbstractJdbcConnectorType.STEP_ONE_CREATE_SYSTEM);
// Execute the first step.
ConnectorTypeDto stepExecutedResult = connectorManager.execute(jdbcConnectorTypeDto);
// The system had to be created.
BaseDto system = stepExecutedResult.getEmbedded().get(AbstractJdbcConnectorType.SYSTEM_DTO_KEY);
assertTrue(system instanceof SysSystemDto);
SysSystemDto systemDto = systemService.get(system.getId());
assertNotNull(systemDto);
// Load wizard data for existed system;
ConnectorType connectorTypeBySystem = connectorManager.findConnectorTypeBySystem(systemDto);
ConnectorTypeDto reopenSystem = getConnectorTypeDto();
reopenSystem.setReopened(true);
reopenSystem.setId(connectorTypeBySystem.getId());
reopenSystem.getEmbedded().put(PostgresqlConnectorType.SYSTEM_DTO_KEY, systemDto);
reopenSystem = connectorManager.load(reopenSystem);
assertNotNull(reopenSystem);
assertEquals(systemDto.getName(), reopenSystem.getMetadata().get(AbstractJdbcConnectorType.SYSTEM_NAME));
Assert.assertEquals(this.getHost(), reopenSystem.getMetadata().get(AbstractJdbcConnectorType.HOST));
Assert.assertEquals(this.getPort(), reopenSystem.getMetadata().get(AbstractJdbcConnectorType.PORT));
Assert.assertEquals(this.getDatabase(), reopenSystem.getMetadata().get(AbstractJdbcConnectorType.DATABASE));
Assert.assertEquals(this.getUsername(), reopenSystem.getMetadata().get(AbstractJdbcConnectorType.USER));
// Password cannot be returned!
Assert.assertNull(reopenSystem.getMetadata().get(AbstractJdbcConnectorType.PASSWORD));
assertEquals("idm_identity", reopenSystem.getMetadata().get(AbstractJdbcConnectorType.TABLE));
// Delete created system.
systemService.delete(systemDto);
}
Aggregations