Search in sources :

Example 66 with SysSystemEntityDto

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

the class DefaultProvisioningExecutorIntegrationTest method testGreenLineAccountProvisioning.

@Test
public void testGreenLineAccountProvisioning() {
    SysSystemDto system = getHelper().createTestResourceSystem(true);
    ProvisioningAttributeDto usernameAttribute = getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_NAME);
    ProvisioningAttributeDto firstNameAttribute = getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_FIRSTNAME);
    ProvisioningAttributeDto lastNameAttribute = getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_LASTNAME);
    ProvisioningAttributeDto passwordAttribute = getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_PASSWORD);
    // 
    // create test provisioning context
    SysProvisioningOperationDto provisioningOperation = createProvisioningOperation(system, "firstname");
    IcObjectClass objectClass = provisioningOperation.getProvisioningContext().getConnectorObject().getObjectClass();
    Map<ProvisioningAttributeDto, Object> accoutObject = provisioningOperation.getProvisioningContext().getAccountObject();
    String uid = (String) accoutObject.get(usernameAttribute);
    GuardedString password = (GuardedString) accoutObject.get(passwordAttribute);
    // 
    // publish event
    provisioningExecutor.execute(provisioningOperation);
    // 
    // check target account
    IcUidAttribute uidAttribute = new IcUidAttributeImpl(null, uid, null);
    IcConnectorObject existsConnectorObject = connectorFacade.readObject(systemService.getConnectorInstance(system), systemService.getConnectorConfiguration(system), objectClass, uidAttribute);
    // 
    assertNotNull(existsConnectorObject);
    assertEquals(uid, existsConnectorObject.getUidValue());
    assertEquals(accoutObject.get(firstNameAttribute), existsConnectorObject.getAttributeByName(getHelper().getSchemaColumnName(TestHelper.ATTRIBUTE_MAPPING_FIRSTNAME)).getValue());
    assertEquals(accoutObject.get(lastNameAttribute), existsConnectorObject.getAttributeByName(getHelper().getSchemaColumnName(TestHelper.ATTRIBUTE_MAPPING_LASTNAME)).getValue());
    // authenticate for password check
    IcUidAttribute attribute = connectorFacade.authenticateObject(systemService.getConnectorInstance(system), systemService.getConnectorConfiguration(system), objectClass, uid, password);
    assertNotNull(attribute);
    assertEquals(uid, attribute.getUidValue());
    // 
    // check system entity
    SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
    assertFalse(systemEntity.isWish());
}
Also used : IcUidAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcUidAttributeImpl) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) 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 67 with SysSystemEntityDto

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

the class DefaultProvisioningExecutorIntegrationTest method createProvisioningOperation.

/**
 * Prepare provisioning context and operation
 *
 * @param system
 * @return
 */
private SysProvisioningOperationDto createProvisioningOperation(SysSystemDto system, String firstname) {
    ProvisioningContext context = new ProvisioningContext();
    SysSystemEntityDto systemEntity = getHelper().createSystemEntity(system);
    Map<ProvisioningAttributeDto, Object> accoutObject = createAccountObject(systemEntity, firstname);
    context.setAccountObject(accoutObject);
    // 
    // prepare provisioning operation
    SysSystemMappingDto systemMapping = getHelper().getDefaultMapping(system);
    IcObjectClass objectClass = new IcObjectClassImpl(schemaObjectClassService.get(systemMapping.getObjectClass()).getObjectClassName());
    IcConnectorObject connectorObject = new IcConnectorObjectImpl(null, objectClass, null);
    SysProvisioningOperationDto.Builder operationBuilder = new SysProvisioningOperationDto.Builder().setSystem(system.getId()).setOperationType(ProvisioningOperationType.CREATE).setSystemEntity(systemEntity).setProvisioningContext(new ProvisioningContext(accoutObject, connectorObject));
    SysProvisioningOperationDto operation = operationBuilder.build();
    // set default result state
    operation.setResult(new OperationResult(OperationState.CREATED));
    // 
    return operation;
}
Also used : IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)

Example 68 with SysSystemEntityDto

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

the class DefaultProvisioningExecutorIntegrationTest method testRunningOperationInQueue.

@Test
public void testRunningOperationInQueue() {
    SysSystemDto system = getHelper().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(getHelper().findResource(uid));
    SysProvisioningBatchDto batch = DtoUtils.getEmbedded(operation, SysProvisioningOperation_.batch);
    Assert.assertNull(batch.getNextAttempt());
    // 
    // set operation state to running manually
    operation.getResult().setState(OperationState.RUNNING);
    operation = provisioningOperationService.save(operation);
    // 
    // created the second operation
    ProvisioningContext context = new ProvisioningContext();
    String firstname = "firstname2";
    accoutObject = createAccountObject(systemEntity, firstname);
    context.setAccountObject(accoutObject);
    // 
    // prepare provisioning operation
    SysSystemMappingDto systemMapping = getHelper().getDefaultMapping(system);
    IcObjectClass objectClass = new IcObjectClassImpl(schemaObjectClassService.get(systemMapping.getObjectClass()).getObjectClassName());
    IcConnectorObject connectorObject = new IcConnectorObjectImpl(null, objectClass, null);
    SysProvisioningOperationDto.Builder operationBuilder = new SysProvisioningOperationDto.Builder().setOperationType(ProvisioningOperationType.CREATE).setSystemEntity(systemEntity).setProvisioningContext(new ProvisioningContext(accoutObject, connectorObject));
    SysProvisioningOperationDto secondOperation = operationBuilder.build();
    // for quick search
    secondOperation.setId(UUID.randomUUID());
    // 
    // publish event
    provisioningExecutor.execute(secondOperation);
    // 
    secondOperation = provisioningOperationService.get(secondOperation);
    batch = provisioningBatchService.get(batch);
    Assert.assertNotNull(batch.getNextAttempt());
    // 
    // retry - the operation is still running
    RetryProvisioningTaskExecutor retryProvisioningTaskExecutor = new RetryProvisioningTaskExecutor();
    Boolean result = longRunningTaskManager.executeSync(retryProvisioningTaskExecutor);
    Assert.assertTrue(result);
    operation = provisioningOperationService.get(operation);
    secondOperation = provisioningOperationService.get(secondOperation);
    // 
    Assert.assertEquals(OperationState.RUNNING, operation.getResultState());
    Assert.assertEquals(OperationState.NOT_EXECUTED, secondOperation.getResultState());
    // 
    operation.getResult().setState(OperationState.EXECUTED);
    operation = provisioningOperationService.save(operation);
    // Account cannot exist now
    TestResource resource = getHelper().findResource(uid);
    Assert.assertNull(resource);
    // 
    // retry - expected success now
    retryProvisioningTaskExecutor = new RetryProvisioningTaskExecutor();
    result = longRunningTaskManager.executeSync(retryProvisioningTaskExecutor);
    Assert.assertTrue(result);
    // 
    systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
    Assert.assertFalse(systemEntity.isWish());
    resource = getHelper().findResource(uid);
    Assert.assertNotNull(resource);
    Assert.assertEquals(firstname, resource.getFirstname());
    batch = provisioningBatchService.get(batch.getId());
    Assert.assertNull(batch.getNextAttempt());
}
Also used : IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) RetryProvisioningTaskExecutor(eu.bcvsolutions.idm.acc.scheduler.task.impl.RetryProvisioningTaskExecutor) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 69 with SysSystemEntityDto

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

the class DefaultSysProvisioningBatchServiceTest method emptyFilterTest.

@Test
public void emptyFilterTest() {
    IdmBasePermission permission = IdmBasePermission.ADMIN;
    SysSystemDto system = getHelper().createSystem(TestResource.TABLE_NAME);
    SysSystemEntityDto systemEntity = getHelper().createSystemEntity(system);
    // 
    SysProvisioningBatchDto provisioningBatch = new SysProvisioningBatchDto();
    provisioningBatch.setId(UUID.randomUUID());
    provisioningBatch.setSystemEntity(systemEntity.getId());
    batchService.save(provisioningBatch);
    EmptyFilter filter = new EmptyFilter();
    Page<SysProvisioningBatchDto> result = batchService.find(filter, null, permission);
    assertTrue(result.getContent().contains(provisioningBatch));
}
Also used : EmptyFilter(eu.bcvsolutions.idm.core.api.dto.filter.EmptyFilter) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Aggregations

SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)69 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)49 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)36 Test (org.junit.Test)36 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)25 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)22 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)19 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)15 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)14 ProvisioningAttributeDto (eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto)14 ProvisioningContext (eu.bcvsolutions.idm.acc.domain.ProvisioningContext)13 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)12 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)12 SysProvisioningBatchDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto)11 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)10 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)10 IcObjectClass (eu.bcvsolutions.idm.ic.api.IcObjectClass)10 IcObjectClassImpl (eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl)10 SysProvisioningOperationFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter)8 SysSystemEntityFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter)8