use of eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto in project CzechIdMng by bcvsolutions.
the class SysProvisioningOperationFilterIntegrationTest method operationTypeFilterTest.
@Test
public void operationTypeFilterTest() {
IdmBasePermission permission = IdmBasePermission.ADMIN;
SystemEntityType entityType = SystemEntityType.IDENTITY;
SysSystemDto system = createSystem();
SysProvisioningOperationDto provisioningOperation1 = createProvisioningOperation(entityType, system);
SysProvisioningOperationDto provisioningOperation2 = createProvisioningOperation(entityType, system);
provisioningOperation2.setOperationType(ProvisioningEventType.CANCEL);
operationService.save(provisioningOperation2);
SysProvisioningOperationDto provisioningOperation3 = createProvisioningOperation(entityType, system);
provisioningOperation3.setOperationType(ProvisioningEventType.CANCEL);
operationService.save(provisioningOperation3);
SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
filter.setSystemId(system.getId());
filter.setOperationType(ProvisioningEventType.CANCEL);
Page<SysProvisioningOperationDto> result = operationService.find(filter, null, permission);
assertEquals(2, result.getTotalElements());
assertTrue(result.getContent().contains(provisioningOperation2));
assertFalse(result.getContent().contains(provisioningOperation1));
}
use of eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto in project CzechIdMng by bcvsolutions.
the class ProvisioningBreakProcessorTest method testPeriod.
@Test
public void testPeriod() {
SysSystemDto system = testHelper.createTestResourceSystem(true);
IdmIdentityDto identity = testHelper.createIdentity();
SysProvisioningBreakConfigDto breakConfig = createProvisioningBreak(20l, 2, null, ProvisioningEventType.UPDATE, system.getId());
IdmIdentityDto recipient = testHelper.createIdentity();
createRecipient(breakConfig.getId(), recipient.getId(), null);
//
this.createAccount(system, identity);
//
//
// create
provisioningService.doProvisioning(identity);
provisioningService.doProvisioning(identity);
provisioningService.doProvisioning(identity);
//
SysProvisioningBreakItems cacheProcessedItems = provisioningBreakConfig.getCacheProcessedItems(system.getId());
//
// subtrack only 19 minutes from all items
long subtrackMinutes = 1140000;
List<Long> execudedItems = cacheProcessedItems.getExecutedItems(ProvisioningEventType.UPDATE);
// it isn't possible use foreEach or another stream function (reference)
for (Long item : execudedItems) {
execudedItems.set(execudedItems.indexOf(item), item - subtrackMinutes);
}
//
// block
provisioningService.doProvisioning(identity);
//
SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, identity.getUsername());
SysProvisioningBatchDto batch = batchService.findBatch(system.getId(), identity.getId(), systemEntity.getId());
//
assertNotNull(batch);
//
List<SysProvisioningOperationDto> content = provisioningOperationService.findByBatchId(batch.getId(), null).getContent();
assertEquals(1, content.size());
//
SysProvisioningOperationDto sysProvisioningOperationDto = content.get(0);
//
assertEquals(ProvisioningEventType.UPDATE, sysProvisioningOperationDto.getOperationType());
assertEquals(OperationState.BLOCKED, sysProvisioningOperationDto.getResult().getState());
}
use of eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto in project CzechIdMng by bcvsolutions.
the class ProvisioningBreakProcessorTest method testBlockSystemCreate.
@Test
public void testBlockSystemCreate() {
SysSystemDto system = testHelper.createTestResourceSystem(true);
SysBlockedOperationDto blockedOperationDto = new SysBlockedOperationDto();
blockedOperationDto.blockCreate();
system.setBlockedOperation(blockedOperationDto);
system = systemService.save(system);
//
IdmIdentityDto identity = testHelper.createIdentity();
createProvisioningBreak(20l, 3, 2, ProvisioningEventType.CREATE, system.getId());
//
this.createAccount(system, identity);
//
// create block
provisioningService.doProvisioning(identity);
SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, identity.getUsername());
//
SysProvisioningBatchDto batch = batchService.findBatch(system.getId(), identity.getId(), systemEntity.getId());
//
List<SysProvisioningOperationDto> content = provisioningOperationService.findByBatchId(batch.getId(), null).getContent();
assertEquals(1, content.size());
SysProvisioningOperationDto sysProvisioningOperationDto = content.get(0);
//
assertEquals(ProvisioningEventType.CREATE, sysProvisioningOperationDto.getOperationType());
assertEquals(OperationState.BLOCKED, sysProvisioningOperationDto.getResult().getState());
}
use of eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto in project CzechIdMng by bcvsolutions.
the class DefaultProvisioningExecutorIntegrationTest method testClearProvisioningBatchOnReadonlySystem.
@Test
public void testClearProvisioningBatchOnReadonlySystem() {
SysSystemDto system = helper.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));
// 3 - update
provisioningExecutor.execute(updateProvisioningOperation(systemEntity, firstname + 3));
//
systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
assertTrue(systemEntity.isWish());
assertNull(helper.findResource(uid));
//
// check batch
SysProvisioningBatchDto batch = provisioningBatchService.findBatch(system.getId(), readOnlyOperation.getEntityIdentifier(), 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 = helper.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 = helper.findResource(uid);
Assert.assertEquals(firstname + 3, resource.getFirstname());
Assert.assertEquals(0, provisioningOperationService.findByBatchId(batch.getId(), null).getTotalElements());
Assert.assertNull(provisioningOperationService.get(readOnlyOperation.getId()));
Assert.assertNull(provisioningBatchService.get(batch.getId()));
}
use of eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto in project CzechIdMng by bcvsolutions.
the class DefaultProvisioningExecutorIntegrationTest method testAsynchronousSystem.
@Test
public void testAsynchronousSystem() {
SysSystemDto system = helper.createTestResourceSystem(true);
system.setQueue(true);
system = systemService.save(system);
//
// create test provisioning context
SysProvisioningOperationDto provisioningOperation = createProvisioningOperation(system, "firstname");
Map<ProvisioningAttributeDto, Object> accoutObject = provisioningOperation.getProvisioningContext().getAccountObject();
String uid = (String) accoutObject.get(getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_NAME));
//
// publish event
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);
assertEquals(OperationState.CREATED, operation.getResultState());
SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
assertTrue(systemEntity.isWish());
assertNull(helper.findResource(uid));
//
// execute LRT with incorrect setting - virtual at fist - expected no process
ProvisioningQueueTaskExecutor provisioningQueueExecutor = new ProvisioningQueueTaskExecutor();
provisioningQueueExecutor.setVirtual(true);
Boolean result = longRunningTaskManager.executeSync(provisioningQueueExecutor);
assertTrue(result);
IdmLongRunningTaskDto lrt = longRunningTaskManager.getLongRunningTask(provisioningQueueExecutor.getLongRunningTaskId());
assertEquals(0L, lrt.getCount().longValue());
systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
assertTrue(systemEntity.isWish());
assertNull(helper.findResource(uid));
//
// execute LRT with correct setting
provisioningQueueExecutor = new ProvisioningQueueTaskExecutor();
result = longRunningTaskManager.executeSync(provisioningQueueExecutor);
assertTrue(result);
lrt = longRunningTaskManager.getLongRunningTask(provisioningQueueExecutor);
assertEquals(1L, lrt.getCount().longValue());
systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
assertFalse(systemEntity.isWish());
assertNotNull(helper.findResource(uid));
}
Aggregations