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);
}
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);
}
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();
}
}
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);
}
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);
}
Aggregations