Search in sources :

Example 1 with SysProvisioningArchiveDto

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

the class DefaultSysProvisioningArchiveServiceTest method createProvisioningArchive.

private SysProvisioningArchiveDto createProvisioningArchive(SystemEntityType type, SysSystemDto system) {
    SysProvisioningArchiveDto provisioningArchive = new SysProvisioningArchiveDto();
    provisioningArchive.setEntityType(type);
    provisioningArchive.setOperationType(ProvisioningEventType.CREATE);
    provisioningArchive.setProvisioningContext(new ProvisioningContext());
    provisioningArchive.setSystem(system.getId());
    provisioningArchive.setSystemEntityUid("SomeEntityUID" + UUID.randomUUID());
    OperationResult result = new OperationResult();
    result.setState(OperationState.RUNNING);
    provisioningArchive.setResult(result);
    return archiveService.save(provisioningArchive);
}
Also used : ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult)

Example 2 with SysProvisioningArchiveDto

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

the class DefaultSysProvisioningArchiveServiceTest method operationTypeFilterTest.

@Test
public void operationTypeFilterTest() {
    IdmBasePermission permission = IdmBasePermission.ADMIN;
    SystemEntityType entityType = SystemEntityType.IDENTITY;
    SysSystemDto system = createRoleSystem();
    SysProvisioningArchiveDto provisioningArchive1 = createProvisioningArchive(entityType, system);
    SysProvisioningArchiveDto provisioningArchive2 = createProvisioningArchive(entityType, system);
    provisioningArchive2.setOperationType(ProvisioningEventType.UPDATE);
    archiveService.save(provisioningArchive2);
    SysProvisioningArchiveDto provisioningArchive3 = createProvisioningArchive(entityType, system);
    provisioningArchive3.setOperationType(ProvisioningEventType.UPDATE);
    archiveService.save(provisioningArchive3);
    SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
    filter.setOperationType(ProvisioningEventType.UPDATE);
    filter.setSystemId(system.getId());
    Page<SysProvisioningArchiveDto> result = archiveService.find(filter, null, permission);
    assertEquals(2, result.getTotalElements());
    assertFalse(result.getContent().contains(provisioningArchive1));
    assertTrue(result.getContent().contains(provisioningArchive2));
    assertTrue(result.getContent().contains(provisioningArchive3));
}
Also used : SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 3 with SysProvisioningArchiveDto

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

the class DefaultSysProvisioningArchiveServiceTest method systemIdFilterTest.

@Test
public void systemIdFilterTest() {
    IdmBasePermission permission = IdmBasePermission.ADMIN;
    SystemEntityType entityType = SystemEntityType.IDENTITY;
    SysSystemDto system1 = createRoleSystem();
    SysSystemDto system2 = createRoleSystem();
    SysProvisioningArchiveDto provisioningArchive1 = createProvisioningArchive(entityType, system1);
    SysProvisioningArchiveDto provisioningArchive2 = createProvisioningArchive(entityType, system1);
    SysProvisioningArchiveDto provisioningArchive3 = createProvisioningArchive(entityType, system2);
    SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
    filter.setSystemId(system1.getId());
    Page<SysProvisioningArchiveDto> result = archiveService.find(filter, null, permission);
    assertEquals(2, result.getTotalElements());
    assertTrue(result.getContent().contains(provisioningArchive1));
    assertTrue(result.getContent().contains(provisioningArchive2));
    assertFalse(result.getContent().contains(provisioningArchive3));
}
Also used : SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 4 with SysProvisioningArchiveDto

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

the class DefaultSysProvisioningArchiveServiceTest method resultStateFilterTest.

@Test
public void resultStateFilterTest() {
    IdmBasePermission permission = IdmBasePermission.ADMIN;
    SystemEntityType entityType = SystemEntityType.IDENTITY;
    SysSystemDto system = createRoleSystem();
    OperationResult resultState = new OperationResult();
    resultState.setState(OperationState.CREATED);
    SysProvisioningArchiveDto provisioningArchive1 = createProvisioningArchive(entityType, system);
    SysProvisioningArchiveDto provisioningArchive2 = createProvisioningArchive(entityType, system);
    provisioningArchive2.setResult(resultState);
    archiveService.save(provisioningArchive2);
    SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
    filter.setResultState(OperationState.CREATED);
    Page<SysProvisioningArchiveDto> result = archiveService.find(filter, null, permission);
    assertEquals(1, result.getTotalElements());
    assertFalse(result.getContent().contains(provisioningArchive1));
    assertTrue(result.getContent().contains(provisioningArchive2));
}
Also used : SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 5 with SysProvisioningArchiveDto

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

the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedStrategyMergeWithDuplTest.

@Test
public void compileAttributesOverrloadedStrategyMergeWithDuplTest() {
    String sameValue = "sameValue-" + System.currentTimeMillis();
    String eavAttribute = "EAV_ATTRIBUTE";
    IdmRoleDto role1 = helper.createRole();
    IdmRoleDto role2 = helper.createRole();
    IdmIdentityDto identity = helper.createIdentity();
    helper.createIdentityRole(identity, role1);
    helper.createIdentityRole(identity, role2);
    SysSystemDto system = helper.createTestResourceSystem(true);
    systemService.generateSchema(system);
    SysSchemaAttributeFilter schemaAttFilter = new SysSchemaAttributeFilter();
    schemaAttFilter.setSystemId(system.getId());
    schemaAttFilter.setName(eavAttribute);
    List<SysSchemaAttributeDto> schemaAttrs = schemaAttributeService.find(schemaAttFilter, null).getContent();
    assertEquals(1, schemaAttrs.size());
    SysSchemaAttributeDto schemaAttributeDto = schemaAttrs.get(0);
    schemaAttributeDto.setMultivalued(true);
    schemaAttributeDto = schemaAttributeService.save(schemaAttributeDto);
    SysSystemMappingDto systemMapping = helper.getDefaultMapping(system);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(system.getId());
    schemaAttributeFilter.setName(eavAttribute);
    List<SysSchemaAttributeDto> atts = schemaAttributeService.find(schemaAttributeFilter, null).getContent();
    assertEquals(1, atts.size());
    SysSchemaAttributeDto sysSchemaAttributeEav = atts.get(0);
    // create eav attribute with merge
    SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
    attributeMapping.setExtendedAttribute(true);
    attributeMapping.setName(eavAttribute);
    attributeMapping.setIdmPropertyName(eavAttribute);
    attributeMapping.setStrategyType(AttributeMappingStrategyType.MERGE);
    attributeMapping.setSchemaAttribute(sysSchemaAttributeEav.getId());
    attributeMapping.setSystemMapping(systemMapping.getId());
    attributeMapping = systemAttributeMappingService.save(attributeMapping);
    SysRoleSystemDto roleSystem1 = helper.createRoleSystem(role1, system);
    SysRoleSystemDto roleSystem2 = helper.createRoleSystem(role2, system);
    SysRoleSystemAttributeDto overloadedRoleOne = new SysRoleSystemAttributeDto();
    overloadedRoleOne.setSystemAttributeMapping(attributeMapping.getId());
    overloadedRoleOne.setEntityAttribute(false);
    overloadedRoleOne.setExtendedAttribute(true);
    overloadedRoleOne.setStrategyType(AttributeMappingStrategyType.MERGE);
    overloadedRoleOne.setName(attributeMapping.getName());
    overloadedRoleOne.setDisabledDefaultAttribute(false);
    overloadedRoleOne.setIdmPropertyName(eavAttribute);
    overloadedRoleOne.setRoleSystem(roleSystem1.getId());
    overloadedRoleOne.setTransformToResourceScript("return '" + sameValue + "';");
    overloadedRoleOne = roleSystemAttributeService.save(overloadedRoleOne);
    SysRoleSystemAttributeDto overloadedRoleTwo = new SysRoleSystemAttributeDto();
    overloadedRoleTwo.setSystemAttributeMapping(attributeMapping.getId());
    overloadedRoleTwo.setEntityAttribute(false);
    overloadedRoleTwo.setExtendedAttribute(true);
    overloadedRoleTwo.setStrategyType(AttributeMappingStrategyType.MERGE);
    overloadedRoleTwo.setName(attributeMapping.getName());
    overloadedRoleTwo.setDisabledDefaultAttribute(false);
    overloadedRoleTwo.setIdmPropertyName(eavAttribute);
    overloadedRoleTwo.setRoleSystem(roleSystem2.getId());
    overloadedRoleTwo.setTransformToResourceScript("return '" + sameValue + "';");
    overloadedRoleTwo = roleSystemAttributeService.save(overloadedRoleTwo);
    provisioningService.accountManagement(identity);
    provisioningService.doProvisioning(identity);
    List<AccAccountDto> accounts = accountService.getAccounts(system.getId(), identity.getId());
    assertEquals(1, accounts.size());
    SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
    filter.setSystemId(system.getId());
    List<SysProvisioningArchiveDto> archives = porvisioningArchiveService.find(filter, null).getContent();
    assertEquals(1, archives.size());
    SysProvisioningArchiveDto archive = archives.get(0);
    assertEquals(OperationState.EXECUTED, archive.getResultState());
    ProvisioningContext provisioningContext = archive.getProvisioningContext();
    Object values = null;
    for (ProvisioningAttributeDto key : provisioningContext.getAccountObject().keySet()) {
        if (key.getSchemaAttributeName().equals(eavAttribute)) {
            values = provisioningContext.getAccountObject().get(key);
            break;
        }
    }
    assertNotNull(values);
    if (values instanceof ArrayList<?>) {
        ArrayList<?> colleaction = (ArrayList<?>) values;
        assertEquals(1, colleaction.size());
        Object object = colleaction.get(0);
        assertEquals(sameValue, object);
    } else {
        fail();
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) ArrayList(java.util.ArrayList) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

SysProvisioningArchiveDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto)17 SysProvisioningOperationFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter)15 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)14 Test (org.junit.Test)14 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)12 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)8 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)6 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)6 IdmBasePermission (eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission)6 IdmContractGuaranteeDto (eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto)4 ProvisioningContext (eu.bcvsolutions.idm.acc.domain.ProvisioningContext)3 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)3 ProvisioningAttributeDto (eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto)2 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)2 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)2 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)2 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)2 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)2 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)2 ArrayList (java.util.ArrayList)2