use of eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto 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.dto.ConnectorTypeDto 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.ConnectorTypeDto 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.dto.ConnectorTypeDto 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);
}
use of eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto in project CzechIdMng by bcvsolutions.
the class AdGroupConnectorTypeTest method testStepOne.
@Test
public void testStepOne() {
ConnectorType connectorType = connectorManager.getConnectorType(MockAdGroupConnectorType.NAME);
ConnectorTypeDto connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
SysSystemDto systemDto = createSystem(this.getHelper().createName(), connectorTypeDto);
// Clean
systemService.delete(systemDto);
}
Aggregations