Search in sources :

Example 21 with IdmExportImportDto

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());
}
Also used : IdmExportImportDto(eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto) ImportContext(eu.bcvsolutions.idm.core.api.dto.ImportContext) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) File(java.io.File)

Example 22 with IdmExportImportDto

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());
}
Also used : IdmExportImportDto(eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractExportBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractExportBulkActionTest) Test(org.junit.Test)

Example 23 with IdmExportImportDto

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);
}
Also used : IdmExportImportDto(eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto) SysProvisioningBreakConfigDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractExportBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractExportBulkActionTest) Test(org.junit.Test)

Example 24 with IdmExportImportDto

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());
}
Also used : IdmExportImportDto(eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysConnectorServerDto(eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractExportBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractExportBulkActionTest) Test(org.junit.Test)

Example 25 with IdmExportImportDto

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());
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmExportImportDto(eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractExportBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractExportBulkActionTest) Test(org.junit.Test)

Aggregations

IdmExportImportDto (eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto)31 AbstractExportBulkActionTest (eu.bcvsolutions.idm.test.api.AbstractExportBulkActionTest)18 Test (org.junit.Test)18 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)14 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)8 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)7 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)5 SysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncConfigDto)4 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)4 IdmAttachmentDto (eu.bcvsolutions.idm.core.ecm.api.dto.IdmAttachmentDto)4 SysProvisioningBreakConfigDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto)3 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)3 Path (java.nio.file.Path)3 Transactional (org.springframework.transaction.annotation.Transactional)3 SysProvisioningBreakRecipientDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakRecipientDto)2 BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)2 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)2 IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)2 ImportContext (eu.bcvsolutions.idm.core.api.dto.ImportContext)2 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)2