use of eu.bcvsolutions.idm.acc.service.api.ConnectorType 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);
}
use of eu.bcvsolutions.idm.acc.service.api.ConnectorType in project CzechIdMng by bcvsolutions.
the class AdGroupConnectorTypeTest method testReopenSystem.
@Test
public void testReopenSystem() {
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);
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);
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);
assertNotNull(loadedConnectorTypeDto.getMetadata().get(MockAdGroupConnectorType.PORT));
assertNotNull(loadedConnectorTypeDto.getMetadata().get(MockAdGroupConnectorType.HOST));
assertNotNull(loadedConnectorTypeDto.getMetadata().get(MockAdGroupConnectorType.USER));
assertNotNull(loadedConnectorTypeDto.getMetadata().get(MockAdGroupConnectorType.SSL_SWITCH));
assertNotNull(loadedConnectorTypeDto.getMetadata().get(MockAdGroupConnectorType.GROUP_CONTAINER_KEY));
assertNotNull(loadedConnectorTypeDto.getMetadata().get(MockAdGroupConnectorType.GROUP_SYNC_ID));
assertTrue(Boolean.parseBoolean(loadedConnectorTypeDto.getMetadata().get(SysSyncRoleConfig_.membershipSwitch.getName())));
assertTrue(Boolean.parseBoolean(loadedConnectorTypeDto.getMetadata().get(SysSyncRoleConfig_.assignCatalogueSwitch.getName())));
assertTrue(Boolean.parseBoolean(loadedConnectorTypeDto.getMetadata().get(SysSyncRoleConfig_.assignRoleSwitch.getName())));
assertTrue(Boolean.parseBoolean(loadedConnectorTypeDto.getMetadata().get(SysSyncRoleConfig_.assignRoleRemoveSwitch.getName())));
assertTrue(Boolean.parseBoolean(loadedConnectorTypeDto.getMetadata().get(SysSyncRoleConfig_.removeCatalogueRoleSwitch.getName())));
assertNull(loadedConnectorTypeDto.getMetadata().get(MockAdGroupConnectorType.MEMBER_SYSTEM_MAPPING));
// Clean
systemService.delete(systemDto);
}
use of eu.bcvsolutions.idm.acc.service.api.ConnectorType 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.service.api.ConnectorType in project CzechIdMng by bcvsolutions.
the class AdGroupConnectorTypeTest method testStepFour.
@Test
public void testStepFour() {
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);
// Check containers in connector configuration.
systemDto = systemService.get(systemDto.getId());
IdmFormDefinitionDto connectorFormDefinition = systemService.getConnectorFormDefinition(systemDto);
String newGroupContainers = containersToString(getValuesFromConnectorInstance(MockAdGroupConnectorType.BASE_CONTEXT_GROUP_KEY, systemDto, connectorFormDefinition));
assertEquals(groupContainersMock.trim(), newGroupContainers.trim());
// 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 -> RoleSynchronizationExecutor.ROLE_MEMBERSHIP_ID_FIELD.equals(attribute.getIdmPropertyName())));
assertTrue(attributeMappingDtos.stream().anyMatch(attribute -> RoleSynchronizationExecutor.ROLE_MEMBERS_FIELD.equals(attribute.getIdmPropertyName())));
assertTrue(attributeMappingDtos.stream().anyMatch(attribute -> RoleSynchronizationExecutor.ROLE_FORWARD_ACM_FIELD.equals(attribute.getIdmPropertyName())));
assertTrue(attributeMappingDtos.stream().anyMatch(attribute -> RoleSynchronizationExecutor.ROLE_SKIP_VALUE_IF_EXCLUDED_FIELD.equals(attribute.getIdmPropertyName())));
assertTrue(attributeMappingDtos.stream().anyMatch(attribute -> RoleSynchronizationExecutor.ROLE_CATALOGUE_FIELD.equals(attribute.getIdmPropertyName())));
// Clean
systemService.delete(systemDto);
}
use of eu.bcvsolutions.idm.acc.service.api.ConnectorType in project CzechIdMng by bcvsolutions.
the class AdGroupConnectorTypeTest method testAssignUserToGroup.
@Test
public void testAssignUserToGroup() {
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());
connectorTypeDto.setWizardStepName(MockAdGroupConnectorType.STEP_CREATE_USER_TEST);
// Execute step for testing permissions to create user.
ConnectorTypeDto stepExecutedResult = connectorManager.execute(connectorTypeDto);
String entityStateId = stepExecutedResult.getMetadata().get(MockAdGroupConnectorType.ENTITY_STATE_WITH_TEST_CREATED_USER_DN_KEY);
assertNotNull(entityStateId);
IdmEntityStateDto entityStateDto = entityStateService.get(UUID.fromString(entityStateId));
assertNotNull(entityStateDto);
connectorTypeDto.setWizardStepName(MockAdGroupConnectorType.STEP_ASSIGN_GROUP_TEST);
// Execute step for testing permissions to assign user to the group.
connectorManager.execute(connectorTypeDto);
entityStateDto = entityStateService.get(UUID.fromString(entityStateId));
assertNotNull(entityStateDto);
// Clean
entityStateService.delete(entityStateDto);
systemService.delete(systemDto);
}
Aggregations