use of eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto in project CzechIdMng by bcvsolutions.
the class DefaultImportManager method validate.
/**
* Validate import batch
*
* @param tempDirectory
* @return
*/
private IdmExportImportDto validate(Path tempDirectory) {
Assert.notNull(tempDirectory, "Temp directory cannot be null!");
File manifest = Paths.get(tempDirectory.toString(), ExportManager.EXPORT_BATCH_FILE_NAME).toFile();
if (!manifest.exists()) {
throw new ResultCodeException(CoreResultCode.IMPORT_VALIDATION_FAILED_NO_MANIFEST, ImmutableMap.of("manifest", manifest.getAbsoluteFile()));
}
return (IdmExportImportDto) convertFileToDto(manifest, IdmExportImportDto.class, new ImportContext());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto in project CzechIdMng by bcvsolutions.
the class SystemExportBulkActionIntegrationTest method testExportAndImportMapping.
@Test
public void testExportAndImportMapping() {
SysSystemDto system = createSystem();
// Load configurations
List<SysSystemMappingDto> mappings = findMappings(system);
Assert.assertEquals(1, mappings.size());
SysSystemMappingDto originalMapping = mappings.get(0);
// Make export, upload, delete system and import
IdmExportImportDto importBatch = executeExportAndImport(system, SystemExportBulkAction.NAME);
system = systemService.get(system.getId());
Assert.assertNotNull(system);
mappings = findMappings(system);
Assert.assertEquals(1, mappings.size());
SysSystemMappingDto mapping = mappings.get(0);
Assert.assertEquals(originalMapping.getId(), mapping.getId());
SysSchemaObjectClassDto objectClassDto = new SysSchemaObjectClassDto();
objectClassDto.setId(mapping.getObjectClass());
helper.createMappingSystem(SystemEntityType.ROLE, objectClassDto);
mappings = findMappings(system);
Assert.assertEquals(2, mappings.size());
// Execute import (check authoritative mode)
importBatch = importManager.executeImport(importBatch, false);
Assert.assertNotNull(importBatch);
Assert.assertEquals(ExportImportType.IMPORT, importBatch.getType());
Assert.assertEquals(OperationState.EXECUTED, importBatch.getResult().getState());
// Second mapping had to be deleted!
mappings = findMappings(system);
Assert.assertEquals(1, mappings.size());
mapping = mappings.get(0);
Assert.assertEquals(originalMapping.getId(), mapping.getId());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto in project CzechIdMng by bcvsolutions.
the class SystemExportBulkActionIntegrationTest method testExportAndImportBreak.
@Test
public void testExportAndImportBreak() {
SysSystemDto system = createSystem();
SysProvisioningBreakConfigDto originalBreak = new SysProvisioningBreakConfigDto();
originalBreak.setSystem(system.getId());
originalBreak.setOperationType(ProvisioningEventType.CREATE);
originalBreak.setPeriod(10l);
originalBreak = provisioningBreakService.save(originalBreak);
// Make export, upload, delete system and import
IdmExportImportDto importBatch = executeExportAndImport(system, SystemExportBulkAction.NAME);
system = systemService.get(system.getId());
Assert.assertNotNull(system);
List<SysProvisioningBreakConfigDto> breaks = findBreaks(system);
Assert.assertEquals(1, breaks.size());
Assert.assertEquals(originalBreak.getId(), breaks.get(0).getId());
// Create redundant break
SysProvisioningBreakConfigDto redundantBreak = new SysProvisioningBreakConfigDto();
redundantBreak.setSystem(system.getId());
redundantBreak.setPeriod(10l);
redundantBreak.setOperationType(ProvisioningEventType.UPDATE);
redundantBreak = provisioningBreakService.save(redundantBreak);
// Execute import (check authoritative mode)
importBatch = importManager.executeImport(importBatch, false);
Assert.assertNotNull(importBatch);
Assert.assertEquals(ExportImportType.IMPORT, importBatch.getType());
Assert.assertEquals(OperationState.EXECUTED, importBatch.getResult().getState());
// Redundant sync had to be deleted!
redundantBreak = provisioningBreakService.get(redundantBreak.getId());
Assert.assertNull(redundantBreak);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto in project CzechIdMng by bcvsolutions.
the class SystemExportBulkActionIntegrationTest method testExportAndUseRemoteSystem.
@Test
public void testExportAndUseRemoteSystem() {
SysConnectorServerDto connectorServer = new SysConnectorServerDto();
String host = getHelper().createName();
connectorServer.setHost(host);
connectorServer.setPort(43);
String password = "password";
connectorServer.setPassword(new GuardedString(password));
connectorServer = remoteServerService.save(connectorServer);
SysSystemDto system = createSystem();
system.setRemoteServer(connectorServer.getId());
system = systemService.save(system);
Assert.assertFalse(system.isDisabled());
// Make export, upload, delete system and import
IdmExportImportDto importBatch = executeExportAndImport(system, SystemExportBulkAction.NAME);
system = systemService.get(system.getId());
Assert.assertNotNull(system);
Assert.assertNotNull(system.getRemoteServer());
Assert.assertTrue(system.isDisabled());
Assert.assertNotNull(system.getConnectorServer());
Assert.assertNotNull(system.getConnectorServer().getHost());
// Password is preserved from remote server
Assert.assertEquals(password, confidentialStorage.getGuardedString(system.getId(), SysSystem.class, SysSystemService.REMOTE_SERVER_PASSWORD).asString());
//
// get remote server
SysConnectorServerDto importedConnectorServer = remoteServerService.get(system.getRemoteServer());
Assert.assertEquals(connectorServer.getId(), importedConnectorServer.getId());
Assert.assertEquals(connectorServer.getHost(), importedConnectorServer.getHost());
Assert.assertEquals(connectorServer.getPort(), importedConnectorServer.getPort());
Assert.assertEquals(connectorServer.isUseSsl(), importedConnectorServer.isUseSsl());
Assert.assertEquals(connectorServer.getTimeout(), importedConnectorServer.getTimeout());
// Password is preserved
Assert.assertEquals(password, remoteServerService.getPassword(importedConnectorServer.getId()).asString());
// delete remote server and create new with the same setting => find by example
deleteRemoteServer(system);
//
connectorServer = new SysConnectorServerDto();
connectorServer.setHost(host);
connectorServer.setPort(43);
connectorServer.setPassword(new GuardedString(password));
connectorServer = remoteServerService.save(connectorServer);
// Execute import (check authoritative mode)
importBatch = importManager.executeImport(importBatch, false);
Assert.assertNotNull(importBatch);
Assert.assertEquals(ExportImportType.IMPORT, importBatch.getType());
Assert.assertEquals(OperationState.EXECUTED, importBatch.getResult().getState());
//
system = systemService.get(system);
importedConnectorServer = remoteServerService.get(system.getRemoteServer());
Assert.assertEquals(connectorServer.getId(), importedConnectorServer.getId());
Assert.assertEquals(connectorServer.getHost(), importedConnectorServer.getHost());
Assert.assertEquals(connectorServer.getPort(), importedConnectorServer.getPort());
Assert.assertEquals(connectorServer.isUseSsl(), importedConnectorServer.isUseSsl());
Assert.assertEquals(connectorServer.getTimeout(), importedConnectorServer.getTimeout());
// Password is preserved
Assert.assertEquals(password, confidentialStorage.getGuardedString(system.getId(), SysSystem.class, SysSystemService.REMOTE_SERVER_PASSWORD).asString());
Assert.assertEquals(password, remoteServerService.getPassword(importedConnectorServer.getId()).asString());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto in project CzechIdMng by bcvsolutions.
the class SystemExportBulkActionIntegrationTest method testExportAndImportMappingWithTreeType.
@Test
public void testExportAndImportMappingWithTreeType() {
SysSystemDto system = createSystem();
IdmTreeTypeDto treeType = helper.createTreeType();
// Load configurations
List<SysSystemMappingDto> mappings = findMappings(system);
Assert.assertEquals(1, mappings.size());
SysSystemMappingDto originalMapping = mappings.get(0);
originalMapping.setTreeType(treeType.getId());
originalMapping = systemMappingService.save(originalMapping);
// Make export, upload, delete system and import
IdmExportImportDto importBatch = executeExportAndImport(system, SystemExportBulkAction.NAME);
system = systemService.get(system.getId());
Assert.assertNotNull(system);
mappings = findMappings(system);
Assert.assertEquals(1, mappings.size());
SysSystemMappingDto mapping = mappings.get(0);
Assert.assertEquals(originalMapping.getId(), mapping.getId());
SysSchemaObjectClassDto objectClassDto = new SysSchemaObjectClassDto();
objectClassDto.setId(mapping.getObjectClass());
helper.createMappingSystem(SystemEntityType.ROLE, objectClassDto);
mappings = findMappings(system);
Assert.assertEquals(2, mappings.size());
// Remove original tree-type. And create new with same code (simulate a different IdM ... same tree-type with different IDs).
originalMapping.setTreeType(null);
originalMapping = systemMappingService.save(originalMapping);
treeTypeService.delete(treeType);
IdmTreeTypeDto newTreeType = helper.createTreeType(treeType.getCode());
// Execute import (check authoritative mode)
importBatch = importManager.executeImport(importBatch, false);
Assert.assertNotNull(importBatch);
Assert.assertEquals(ExportImportType.IMPORT, importBatch.getType());
Assert.assertEquals(OperationState.EXECUTED, importBatch.getResult().getState());
// Second mapping had to be deleted!
mappings = findMappings(system);
Assert.assertEquals(1, mappings.size());
mapping = mappings.get(0);
Assert.assertEquals(originalMapping.getId(), mapping.getId());
Assert.assertEquals(newTreeType.getId(), mapping.getTreeType());
}
Aggregations