Search in sources :

Example 21 with SysProvisioningOperationFilter

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

the class ContractGuaranteeSaveAndDeleteProcessorTest method testProvisioningAfterUpdateContractGuarantee.

@Test
public void testProvisioningAfterUpdateContractGuarantee() {
    SysSystemDto system = testHelper.createTestResourceSystem(true);
    // 
    IdmIdentityDto identity = testHelper.createIdentity();
    testHelper.createIdentityAccount(system, identity);
    // 
    // save identity with account, invoke provisioning = create
    identity = identityService.save(identity);
    // 
    IdmIdentityDto guarantee = testHelper.createIdentity();
    IdmIdentityContractDto primeContract = testHelper.getPrimeContract(identity.getId());
    IdmContractGuaranteeDto contractGuarantee = testHelper.createContractGuarantee(primeContract.getId(), guarantee.getId());
    // 
    IdmIdentityDto newGuarantee = testHelper.createIdentity();
    contractGuarantee.setGuarantee(newGuarantee.getId());
    // save/update
    contractGuarantee = contractGuaranteeService.save(contractGuarantee);
    // 
    SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
    filter.setSystemId(system.getId());
    List<SysProvisioningArchiveDto> content = provisioningArchiveService.find(filter, null).getContent();
    // create, add contract guarantee and update = 3 operation
    assertEquals(3, content.size());
    SysProvisioningArchiveDto last = Iterables.getLast(content);
    assertEquals(ProvisioningEventType.UPDATE, last.getOperationType());
    assertEquals(SystemEntityType.IDENTITY, last.getEntityType());
    assertEquals(identity.getId(), last.getEntityIdentifier());
}
Also used : IdmContractGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 22 with SysProvisioningOperationFilter

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

the class ContractGuaranteeSaveAndDeleteProcessorTest method testUpdateContractGuaranteeWithoutProvisioning.

@Test
public void testUpdateContractGuaranteeWithoutProvisioning() {
    IdmIdentityDto identity = testHelper.createIdentity();
    // 
    IdmIdentityDto guarantee = testHelper.createIdentity();
    IdmIdentityContractDto primeContract = testHelper.getPrimeContract(identity.getId());
    IdmContractGuaranteeDto contractGuarantee = testHelper.createContractGuarantee(primeContract.getId(), guarantee.getId());
    // 
    IdmIdentityDto newGuarantee = testHelper.createIdentity();
    contractGuarantee.setGuarantee(newGuarantee.getId());
    // save/update
    contractGuarantee = contractGuaranteeService.save(contractGuarantee);
    // 
    SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
    filter.setEntityIdentifier(identity.getId());
    List<SysProvisioningArchiveDto> content = provisioningArchiveService.find(filter, null).getContent();
    assertEquals(0, content.size());
}
Also used : IdmContractGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 23 with SysProvisioningOperationFilter

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

the class ContractGuaranteeSaveAndDeleteProcessorTest method testProvisioningAfterCreateContractGuarantee.

@Test
public void testProvisioningAfterCreateContractGuarantee() {
    SysSystemDto system = testHelper.createTestResourceSystem(true);
    // 
    // check before
    SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
    filter.setSystemId(system.getId());
    List<SysProvisioningArchiveDto> content = provisioningArchiveService.find(filter, null).getContent();
    assertEquals(0, content.size());
    // 
    // create identity
    IdmIdentityDto identity = testHelper.createIdentity();
    testHelper.createIdentityAccount(system, identity);
    // 
    // save identity with account, invoke provisioning = create
    identity = identityService.save(identity);
    // 
    content = provisioningArchiveService.find(filter, null).getContent();
    assertEquals(1, content.size());
    SysProvisioningArchiveDto sysProvisioningArchiveDto = content.get(0);
    assertEquals(ProvisioningEventType.CREATE, sysProvisioningArchiveDto.getOperationType());
    assertEquals(SystemEntityType.IDENTITY, sysProvisioningArchiveDto.getEntityType());
    assertEquals(identity.getId(), sysProvisioningArchiveDto.getEntityIdentifier());
    // 
    IdmIdentityDto guarantee = testHelper.createIdentity();
    IdmIdentityContractDto primeContract = testHelper.getPrimeContract(identity.getId());
    testHelper.createContractGuarantee(primeContract.getId(), guarantee.getId());
    // 
    // check after create contract
    content = provisioningArchiveService.find(filter, null).getContent();
    assertEquals(2, content.size());
    sysProvisioningArchiveDto = Iterables.getLast(content);
    assertEquals(ProvisioningEventType.UPDATE, sysProvisioningArchiveDto.getOperationType());
    assertEquals(SystemEntityType.IDENTITY, sysProvisioningArchiveDto.getEntityType());
    assertEquals(identity.getId(), sysProvisioningArchiveDto.getEntityIdentifier());
}
Also used : SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 24 with SysProvisioningOperationFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter 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 25 with SysProvisioningOperationFilter

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

the class DefaultProvisioningExecutorIntegrationTest method testRetryProvisioning.

@Test
public void testRetryProvisioning() {
    testProvisioningExceptionProcessor.setDisabled(false);
    try {
        SysSystemDto system = helper.createTestResourceSystem(true);
        SysProvisioningOperationDto provisioningOperation = createProvisioningOperation(system, "firstname");
        Map<ProvisioningAttributeDto, Object> accoutObject = provisioningOperation.getProvisioningContext().getAccountObject();
        String uid = (String) accoutObject.get(getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_NAME));
        DateTime now = new DateTime();
        // 
        // publish event
        // 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 operation = provisioningOperationService.find(filter, null).getContent().get(0);
        SysProvisioningBatchDto batch = provisioningBatchService.findBatch(system.getId(), operation.getEntityIdentifier(), operation.getSystemEntity());
        Assert.assertEquals(OperationState.EXCEPTION, operation.getResultState());
        Assert.assertEquals(AccResultCode.PROVISIONING_FAILED.name(), operation.getResult().getModel().getStatusEnum());
        Assert.assertEquals(1, operation.getCurrentAttempt());
        Assert.assertTrue(operation.getMaxAttempts() > 1);
        Assert.assertTrue(batch.getNextAttempt().isAfter(now));
        SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
        Assert.assertTrue(systemEntity.isWish());
        Assert.assertNull(helper.findResource(uid));
        // 
        batch.setNextAttempt(new DateTime());
        provisioningBatchService.save(batch);
        // 
        // retry - the same exception expected
        RetryProvisioningTaskExecutor retryProvisioningTaskExecutor = new RetryProvisioningTaskExecutor();
        Boolean result = longRunningTaskManager.executeSync(retryProvisioningTaskExecutor);
        Assert.assertTrue(result);
        operation = provisioningOperationService.get(operation.getId());
        batch = provisioningBatchService.findBatch(system.getId(), operation.getEntityIdentifier(), systemEntity.getId());
        Assert.assertEquals(2, operation.getCurrentAttempt());
        Assert.assertTrue(batch.getNextAttempt().isAfter(now));
        // 
        batch.setNextAttempt(new DateTime());
        provisioningBatchService.save(batch);
        // 
        // retry - expected success now
        testProvisioningExceptionProcessor.setDisabled(true);
        retryProvisioningTaskExecutor = new RetryProvisioningTaskExecutor();
        result = longRunningTaskManager.executeSync(retryProvisioningTaskExecutor);
        Assert.assertTrue(result);
        // 
        systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
        Assert.assertFalse(systemEntity.isWish());
        Assert.assertNotNull(helper.findResource(uid));
        Assert.assertNull(provisioningBatchService.get(batch.getId()));
    } finally {
        testProvisioningExceptionProcessor.setDisabled(true);
    }
}
Also used : SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) RetryProvisioningTaskExecutor(eu.bcvsolutions.idm.acc.scheduler.task.impl.RetryProvisioningTaskExecutor) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) DateTime(org.joda.time.DateTime) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

SysProvisioningOperationFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter)32 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)27 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)27 Test (org.junit.Test)27 SysProvisioningArchiveDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto)15 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)15 IdmBasePermission (eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission)14 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)13 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)8 ProvisioningAttributeDto (eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto)7 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)6 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)6 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)6 SysProvisioningBatchDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto)4 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)4 IdmContractGuaranteeDto (eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto)4 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)3 ProvisioningContext (eu.bcvsolutions.idm.acc.domain.ProvisioningContext)2 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)2 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)2