Search in sources :

Example 41 with SysSystemEntityDto

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

the class MappingContextTest method testMappingContextConnectorObject.

@Test
public void testMappingContextConnectorObject() {
    SysSystemDto system = helper.createTestResourceSystem(true);
    Assert.assertNotNull(system);
    SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
    Assert.assertNotNull(mapping);
    // Create the description attribute (print context as string).
    createDescriptionAttribute(system, mapping);
    // Set context transformation to the mapping
    // Add connector object to the context.
    mapping.setAddContextConnectorObject(true);
    mapping = initContextForMapping(mapping);
    IdmRoleDto roleWithSystem = helper.createRole();
    helper.createRoleSystem(roleWithSystem, system);
    IdmIdentityDto identity = helper.createIdentity();
    helper.createContract(identity, null, LocalDate.now(), null);
    List<IdmIdentityContractDto> contracts = identityContractService.findAllByIdentity(identity.getId());
    Assert.assertEquals(2, contracts.size());
    helper.createIdentityRole(identity, roleWithSystem, null, null);
    TestResource resource = helper.findResource(identity.getUsername());
    assertNotNull(resource);
    assertEquals(identity.getFirstName(), resource.getFirstname());
    MappingContext context = new MappingContext();
    context.put("test", "TestValueOne");
    assertEquals(context.toString(), resource.getDescrip());
    SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, identity.getUsername());
    IcConnectorObject connectorObject = systemEntityService.getConnectorObject(systemEntity);
    Assert.assertNotNull(connectorObject);
    // Invoke provisioning
    identityService.save(identity);
    resource = helper.findResource(identity.getUsername());
    assertNotNull(resource);
    assertEquals(identity.getFirstName(), resource.getFirstname());
    context = new MappingContext();
    context.put("test", "TestValueOne");
    context.setConnectorObject(connectorObject);
    assertEquals(context.toString(), resource.getDescrip());
    // Delete role mapping
    systemMappingService.delete(mapping);
}
Also used : MappingContext(eu.bcvsolutions.idm.acc.domain.MappingContext) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 42 with SysSystemEntityDto

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

the class ProvisioningBreakProcessorTest method testClearCache.

@Test
public void testClearCache() {
    SysSystemDto system = getHelper().createTestResourceSystem(true);
    IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
    createProvisioningBreak(20l, 3, null, ProvisioningEventType.UPDATE, system.getId());
    // 
    this.createAccount(system, identity);
    // 
    // create
    provisioningService.doProvisioning(identity);
    // 
    SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, identity.getUsername());
    SysProvisioningBatchDto batch = batchService.findBatch(systemEntity.getId());
    List<SysProvisioningOperationDto> content = provisioningOperationService.findByBatchId(batch.getId(), null).getContent();
    // 
    provisioningService.doProvisioning(identity);
    // 
    content = provisioningOperationService.findByBatchId(batch.getId(), null).getContent();
    // 
    provisioningService.doProvisioning(identity);
    // 
    content = provisioningOperationService.findByBatchId(batch.getId(), null).getContent();
    // 
    assertTrue(content.isEmpty());
    // 
    SysBlockedOperationDto blockedOperation = new SysBlockedOperationDto();
    blockedOperation.blockUpdate();
    system.setBlockedOperation(blockedOperation);
    // block system
    system = systemService.save(system);
    // 
    blockedOperation = new SysBlockedOperationDto();
    blockedOperation.setUpdateOperation(Boolean.FALSE);
    system.setBlockedOperation(blockedOperation);
    // unblock system, clear cache
    system = systemService.save(system);
    // 
    provisioningService.doProvisioning(identity);
    provisioningService.doProvisioning(identity);
    // 
    systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, identity.getUsername());
    batch = batchService.findBatch(systemEntity.getId());
    // 
    assertEquals(0, provisioningOperationService.findByBatchId(batch.getId(), null).getTotalElements());
}
Also used : SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) SysBlockedOperationDto(eu.bcvsolutions.idm.acc.dto.SysBlockedOperationDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) 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 43 with SysSystemEntityDto

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

the class ProvisioningBreakProcessorTest method testBlockSystemUpdateCombination.

@Test
public void testBlockSystemUpdateCombination() {
    SysSystemDto system = getHelper().createTestResourceSystem(true);
    // 
    IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
    createProvisioningBreak(20l, 1, null, ProvisioningEventType.UPDATE, system.getId());
    // 
    this.createAccount(system, identity);
    // 
    // 
    // create
    provisioningService.doProvisioning(identity);
    // 
    SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, identity.getUsername());
    SysProvisioningBatchDto batch = batchService.findBatch(systemEntity.getId());
    List<SysProvisioningOperationDto> content = provisioningOperationService.findByBatchId(batch.getId(), null).getContent();
    // 
    assertTrue(content.isEmpty());
    // 
    provisioningService.doProvisioning(identity);
    // block
    provisioningService.doProvisioning(identity);
    // 
    systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, identity.getUsername());
    batch = batchService.findBatch(systemEntity.getId());
    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());
}
Also used : SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) 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 44 with SysSystemEntityDto

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

the class DefaultSysSystemServiceIntegrationTest method testReferentialIntegrityProvisioningOperationExists.

@Test(expected = ResultCodeException.class)
public void testReferentialIntegrityProvisioningOperationExists() {
    SysSystemDto system = new SysSystemDto();
    String systemName = "t_s_" + System.currentTimeMillis();
    system.setName(systemName);
    system = systemService.save(system);
    // system entity
    SysSystemEntityDto systemEntity = new SysSystemEntityDto();
    systemEntity.setUid("test");
    systemEntity.setSystem(system.getId());
    systemEntity.setEntityType(SystemEntityType.IDENTITY);
    systemEntity = systemEntityService.save(systemEntity);
    SysProvisioningOperationDto provisioningOperation = new SysProvisioningOperationDto();
    provisioningOperation.setSystem(system.getId());
    provisioningOperation.setEntityType(SystemEntityType.IDENTITY);
    provisioningOperation.setOperationType(ProvisioningEventType.CREATE);
    provisioningOperation.setSystemEntity(systemEntity.getId());
    provisioningOperation.setEntityIdentifier(UUID.randomUUID());
    provisioningOperation.setProvisioningContext(new ProvisioningContext());
    provisioningOperation.setResult(new OperationResult());
    provisioningOperationService.save(provisioningOperation);
    // 
    systemService.delete(system);
}
Also used : ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) 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)

Example 45 with SysSystemEntityDto

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

the class DefaultSysProvisioningServiceTest method testUpdateWishIfSystemEntityExists.

@Test
public void testUpdateWishIfSystemEntityExists() {
    String username = getHelper().createName();
    SysSystemDto system = getHelper().createTestResourceSystem(true);
    // 
    // prepare resource
    IdmIdentityDto identity = getHelper().createIdentity(username, (GuardedString) null);
    TestResource resource = new TestResource();
    resource.setName(username);
    resource.setFirstname(identity.getFirstName());
    resource.setLastname(identity.getLastName());
    // TODO: test constant
    resource.setStatus("enabled");
    resource = getHelper().saveResource(resource);
    // 
    // prepare identity with account on target system with the same system entity as prepared
    IdmRoleDto role = getHelper().createRole();
    getHelper().createRoleSystem(role, system);
    getHelper().createIdentityRole(identity, role);
    // 
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    AccIdentityAccountDto accountIdentityOne = identityAccountService.find(filter, null).getContent().get(0);
    AccAccountDto account = accountService.get(accountIdentityOne.getAccount());
    // 
    SysSystemEntityDto systemEntity = DtoUtils.getEmbedded(account, AccAccount_.systemEntity);
    // 
    resource = helper.findResource(account.getRealUid());
    // 
    Assert.assertFalse(systemEntity.isWish());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) 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