Search in sources :

Example 1 with LdapServer

use of eu.bcvsolutions.idm.rpt.ldap.LdapServer in project CzechIdMng by bcvsolutions.

the class ProvisioningOperationReportIntegrationTest method testProvisioningOperationReportMultivalued.

@Test
public void testProvisioningOperationReportMultivalued() throws Exception {
    LdapServer server = new LdapServer();
    server.run();
    SysSystemDto system = ldapTestHelper.createTestResourceSystem(true, "ldap_test" + System.currentTimeMillis());
    // create provisioning operation
    // TODO: now is DN stored as username, create script in mapping that will composed the final dn
    IdmIdentityDto identity = getHelper().createIdentity(LdapServer.generateDn("test-" + System.currentTimeMillis()));
    IdmRoleDto role = getHelper().createRole();
    getHelper().createRoleSystem(role, system);
    getHelper().createIdentityRole(identity, role);
    // 
    AccAccountFilter filter = new AccAccountFilter();
    filter.setIdentityId(identity.getId());
    filter.setSystemId(system.getId());
    List<AccAccountDto> accounts = accountService.find(filter, null).getContent();
    assertEquals(1, accounts.size());
    SysProvisioningOperationFilter provisioningFilter = new SysProvisioningOperationFilter();
    provisioningFilter.setEntityIdentifier(identity.getId());
    List<SysProvisioningOperationDto> operations = provisioningOperationService.find(provisioningFilter, null).getContent();
    assertTrue(operations.isEmpty());
    boolean existsEntityByDn = server.existsEntityByDn(identity.getUsername());
    assertTrue(existsEntityByDn);
    // Set read only to system
    system.setReadonly(true);
    system = systemService.save(system);
    IdmRoleDto roleWithMerge = getHelper().createRole();
    SysRoleSystemDto createRoleSystem = getHelper().createRoleSystem(roleWithMerge, system);
    ldapTestHelper.createMergeAttributeForRole(system, createRoleSystem, LdapServer.GROUP_A_DN);
    getHelper().createIdentityRole(identity, roleWithMerge);
    operations = provisioningOperationService.find(provisioningFilter, null).getContent();
    assertFalse(operations.isEmpty());
    // prepare report filter
    RptReportDto report = new RptReportDto(UUID.randomUUID());
    report.setExecutorName(reportExecutor.getName());
    IdmFormDto filterForm = new IdmFormDto();
    IdmFormDefinitionDto definition = reportExecutor.getFormDefinition();
    IdmFormValueDto systemFilter = new IdmFormValueDto(definition.getMappedAttributeByCode(ProvisioningOperationReportExecutor.PARAMETER_SYSTEM));
    systemFilter.setUuidValue(system.getId());
    filterForm.getValues().add(systemFilter);
    filterForm.setFormDefinition(definition.getId());
    report.setFilter(filterForm);
    // 
    // generate report
    report = reportExecutor.generate(report);
    Assert.assertNotNull(report.getData());
    List<RptProvisioningOperationDto> reportItems = mapper.readValue(attachmentManager.getAttachmentData(report.getData()), new TypeReference<List<RptProvisioningOperationDto>>() {
    });
    assertEquals(1, reportItems.size());
    RptProvisioningOperationDto rptProvisioningOperationDto = reportItems.get(0);
    String value = rptProvisioningOperationDto.getProvisioningValues().get(LdapTestHelper.ATTRIBUTE_MAPPING_MEMBER_OF);
    assertEquals(LdapServer.GROUP_A_DN, value);
    server.stop();
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) IdmFormDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) LdapServer(eu.bcvsolutions.idm.rpt.ldap.LdapServer) RptProvisioningOperationDto(eu.bcvsolutions.idm.rpt.dto.RptProvisioningOperationDto) AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) List(java.util.List) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)1 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)1 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)1 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)1 AccAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter)1 SysProvisioningOperationFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter)1 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)1 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)1 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)1 IdmFormDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto)1 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)1 RptReportDto (eu.bcvsolutions.idm.rpt.api.dto.RptReportDto)1 RptProvisioningOperationDto (eu.bcvsolutions.idm.rpt.dto.RptProvisioningOperationDto)1 LdapServer (eu.bcvsolutions.idm.rpt.ldap.LdapServer)1 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)1 List (java.util.List)1 Test (org.junit.Test)1