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());
}
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());
}
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);
}
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);
}
}
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);
}
Aggregations