Search in sources :

Example 11 with IdmExportImportDto

use of eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto in project CzechIdMng by bcvsolutions.

the class SystemExportBulkActionIntegrationTest method testExportAndImportContractSyncAdvancedPairing.

@Test
public void testExportAndImportContractSyncAdvancedPairing() {
    SysSystemDto system = createSystem();
    List<SysSystemMappingDto> mappings = findMappings(system);
    Assert.assertEquals(1, mappings.size());
    SysSystemMappingDto originalMapping = mappings.get(0);
    List<SysSystemAttributeMappingDto> originalAttributes = findAttributeMappings(system);
    SysSystemAttributeMappingDto originalAttribute = originalAttributes.get(0);
    IdmTreeTypeDto treeType = getHelper().createTreeType();
    IdmTreeNodeDto treeNode = getHelper().createTreeNode(treeType, null);
    SysSyncContractConfigDto originalSync = new SysSyncContractConfigDto();
    originalSync.setSystemMapping(originalMapping.getId());
    originalSync.setName(getHelper().createName());
    originalSync.setCorrelationAttribute(originalAttribute.getId());
    originalSync.setDefaultTreeType(treeType.getId());
    originalSync.setDefaultTreeNode(treeNode.getId());
    originalSync = (SysSyncContractConfigDto) synchronizationConfigService.save(originalSync);
    // Make export, upload, delete system and import
    IdmExportImportDto importBatch = executeExportAndImport(system, SystemExportBulkAction.NAME);
    system = systemService.get(system.getId());
    Assert.assertNotNull(system);
    mappings = findMappings(system);
    List<SysSystemAttributeMappingDto> attributes = findAttributeMappings(system);
    Assert.assertEquals(1, mappings.size());
    SysSystemMappingDto mapping = mappings.get(0);
    Assert.assertEquals(originalMapping.getId(), mapping.getId());
    Assert.assertEquals(originalAttributes.size(), attributes.size());
    // Create redundant sync
    SysSyncConfigDto redundantSync = new SysSyncConfigDto();
    redundantSync.setSystemMapping(originalMapping.getId());
    redundantSync.setName(getHelper().createName());
    redundantSync.setCorrelationAttribute(originalAttribute.getId());
    redundantSync = (SysSyncConfigDto) synchronizationConfigService.save(redundantSync);
    // Clear tree type and tree node.
    originalSync.setDefaultTreeType(null);
    originalSync.setDefaultTreeNode(null);
    originalSync = (SysSyncContractConfigDto) synchronizationConfigService.save(originalSync);
    // Delete original tree-type and tree-node and create new with same code (test of advanced paring).
    getHelper().deleteTreeNode(treeNode.getId());
    getHelper().deleteTreeType(treeType.getId());
    IdmTreeTypeDto treeTypeNew = getHelper().createTreeType(treeType.getCode());
    IdmTreeNodeDto treeNodeNew = getHelper().createTreeNode(treeTypeNew, treeNode.getCode(), null);
    // 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!
    redundantSync = (SysSyncConfigDto) synchronizationConfigService.get(redundantSync.getId());
    Assert.assertNull(redundantSync);
    // Check advanced paring for tree-type and tree-node.
    originalSync = (SysSyncContractConfigDto) synchronizationConfigService.get(originalSync.getId());
    Assert.assertNotNull(originalSync);
    Assert.assertEquals(treeTypeNew.getId(), originalSync.getDefaultTreeType());
    Assert.assertEquals(treeNodeNew.getId(), originalSync.getDefaultTreeNode());
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmExportImportDto(eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto) SysSyncContractConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) SysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncConfigDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractExportBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractExportBulkActionTest) Test(org.junit.Test)

Example 12 with IdmExportImportDto

use of eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto in project CzechIdMng by bcvsolutions.

the class SystemExportBulkActionIntegrationTest method testExportAndImportBreakIdentityAdvancedPairing.

@Test
public void testExportAndImportBreakIdentityAdvancedPairing() {
    SysSystemDto system = createSystem();
    SysProvisioningBreakConfigDto originalBreak = new SysProvisioningBreakConfigDto();
    originalBreak.setSystem(system.getId());
    originalBreak.setOperationType(ProvisioningEventType.CREATE);
    originalBreak.setPeriod(10l);
    originalBreak = provisioningBreakService.save(originalBreak);
    IdmIdentityDto originalRecipient = getHelper().createIdentity();
    SysProvisioningBreakRecipientDto breakRecipient = new SysProvisioningBreakRecipientDto();
    breakRecipient.setIdentity(originalRecipient.getId());
    breakRecipient.setBreakConfig(originalBreak.getId());
    breakRecipient = provisioningBreakRecipientService.save(breakRecipient);
    // 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());
    breakRecipient = provisioningBreakRecipientService.get(breakRecipient.getId());
    Assert.assertNotNull(breakRecipient);
    Assert.assertEquals(originalRecipient.getId(), breakRecipient.getIdentity());
    // Delete original recipient.
    identityService.delete(originalRecipient);
    // Execute failed import (check advanced pairing -> will failed -> identity
    // missing).
    ImportTaskExecutor lrt = new ImportTaskExecutor(importBatch.getId(), false);
    try {
        importManager.internalExecuteImport(importBatch, false, lrt);
        Assert.assertTrue(false);
    } catch (ResultCodeException ex) {
        if (ex.getError() != null && ex.getError().getError() != null && CoreResultCode.IMPORT_ADVANCED_PARING_FAILED_NOT_FOUND.name().equals(ex.getError().getError().getStatusEnum())) {
        // I expect the exception here.
        } else {
            Assert.assertTrue(false);
        }
    }
    // Create recipient with same user name.
    IdmIdentityDto newRecipient = getHelper().createIdentity(originalRecipient.getUsername());
    // Execute import (check advanced pairing).
    importBatch = importManager.executeImport(importBatch, false);
    Assert.assertNotNull(importBatch);
    Assert.assertEquals(ExportImportType.IMPORT, importBatch.getType());
    Assert.assertEquals(OperationState.EXECUTED, importBatch.getResult().getState());
    breakRecipient = provisioningBreakRecipientService.get(breakRecipient.getId());
    Assert.assertNotNull(breakRecipient);
    Assert.assertEquals(newRecipient.getId(), breakRecipient.getIdentity());
}
Also used : SysProvisioningBreakRecipientDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakRecipientDto) IdmExportImportDto(eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto) SysProvisioningBreakConfigDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto) ImportTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.ImportTaskExecutor) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractExportBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractExportBulkActionTest) Test(org.junit.Test)

Example 13 with IdmExportImportDto

use of eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto in project CzechIdMng by bcvsolutions.

the class SystemExportBulkActionIntegrationTest method testExportAndImportAttributeMapping.

@Test
public void testExportAndImportAttributeMapping() {
    SysSystemDto system = createSystem();
    List<SysSystemMappingDto> mappings = findMappings(system);
    Assert.assertEquals(1, mappings.size());
    SysSystemMappingDto originalMapping = mappings.get(0);
    List<SysSystemAttributeMappingDto> originalAttributes = findAttributeMappings(system);
    // Make export, upload, delete system and import
    IdmExportImportDto importBatch = executeExportAndImport(system, SystemExportBulkAction.NAME);
    system = systemService.get(system.getId());
    Assert.assertNotNull(system);
    mappings = findMappings(system);
    List<SysSystemAttributeMappingDto> attributes = findAttributeMappings(system);
    Assert.assertEquals(1, mappings.size());
    SysSystemMappingDto mapping = mappings.get(0);
    Assert.assertEquals(originalMapping.getId(), mapping.getId());
    Assert.assertEquals(originalAttributes.size(), attributes.size());
    // Create redundant attribute
    SysSystemAttributeMappingDto redundantAttribute = new SysSystemAttributeMappingDto();
    redundantAttribute.setSystemMapping(mapping.getId());
    redundantAttribute.setName(getHelper().createName());
    redundantAttribute.setSchemaAttribute(attributes.get(0).getSchemaAttribute());
    redundantAttribute = systemAttributeMappingService.save(redundantAttribute);
    // 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 attribute had to be deleted!
    redundantAttribute = systemAttributeMappingService.get(redundantAttribute.getId());
    Assert.assertNull(redundantAttribute);
}
Also used : IdmExportImportDto(eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractExportBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractExportBulkActionTest) Test(org.junit.Test)

Example 14 with IdmExportImportDto

use of eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto in project CzechIdMng by bcvsolutions.

the class AbstractExportBulkAction method initBatch.

protected void initBatch(String name) {
    if (batch == null) {
        String nameFromUser = (String) getProperties().get(PROPERTY_NAME);
        if (Strings.isNotEmpty(nameFromUser)) {
            name = nameFromUser;
        }
        batch = new IdmExportImportDto();
        batch.setName(name);
        batch.setType(ExportImportType.EXPORT);
        batch.setExecutorName(this.getName());
        batch.setLongRunningTask(getLongRunningTaskId());
        batch = exportImportService.save(batch, IdmBasePermission.CREATE);
    }
}
Also used : IdmExportImportDto(eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto)

Example 15 with IdmExportImportDto

use of eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto in project CzechIdMng by bcvsolutions.

the class IdmExportImportController method uploadImport.

/**
 * Upload new import
 *
 * @param name
 * @param fileName
 * @param data
 * @return
 * @throws IOException
 */
@ResponseBody
@RequestMapping(method = RequestMethod.POST)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.EXPORTIMPORT_CREATE + "')")
@ApiOperation(value = "Upload new import zip. New import batch will be created.", nickname = "uploadImport", response = IdmExportImportDto.class, tags = { IdmExportImportController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.EXPORTIMPORT_CREATE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.EXPORTIMPORT_CREATE, description = "") }) }, notes = "Upload new import zip. New import batch will be created.")
public Resource<IdmExportImportDto> uploadImport(String name, String fileName, MultipartFile data) throws IOException {
    IdmExportImportDto batch = importManager.uploadImport(name, fileName, data.getInputStream(), IdmBasePermission.CREATE);
    Link selfLink = ControllerLinkBuilder.linkTo(this.getClass()).slash(batch.getId()).withSelfRel();
    return new Resource<IdmExportImportDto>(batch, selfLink);
}
Also used : IdmExportImportDto(eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto) InputStreamResource(org.springframework.core.io.InputStreamResource) Resource(org.springframework.hateoas.Resource) Link(org.springframework.hateoas.Link) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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