Search in sources :

Example 26 with IdmFormDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto in project CzechIdMng by bcvsolutions.

the class IdentityRoleByIdentityDeduplicationExecutorTest method testExecuteReportTwoContract.

@Test
public void testExecuteReportTwoContract() throws JsonParseException, JsonMappingException, IOException {
    String roleCode = "test-" + System.currentTimeMillis();
    IdmTreeNodeDto treeNode = getHelper().createTreeNode();
    IdmIdentityDto identity = getHelper().createIdentity(new GuardedString());
    IdmIdentityContractDto contactOne = getHelper().createContract(identity, treeNode);
    IdmIdentityContractDto contactTwo = getHelper().createContract(identity, treeNode);
    IdmRoleDto role = getHelper().createRole(roleCode);
    getHelper().createIdentityRole(contactOne, role);
    getHelper().createIdentityRole(contactOne, role);
    getHelper().createIdentityRole(contactTwo, role);
    getHelper().createIdentityRole(contactTwo, role);
    RptReportDto report = new RptReportDto(UUID.randomUUID());
    report.setExecutorName(reportExecutor.getName());
    IdmFormDto filter = new IdmFormDto();
    IdmFormDefinitionDto definition = reportExecutor.getFormDefinition();
    IdmFormValueDto treeNodeParameter = new IdmFormValueDto(definition.getMappedAttributeByCode(IdentityRoleByIdentityDeduplicationExecutor.PARAMETER_TREE_NODE));
    treeNodeParameter.setValue(treeNode.getId());
    filter.getValues().add(treeNodeParameter);
    filter.setFormDefinition(definition.getId());
    report.setFilter(filter);
    report = reportExecutor.generate(report);
    Assert.assertNotNull(report.getData());
    List<RptIdentityRoleByRoleDeduplicationDto> reportItems = mapper.readValue(attachmentManager.getAttachmentData(report.getData()), new TypeReference<List<RptIdentityRoleByRoleDeduplicationDto>>() {
    });
    assertEquals(2, reportItems.size());
    for (RptIdentityRoleByRoleDeduplicationDto item : reportItems) {
        assertNotNull(item.getIdentity());
        assertEquals(identity.getId(), item.getIdentity().getId());
        assertNotNull(item.getWorkPosition());
        assertEquals(treeNode.getId(), item.getWorkPosition().getId());
        assertNotNull(item.getIdentityContract());
        if (item.getIdentityContract().getId().equals(contactOne.getId())) {
        // Success
        } else if (item.getIdentityContract().getId().equals(contactTwo.getId())) {
        // Success
        } else {
            fail();
        }
        List<RptIdentityRoleByRoleDeduplicationDuplicityDto> duplicities = item.getDuplicity();
        assertEquals(1, duplicities.size());
    }
    attachmentManager.deleteAttachments(report);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) RptIdentityRoleByRoleDeduplicationDuplicityDto(eu.bcvsolutions.idm.rpt.dto.RptIdentityRoleByRoleDeduplicationDuplicityDto) IdmFormDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) RptIdentityRoleByRoleDeduplicationDto(eu.bcvsolutions.idm.rpt.dto.RptIdentityRoleByRoleDeduplicationDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) List(java.util.List) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 27 with IdmFormDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto in project CzechIdMng by bcvsolutions.

the class IdentityEavReportExecutorIntegrationTest method testEmptyAttribute.

@Test(expected = ResultCodeException.class)
public void testEmptyAttribute() throws IOException {
    // prepare report filter
    RptReportDto report = new RptReportDto(UUID.randomUUID());
    report.setExecutorName(reportExecutor.getName());
    IdmFormDto filter = new IdmFormDto();
    IdmFormDefinitionDto definition = reportExecutor.getFormDefinition();
    // 
    IdmFormValueDto formDefinitionAttribute = new IdmFormValueDto(definition.getMappedAttributeByCode(IdentityEavReportExecutor.PARAMETER_FORM_DEFINITION));
    formDefinitionAttribute.setValue(formService.getDefinition(IdmIdentityDto.class).getId());
    // 
    // add all attributes
    filter.getValues().add(formDefinitionAttribute);
    filter.setFormDefinition(definition.getId());
    report.setFilter(filter);
    // generate report
    reportExecutor.generate(report);
}
Also used : IdmFormDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 28 with IdmFormDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto in project CzechIdMng by bcvsolutions.

the class IdentityEavReportExecutorIntegrationTest method testAuthorizationPolicies.

@Test
public void testAuthorizationPolicies() throws IOException {
    try {
        // prepare test identities
        IdmIdentityDto identityOne = getHelper().createIdentity();
        IdmIdentityDto identityTwo = getHelper().createIdentity();
        // 
        // assign role with no policy
        IdmRoleDto role = getHelper().createRole();
        getHelper().createIdentityRole(identityOne, role);
        // assign role with read policy
        IdmRoleDto roleRead = getHelper().createRole();
        getHelper().createAuthorizationPolicy(roleRead.getId(), CoreGroupPermission.IDENTITY, IdmIdentity.class, BasePermissionEvaluator.class, IdmBasePermission.AUTOCOMPLETE, IdmBasePermission.READ);
        getHelper().createIdentityRole(identityTwo, roleRead);
        // 
        // prepare report filter
        RptReportDto report = new RptReportDto(UUID.randomUUID());
        report.setExecutorName(reportExecutor.getName());
        IdmFormDto filter = new IdmFormDto();
        IdmFormDefinitionDto definition = reportExecutor.getFormDefinition();
        // 
        IdmFormValueDto disabled = new IdmFormValueDto(definition.getMappedAttributeByCode(IdmIdentityFilter.PARAMETER_DISABLED));
        disabled.setValue(false);
        // 
        IdmFormValueDto formDefinitionAttribute = new IdmFormValueDto(definition.getMappedAttributeByCode(IdentityEavReportExecutor.PARAMETER_FORM_DEFINITION));
        IdmFormDefinitionDto definitionAttribute = formService.getDefinition(IdmIdentityDto.class);
        formDefinitionAttribute.setValue(definitionAttribute.getId());
        // 
        IdmFormValueDto eavName = new IdmFormValueDto(definition.getMappedAttributeByCode(IdentityEavReportExecutor.PARAMETER_FORM_ATTRIBUTE));
        String code = getHelper().createName();
        createFormAttribute(code, definitionAttribute.getId());
        eavName.setValue(code);
        // add all attributes
        filter.getValues().add(disabled);
        filter.getValues().add(formDefinitionAttribute);
        filter.getValues().add(eavName);
        filter.setFormDefinition(definition.getId());
        report.setFilter(filter);
        // set eav to identity
        List<String> values = new ArrayList<>();
        String testValue = getHelper().createName();
        values.add(testValue);
        // 
        formService.saveValues(identityOne, definitionAttribute, code, Lists.newArrayList(values));
        logout();
        getHelper().login(identityOne);
        // generate report
        report = reportExecutor.generate(report);
        Assert.assertNotNull(report.getData());
        List<RptIdentityWithFormValueDto> identities = mapper.readValue(attachmentManager.getAttachmentData(report.getData()), new TypeReference<List<RptIdentityWithFormValueDto>>() {
        });
        // 
        // test
        assertEquals(0, identities.size());
        logout();
        getHelper().createBasePolicy(roleRead.getId(), CoreGroupPermission.FORMDEFINITION, IdmFormDefinition.class, IdmBasePermission.AUTOCOMPLETE);
        getHelper().createAuthorizationPolicy(roleRead.getId(), CoreGroupPermission.FORMVALUE, IdmIdentityFormValue.class, IdentityFormValueEvaluator.class, IdmBasePermission.READ);
        getHelper().login(identityTwo);
        report = reportExecutor.generate(report);
        Assert.assertNotNull(report.getData());
        List<RptIdentityWithFormValueDto> identitiesAgain = mapper.readValue(attachmentManager.getAttachmentData(report.getData()), new TypeReference<List<RptIdentityWithFormValueDto>>() {
        });
        // 
        // test
        assertEquals(1, identitiesAgain.size());
        attachmentManager.deleteAttachments(report);
    } finally {
        logout();
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) ArrayList(java.util.ArrayList) IdmFormDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) RptIdentityWithFormValueDto(eu.bcvsolutions.idm.rpt.dto.RptIdentityWithFormValueDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) ArrayList(java.util.ArrayList) List(java.util.List) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 29 with IdmFormDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto in project CzechIdMng by bcvsolutions.

the class IdentityEavReportExecutorIntegrationTest method testReportWithValueSpecified.

@Test
public void testReportWithValueSpecified() throws IOException {
    // prepare test identities
    IdmIdentityDto identityOne = getHelper().createIdentity((GuardedString) null);
    IdmIdentityDto identityDisabled = getHelper().createIdentity((GuardedString) null);
    identityService.disable(identityDisabled.getId());
    // 
    // prepare report filter
    RptReportDto report = new RptReportDto(UUID.randomUUID());
    report.setExecutorName(reportExecutor.getName());
    IdmFormDto filter = new IdmFormDto();
    IdmFormDefinitionDto reportForm = reportExecutor.getFormDefinition();
    // 
    IdmFormValueDto parameterDefinition = new IdmFormValueDto(reportForm.getMappedAttributeByCode(IdentityEavReportExecutor.PARAMETER_FORM_DEFINITION));
    IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentityDto.class);
    parameterDefinition.setValue(formDefinition.getId());
    // 
    String code = getHelper().createName();
    createFormAttribute(code, formDefinition.getId());
    IdmFormValueDto parameterAttribute = new IdmFormValueDto(reportForm.getMappedAttributeByCode(IdentityEavReportExecutor.PARAMETER_FORM_ATTRIBUTE));
    parameterAttribute.setValue(code);
    // 
    String testValue = getHelper().createName();
    IdmFormValueDto parameterValue = new IdmFormValueDto(reportForm.getMappedAttributeByCode(IdentityEavReportExecutor.PARAMETER_EAV_VALUE));
    parameterValue.setValue(testValue);
    // add attributes
    filter.getValues().add(parameterDefinition);
    filter.getValues().add(parameterAttribute);
    filter.getValues().add(parameterValue);
    filter.setFormDefinition(reportForm.getId());
    report.setFilter(filter);
    // 
    formService.saveValues(identityOne, formDefinition, code, Lists.newArrayList(testValue));
    // generate report
    report = reportExecutor.generate(report);
    Assert.assertNotNull(report.getData());
    List<RptIdentityWithFormValueDto> identities = mapper.readValue(attachmentManager.getAttachmentData(report.getData()), new TypeReference<List<RptIdentityWithFormValueDto>>() {
    });
    // 
    // test
    assertEquals(1, identities.size());
    assertEquals(testValue, identities.get(0).getFormValues().get(0));
    // rest renderer
    Assert.assertNotNull(xlsxRenderer.render(report));
    // 
    attachmentManager.deleteAttachments(report);
}
Also used : IdmFormDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) ArrayList(java.util.ArrayList) List(java.util.List) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) RptIdentityWithFormValueDto(eu.bcvsolutions.idm.rpt.dto.RptIdentityWithFormValueDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 30 with IdmFormDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto in project CzechIdMng by bcvsolutions.

the class IdentityEavReportExecutorIntegrationTest method testWrongDefinition.

@Test(expected = ResultCodeException.class)
public void testWrongDefinition() throws IOException {
    // prepare report filter
    RptReportDto report = new RptReportDto(UUID.randomUUID());
    report.setExecutorName(reportExecutor.getName());
    IdmFormDto filter = new IdmFormDto();
    IdmFormDefinitionDto definition = reportExecutor.getFormDefinition();
    // 
    IdmFormValueDto formDefinitionAttribute = new IdmFormValueDto(definition.getMappedAttributeByCode(IdentityEavReportExecutor.PARAMETER_FORM_DEFINITION));
    IdmFormDefinitionDto definitionAttribute = formService.getDefinition(IdmRoleDto.class);
    formDefinitionAttribute.setValue(definitionAttribute.getId());
    // 
    // add all attributes
    filter.getValues().add(formDefinitionAttribute);
    filter.setFormDefinition(definition.getId());
    report.setFilter(filter);
    // generate report
    reportExecutor.generate(report);
}
Also used : IdmFormDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmFormDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto)35 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)33 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)31 RptReportDto (eu.bcvsolutions.idm.rpt.api.dto.RptReportDto)31 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)31 Test (org.junit.Test)31 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)22 List (java.util.List)17 UUID (java.util.UUID)16 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)12 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)12 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)9 InputStream (java.io.InputStream)7 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)6 ArrayList (java.util.ArrayList)6 Transactional (org.springframework.transaction.annotation.Transactional)6 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)5 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)5 AccAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter)5 AttachmentManager (eu.bcvsolutions.idm.core.ecm.api.service.AttachmentManager)5