Search in sources :

Example 26 with SysSystemEntityDto

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

the class IdentitySyncTest method testUpdateIdentityNoAutomappingDontRemoveWishSync.

// linked, system entity has "wish", action Update entity, automapping is not allowed => no change + warning
@Test
public void testUpdateIdentityNoAutomappingDontRemoveWishSync() {
    SysSystemDto system = initData();
    Assert.assertNotNull(system);
    // Disallow automapping
    configurationService.setBooleanValue(ProvisioningConfiguration.PROPERTY_ALLOW_AUTO_MAPPING_ON_EXISTING_ACCOUNT, Boolean.FALSE);
    SysSyncIdentityConfigDto config = doCreateSyncConfig(system);
    config.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
    config = (SysSyncIdentityConfigDto) syncConfigService.save(config);
    // Create system entity with "wish"
    createSystemEntityWish(system);
    // Create identity with account
    IdmIdentityDto identity = helper.createIdentity(IDENTITY_ONE);
    helper.createIdentityAccount(system, identity);
    helper.startSynchronization(config);
    // has to be warning - automapping is not allowed
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.UPDATE_ENTITY, 1, OperationResultType.WARNING);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    // System entity has "wish"
    SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, IDENTITY_ONE);
    Assert.assertTrue(systemEntity.isWish());
    // Delete log
    syncLogService.delete(log);
    syncConfigService.delete(config);
    // Return default
    configurationService.setBooleanValue(ProvisioningConfiguration.PROPERTY_ALLOW_AUTO_MAPPING_ON_EXISTING_ACCOUNT, ProvisioningConfiguration.DEFAULT_ALLOW_AUTO_MAPPING_ON_EXISTING_ACCOUNT);
}
Also used : SysSyncIdentityConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) DefaultSynchronizationServiceTest(eu.bcvsolutions.idm.acc.service.impl.DefaultSynchronizationServiceTest)

Example 27 with SysSystemEntityDto

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

the class IdentitySyncTest method testLinkedIdentityIgnoredDontRemoveWishSync.

// linked, system entity has "wish", action Ignore => no change
@Test
public void testLinkedIdentityIgnoredDontRemoveWishSync() {
    SysSystemDto system = initData();
    Assert.assertNotNull(system);
    SysSyncIdentityConfigDto config = doCreateSyncConfig(system);
    config.setLinkedAction(SynchronizationLinkedActionType.IGNORE);
    config = (SysSyncIdentityConfigDto) syncConfigService.save(config);
    // Create system entity with "wish"
    createSystemEntityWish(system);
    // Create identity with account
    IdmIdentityDto identity = helper.createIdentity(IDENTITY_ONE);
    helper.createIdentityAccount(system, identity);
    helper.startSynchronization(config);
    // has to be ignored
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.LINKED, 1, OperationResultType.IGNORE);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    // System entity has "wish"
    SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, IDENTITY_ONE);
    Assert.assertTrue(systemEntity.isWish());
    // Delete log
    syncLogService.delete(log);
    syncConfigService.delete(config);
}
Also used : SysSyncIdentityConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) DefaultSynchronizationServiceTest(eu.bcvsolutions.idm.acc.service.impl.DefaultSynchronizationServiceTest)

Example 28 with SysSystemEntityDto

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

the class AccountDeleteProcessor method initContext.

/**
 * Create context for systemEntity in account DTO and set ID of role-request to
 * it.
 *
 * @param account
 * @param requestId
 */
private void initContext(AccAccountDto account, UUID requestId) {
    SysSystemEntityDto systemEntityDto = DtoUtils.getEmbedded(account, AccAccount_.systemEntity.getName(), SysSystemEntityDto.class, null);
    if (systemEntityDto == null) {
        return;
    }
    Map<String, Object> context = systemEntityDto.getContext();
    if (context == null) {
        context = new HashMap<String, Object>();
    }
    context.put(IdmRoleRequestService.ROLE_REQUEST_ID_KEY, requestId);
    systemEntityDto.setContext(context);
}
Also used : SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)

Example 29 with SysSystemEntityDto

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

the class DefaultProvisioningExecutorIntegrationTest method testChangePasswordWithoutAccountExist.

@Test
public void testChangePasswordWithoutAccountExist() {
    SysSystemDto system = getHelper().createTestResourceSystem(true);
    ProvisioningContext context = new ProvisioningContext();
    SysSystemEntityDto systemEntity = getHelper().createSystemEntity(system);
    ProvisioningAttributeDto passwordAttribute = getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_PASSWORD);
    // 
    Map<ProvisioningAttributeDto, Object> accoutObject = new HashMap<>();
    accoutObject.put(passwordAttribute, new GuardedString("password"));
    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 provisioningOperation = operationBuilder.build();
    // set default result state
    provisioningOperation.setResult(new OperationResult(OperationState.CREATED));
    // 
    // publish event
    provisioningExecutor.execute(provisioningOperation);
    // 
    SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
    filter.setSystemEntity(provisioningOperation.getSystemEntity());
    filter.setSystemId(system.getId());
    // 
    List<SysProvisioningOperationDto> operations = provisioningOperationService.find(filter, null).getContent();
    Assert.assertEquals(1, operations.size());
    // 
    Assert.assertEquals(AccResultCode.PROVISIONING_PASSWORD_CREATE_ACCOUNT_UID_NOT_FOUND.getCode(), operations.get(0).getResult().getModel().getStatusEnum());
}
Also used : IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) HashMap(java.util.HashMap) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) 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) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 30 with SysSystemEntityDto

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

the class DefaultProvisioningExecutorIntegrationTest method testAsynchronousSystem.

@Test
public void testAsynchronousSystem() {
    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));
    // 
    // 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(getHelper().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(getHelper().findResource(uid));
}
Also used : ProvisioningQueueTaskExecutor(eu.bcvsolutions.idm.acc.scheduler.task.impl.ProvisioningQueueTaskExecutor) IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) 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) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

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