Search in sources :

Example 6 with SysProvisioningBatchDto

use of eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningBatchServiceTest method testMergeBatches.

@Test
public void testMergeBatches() {
    // create two batch for the same system entity
    SysSystemDto system = getHelper().createSystem(TestResource.TABLE_NAME);
    SysSystemEntityDto systemEntity = getHelper().createSystemEntity(system);
    // 
    SysProvisioningBatchDto batchOne = new SysProvisioningBatchDto();
    batchOne.setId(UUID.randomUUID());
    batchOne.setSystemEntity(systemEntity.getId());
    batchOne = batchService.save(batchOne);
    SysProvisioningOperationDto operationOne = createOperation(systemEntity, batchOne);
    // 
    SysProvisioningBatchDto batchTwo = new SysProvisioningBatchDto();
    batchTwo.setId(UUID.randomUUID());
    batchTwo.setSystemEntity(systemEntity.getId());
    batchTwo = batchService.save(batchTwo);
    SysProvisioningOperationDto operationTwo = createOperation(systemEntity, batchTwo);
    // 
    Assert.assertNotEquals(batchOne.getId(), batchTwo.getId());
    // 
    SysProvisioningBatchDto mergedBatch = batchService.findBatch(systemEntity.getId());
    // 
    Assert.assertEquals(batchOne.getId(), mergedBatch.getId());
    // 
    Assert.assertNull(batchService.get(batchTwo));
    operationOne = operationService.get(operationOne.getId());
    operationTwo = operationService.get(operationTwo.getId());
    Assert.assertEquals(batchOne.getId(), operationOne.getBatch());
    Assert.assertEquals(batchOne.getId(), operationTwo.getBatch());
}
Also used : SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 7 with SysProvisioningBatchDto

use of eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto in project CzechIdMng by bcvsolutions.

the class CleanProvisioningQueueTaskExecutorIntegrationTest method testLrtWithFilterBatch.

@Test
public void testLrtWithFilterBatch() {
    // create identity
    IdmIdentityDto person = createIdentity("firstName" + System.currentTimeMillis(), "Surname" + System.currentTimeMillis(), "email" + System.currentTimeMillis() + "@gemail.eu", "000000009", false);
    IdmIdentityDto personSecond = createIdentity("firstName" + System.currentTimeMillis(), "Surname" + System.currentTimeMillis(), "email" + System.currentTimeMillis() + "@gemail.eu", "000000009", false);
    // create system read only
    SysSystemDto system = helper.createTestResourceSystem(true);
    system.setReadonly(true);
    systemService.save(system);
    // create role, "assign" role to system, "assign" role to identity
    IdmRoleDto role = helper.createRole();
    SysRoleSystemDto roleSystemDefault = helper.createRoleSystem(role, system);
    roleSystemDefault.setSystemMapping(helper.getDefaultMapping(system).getId());
    roleSystemService.save(roleSystemDefault);
    IdmIdentityRoleDto identityRole = helper.createIdentityRole(person, role);
    identityRole.setValidFrom(LocalDate.now().plusDays(1));
    identityRoleService.save(identityRole);
    // create system read only
    SysSystemDto systemSecond = helper.createTestResourceSystem(true);
    systemSecond.setReadonly(true);
    systemService.save(systemSecond);
    // create role, "assign" role to system, "assign" role to identity
    IdmRoleDto roleSecond = helper.createRole();
    SysRoleSystemDto roleSystemDefaultSecond = helper.createRoleSystem(roleSecond, systemSecond);
    roleSystemDefaultSecond.setSystemMapping(helper.getDefaultMapping(systemSecond).getId());
    roleSystemService.save(roleSystemDefaultSecond);
    helper.createIdentityRole(personSecond, roleSecond);
    // find items in provisioning queue// first system// 2 provisioning operations, but 1 batch
    SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
    filter.setSystemId(system.getId());
    Page<SysProvisioningOperationDto> page = sysProvisioningOperationService.find(filter, null);
    Assert.assertEquals(2, page.getContent().size());
    // find items in provisioning queue// second system
    SysProvisioningOperationFilter filterSecond = new SysProvisioningOperationFilter();
    filterSecond.setSystemId(systemSecond.getId());
    Page<SysProvisioningOperationDto> pageSecond = sysProvisioningOperationService.find(filterSecond, null);
    Assert.assertEquals(1, pageSecond.getContent().size());
    UUID batchId = page.getContent().get(0).getBatch();
    SysProvisioningBatchDto batch = sysProvisioningBatchService.get(batchId);
    assertNotNull(batch);
    // find items in provisioning queue
    SysProvisioningOperationFilter filterBatch = new SysProvisioningOperationFilter();
    filterBatch.setBatchId(batchId);
    Page<SysProvisioningOperationDto> pageBatch = sysProvisioningOperationService.find(filterBatch, null);
    Assert.assertEquals(2, pageBatch.getContent().size());
    // create and start LRT to clean
    CancelProvisioningQueueTaskExecutor lrt = new CancelProvisioningQueueTaskExecutor();
    // 
    SysProvisioningOperationFilter filterLrt = new SysProvisioningOperationFilter();
    filterLrt.setSystemId(system.getId());
    filterLrt.setOperationType(ProvisioningEventType.CREATE);
    // 
    // filter will find just 1 provisioning operation of same batch, but clean both
    page = sysProvisioningOperationService.find(filterLrt, null);
    Assert.assertEquals(1, page.getContent().size());
    lrt.setFilter(filterLrt);
    // 
    longRunningTaskManager.executeSync(lrt);
    // items in queue are cleaned
    filter = new SysProvisioningOperationFilter();
    filter.setSystemId(system.getId());
    page = sysProvisioningOperationService.find(filter, null);
    Assert.assertEquals(0, page.getContent().size());
    // find items in provisioning queue// both systems
    pageSecond = sysProvisioningOperationService.find(filterSecond, null);
    Assert.assertEquals(1, pageSecond.getContent().size());
    // archive
    SysProvisioningOperationFilter filterArchive = new SysProvisioningOperationFilter();
    filterArchive.setSystemId(system.getId());
    Page<SysProvisioningArchiveDto> archivePage = archiveService.find(filterArchive, null);
    // 2 provisioning operation
    Assert.assertEquals(2, archivePage.getContent().size());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) CancelProvisioningQueueTaskExecutor(eu.bcvsolutions.idm.acc.scheduler.task.impl.CancelProvisioningQueueTaskExecutor) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) UUID(java.util.UUID) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 8 with SysProvisioningBatchDto

use of eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto in project CzechIdMng by bcvsolutions.

the class DefaultProvisioningExecutorIntegrationTest method testClearProvisioningBatchOnReadonlySystem.

@Test
public void testClearProvisioningBatchOnReadonlySystem() {
    SysSystemDto system = getHelper().createTestResourceSystem(true);
    system.setReadonly(true);
    system = systemService.save(system);
    String firstname = "firstname";
    SysProvisioningOperationDto provisioningOperation = createProvisioningOperation(system, firstname);
    Map<ProvisioningAttributeDto, Object> accoutObject = provisioningOperation.getProvisioningContext().getAccountObject();
    String uid = (String) accoutObject.get(getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_NAME));
    // 
    // publish event
    // 1 - create
    provisioningExecutor.execute(provisioningOperation);
    // is necessary to get again operation from service
    SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
    filter.setSystemEntity(provisioningOperation.getSystemEntity());
    filter.setSystemId(system.getId());
    SysProvisioningOperationDto readOnlyOperation = provisioningOperationService.find(filter, null).getContent().get(0);
    assertEquals(OperationState.NOT_EXECUTED, readOnlyOperation.getResultState());
    assertEquals(AccResultCode.PROVISIONING_SYSTEM_READONLY.name(), readOnlyOperation.getResult().getModel().getStatusEnum());
    SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
    // 2 - update
    provisioningExecutor.execute(updateProvisioningOperation(systemEntity, firstname + 2));
    // 
    // FIXME: how to order operations created in the same milis?
    getHelper().waitForResult(null, 1, 1);
    // 
    // 3 - update
    provisioningExecutor.execute(updateProvisioningOperation(systemEntity, firstname + 3));
    // 
    systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
    assertTrue(systemEntity.isWish());
    assertNull(getHelper().findResource(uid));
    // 
    // check batch
    SysProvisioningBatchDto batch = provisioningBatchService.findBatch(systemEntity.getId());
    Assert.assertNotNull(batch);
    // 
    // check provisioning operation requests
    List<SysProvisioningOperationDto> requests = provisioningOperationService.findByBatchId(batch.getId(), null).getContent();
    Assert.assertEquals(3, requests.size());
    // 
    // execute first operation - create
    system.setReadonly(false);
    system = systemService.save(system);
    provisioningExecutor.execute(readOnlyOperation);
    Assert.assertNull(provisioningOperationService.get(readOnlyOperation.getId()));
    // 
    systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
    assertFalse(systemEntity.isWish());
    TestResource resource = getHelper().findResource(uid);
    assertNotNull(resource);
    Assert.assertEquals(firstname, resource.getFirstname());
    Assert.assertEquals(2, provisioningOperationService.findByBatchId(batch.getId(), null).getContent().size());
    // 
    // execute whole batch
    provisioningExecutor.execute(batch);
    // 
    resource = getHelper().findResource(uid);
    Assert.assertEquals(firstname + 3, resource.getFirstname());
    Assert.assertEquals(0, provisioningOperationService.findByBatchId(batch.getId(), null).getTotalElements());
    Assert.assertNull(provisioningOperationService.get(readOnlyOperation.getId()));
    batch = provisioningBatchService.get(batch.getId());
    Assert.assertNull(batch.getNextAttempt());
}
Also used : SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 9 with SysProvisioningBatchDto

use of eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto in project CzechIdMng by bcvsolutions.

the class CleanProvisioningQueueTaskExecutorIntegrationTest method testLrtWithFilterBatch.

@Test
public void testLrtWithFilterBatch() {
    // create identity
    IdmIdentityDto person = createIdentity("firstName" + System.currentTimeMillis(), "Surname" + System.currentTimeMillis(), "email" + System.currentTimeMillis() + "@gemail.eu", "000000009", false);
    IdmIdentityDto personSecond = createIdentity("firstName" + System.currentTimeMillis(), "Surname" + System.currentTimeMillis(), "email" + System.currentTimeMillis() + "@gemail.eu", "000000009", false);
    // create system read only
    SysSystemDto system = helper.createTestResourceSystem(true);
    system.setReadonly(true);
    systemService.save(system);
    // create role, "assign" role to system, "assign" role to identity
    IdmRoleDto role = helper.createRole();
    SysRoleSystemDto roleSystemDefault = helper.createRoleSystem(role, system);
    roleSystemDefault.setSystemMapping(helper.getDefaultMapping(system).getId());
    roleSystemService.save(roleSystemDefault);
    IdmIdentityRoleDto identityRole = helper.createIdentityRole(person, role);
    identityRole.setValidFrom(LocalDate.now().plusDays(1));
    identityRoleService.save(identityRole);
    // create system read only
    SysSystemDto systemSecond = helper.createTestResourceSystem(true);
    systemSecond.setReadonly(true);
    systemService.save(systemSecond);
    // create role, "assign" role to system, "assign" role to identity
    IdmRoleDto roleSecond = helper.createRole();
    SysRoleSystemDto roleSystemDefaultSecond = helper.createRoleSystem(roleSecond, systemSecond);
    roleSystemDefaultSecond.setSystemMapping(helper.getDefaultMapping(systemSecond).getId());
    roleSystemService.save(roleSystemDefaultSecond);
    helper.createIdentityRole(personSecond, roleSecond);
    // find items in provisioning queue// first system// 2 provisioning operations, but 1 batch
    SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
    filter.setSystemId(system.getId());
    Page<SysProvisioningOperationDto> page = sysProvisioningOperationService.find(filter, null);
    Assert.assertEquals(2, page.getContent().size());
    // find items in provisioning queue// second system
    SysProvisioningOperationFilter filterSecond = new SysProvisioningOperationFilter();
    filterSecond.setSystemId(systemSecond.getId());
    Page<SysProvisioningOperationDto> pageSecond = sysProvisioningOperationService.find(filterSecond, null);
    Assert.assertEquals(1, pageSecond.getContent().size());
    UUID batchId = page.getContent().get(0).getBatch();
    SysProvisioningBatchDto batch = sysProvisioningBatchService.get(batchId);
    assertNotNull(batch);
    // find items in provisioning queue
    SysProvisioningOperationFilter filterBatch = new SysProvisioningOperationFilter();
    filterBatch.setBatchId(batchId);
    Page<SysProvisioningOperationDto> pageBatch = sysProvisioningOperationService.find(filterBatch, null);
    Assert.assertEquals(2, pageBatch.getContent().size());
    // create and start LRT to clean
    CancelProvisioningQueueTaskExecutor lrt = new CancelProvisioningQueueTaskExecutor();
    // 
    SysProvisioningOperationFilter filterLrt = new SysProvisioningOperationFilter();
    filterLrt.setSystemId(system.getId());
    filterLrt.setOperationType(ProvisioningEventType.CREATE);
    // 
    // filter will find just 1 provisioning operation of same batch, but clean both
    page = sysProvisioningOperationService.find(filterLrt, null);
    Assert.assertEquals(1, page.getContent().size());
    lrt.setFilter(filterLrt);
    // 
    longRunningTaskManager.executeSync(lrt);
    // items in queue are cleaned
    filter = new SysProvisioningOperationFilter();
    filter.setSystemId(system.getId());
    page = sysProvisioningOperationService.find(filter, null);
    Assert.assertEquals(0, page.getContent().size());
    batch = sysProvisioningBatchService.get(batchId);
    assertNull(batch);
    // find items in provisioning queue// both systems
    pageSecond = sysProvisioningOperationService.find(filterSecond, null);
    Assert.assertEquals(1, pageSecond.getContent().size());
    // archive
    SysProvisioningOperationFilter filterArchive = new SysProvisioningOperationFilter();
    filterArchive.setSystemId(system.getId());
    Page<SysProvisioningArchiveDto> archivePage = archiveService.find(filterArchive, null);
    // 2 provisioning operation
    Assert.assertEquals(2, archivePage.getContent().size());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) CancelProvisioningQueueTaskExecutor(eu.bcvsolutions.idm.acc.scheduler.task.impl.CancelProvisioningQueueTaskExecutor) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) UUID(java.util.UUID) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 10 with SysProvisioningBatchDto

use of eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto in project CzechIdMng by bcvsolutions.

the class ProvisioningOperationCancelBulkAction method processDto.

@Override
protected OperationResult processDto(SysProvisioningOperationDto dto) {
    if (isRetryWholeBatchAttribute()) {
        SysProvisioningBatchDto batch = DtoUtils.getEmbedded(dto, SysProvisioningOperation_.batch, SysProvisioningBatchDto.class, null);
        if (batch == null) {
            batch = provisioningOperationBatchService.get(dto.getBatch());
        }
        provisioningExecutor.cancel(batch);
    } else {
        provisioningExecutor.cancel(dto);
    }
    return new OperationResult(OperationState.EXECUTED);
}
Also used : SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult)

Aggregations

SysProvisioningBatchDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto)24 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)16 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)15 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)14 Test (org.junit.Test)14 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)11 SysProvisioningOperationFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter)9 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)8 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)5 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)5 ProvisioningAttributeDto (eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto)4 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)4 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)4 SysProvisioningArchiveDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto)3 TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)3 RetryProvisioningTaskExecutor (eu.bcvsolutions.idm.acc.scheduler.task.impl.RetryProvisioningTaskExecutor)3 DefaultResultModel (eu.bcvsolutions.idm.core.api.dto.DefaultResultModel)3 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)3 ResultModel (eu.bcvsolutions.idm.core.api.dto.ResultModel)3 UUID (java.util.UUID)3