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