use of eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter in project CzechIdMng by bcvsolutions.
the class DefaultVsRequestServiceIntegrationTest method createAndRealizeRequestTest.
@Test
public void createAndRealizeRequestTest() {
SysSystemDto system = this.createVirtualSystem(USER_IMPLEMENTER_NAME, null);
this.assignRoleSystem(system, helper.createIdentity(USER_ONE_NAME), ROLE_ONE_NAME);
// Find created requests
VsRequestFilter requestFilter = new VsRequestFilter();
requestFilter.setSystemId(system.getId());
requestFilter.setUid(USER_ONE_NAME);
List<VsRequestDto> requests = requestService.find(requestFilter, null).getContent();
Assert.assertEquals(1, requests.size());
VsRequestDto request = requests.get(0);
UUID requestId = request.getId();
Assert.assertEquals(USER_ONE_NAME, request.getUid());
Assert.assertEquals(VsOperationType.CREATE, request.getOperationType());
Assert.assertEquals(VsRequestState.IN_PROGRESS, request.getState());
VsAccountDto account = accountService.findByUidSystem(USER_ONE_NAME, system.getId());
Assert.assertNull("Account must be null, because request was not realized yet!", account);
// We try realize the request
super.logout();
loginService.login(new LoginDto(USER_IMPLEMENTER_NAME, new GuardedString("password")));
request = requestService.realize(request);
Assert.assertEquals(VsRequestState.REALIZED, request.getState());
account = accountService.findByUidSystem(USER_ONE_NAME, system.getId());
Assert.assertNotNull("Account cannot be null, because request was realized!", account);
// test referential integrity - delete system
// TODO: move to api
String virtualSystemKey = MessageFormat.format("{0}:systemId={1}", system.getConnectorKey().getFullName(), system.getId());
Assert.assertNotNull(formService.getDefinition(VsAccount.class, virtualSystemKey));
VsSystemImplementerFilter implementerFilter = new VsSystemImplementerFilter();
implementerFilter.setSystemId(system.getId());
Assert.assertNotEquals(0, systemImplementerService.count(implementerFilter));
// clean up acc accounts
AccAccountFilter accAccountFilter = new AccAccountFilter();
accAccountFilter.setSystemId(system.getId());
accAccountService.find(accAccountFilter, null).forEach(a -> {
accAccountService.delete(a);
});
requestService.find(requestFilter, null).forEach(r -> {
// delete account creates request in progress
if (!r.getId().equals(requestId)) {
requestService.delete(r);
}
});
Assert.assertNotNull(requestService.get(request));
systemService.delete(system);
Assert.assertNull(formService.getDefinition(VsAccount.class, virtualSystemKey));
Assert.assertNull(requestService.get(request));
Assert.assertNull(accountService.get(account));
Assert.assertEquals(0, systemImplementerService.count(implementerFilter));
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter in project CzechIdMng by bcvsolutions.
the class ChangesOnSystemReportIntegrationTest method testProvisioningOperationReportWithoutIdentities.
@Test
public void testProvisioningOperationReportWithoutIdentities() throws IOException {
IdmIdentityDto identityOne = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto identityTwo = getHelper().createIdentity((GuardedString) null);
IdmTreeNodeDto position = getHelper().createTreeNode();
getHelper().createContract(identityOne, position);
SysSystemDto system = createSystemWithOperation();
IdmRoleDto role = getHelper().createRole();
getHelper().createRoleSystem(role, system);
getHelper().createIdentityRole(identityTwo, role);
//
AccAccountFilter accountFilter = new AccAccountFilter();
accountFilter.setIdentityId(identityTwo.getId());
accountFilter.setSystemId(system.getId());
accountFilter.setEntityType(SystemEntityType.IDENTITY);
List<AccAccountDto> accounts = accountService.find(accountFilter, null).getContent();
Assert.assertEquals(1, accounts.size());
//
// prepare report filter
RptReportDto report = new RptReportDto(UUID.randomUUID());
report.setExecutorName(reportExecutor.getName());
IdmFormDto filter = new IdmFormDto();
IdmFormDefinitionDto definition = reportExecutor.getFormDefinition();
IdmFormValueDto filterValue = new IdmFormValueDto(definition.getMappedAttributeByCode(ChangesOnSystemReportExecutor.PARAMETER_MAPPING_ATTRIBUTES));
// TODO: create json java POJO representation
filterValue.setStringValue("{ \"system\": \"" + system.getId() + "\", \"systemMapping\": \"" + getHelper().getDefaultMapping(system).getId() + "\", \"mappingAttributes\": [] }");
filter.getValues().add(filterValue);
filter.setFormDefinition(definition.getId());
report.setFilter(filter);
//
// generate report
report = reportExecutor.generate(report);
Assert.assertNotNull(report.getData());
//
// test renderer
Assert.assertNotNull(xlsxRenderer.render(report));
//
attachmentManager.deleteAttachments(report);
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter in project CzechIdMng by bcvsolutions.
the class ChangesOnSystemReportIntegrationTest method testProvisioningOperationReportWithIdentities.
@Test
public void testProvisioningOperationReportWithIdentities() throws IOException {
IdmIdentityDto identityOne = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto identityTwo = getHelper().createIdentity((GuardedString) null);
IdmTreeNodeDto position = getHelper().createTreeNode();
getHelper().createContract(identityTwo, position);
SysSystemDto system = createSystemWithOperation();
SysSystemMappingDto defaultMapping = getHelper().getDefaultMapping(system);
SysSystemAttributeMappingDto attributeName = attributeMappingService.findBySystemMappingAndName(defaultMapping.getId(), TestHelper.ATTRIBUTE_MAPPING_NAME);
IdmRoleDto role = getHelper().createRole();
getHelper().createRoleSystem(role, system);
getHelper().createIdentityRole(identityTwo, role);
//
AccAccountFilter accountFilter = new AccAccountFilter();
accountFilter.setIdentityId(identityTwo.getId());
accountFilter.setSystemId(system.getId());
accountFilter.setEntityType(SystemEntityType.IDENTITY);
List<AccAccountDto> accounts = accountService.find(accountFilter, null).getContent();
Assert.assertEquals(1, accounts.size());
//
// prepare report filter
RptReportDto report = new RptReportDto(UUID.randomUUID());
report.setExecutorName(reportExecutor.getName());
IdmFormDto filter = new IdmFormDto();
IdmFormDefinitionDto definition = reportExecutor.getFormDefinition();
IdmFormValueDto filterValue = new IdmFormValueDto(definition.getMappedAttributeByCode(ChangesOnSystemReportExecutor.PARAMETER_MAPPING_ATTRIBUTES));
// TODO: create json java POJO representation
filterValue.setStringValue("{ \"system\": \"" + system.getId() + "\", \"systemMapping\": \"" + defaultMapping.getId() + "\", \"mappingAttributes\": [ \"" + attributeName.getId() + "\" ] }");
filter.getValues().add(filterValue);
IdmFormValueDto filterIdentitites = new IdmFormValueDto(definition.getMappedAttributeByCode(ChangesOnSystemReportExecutor.PARAMETER_ONLY_IDENTITY));
filterIdentitites.setUuidValue(identityOne.getId());
filter.getValues().add(filterIdentitites);
IdmFormValueDto filterTreeNode = new IdmFormValueDto(definition.getMappedAttributeByCode(ChangesOnSystemReportExecutor.PARAMETER_TREE_NODE));
filterTreeNode.setUuidValue(position.getId());
filter.getValues().add(filterTreeNode);
filter.setFormDefinition(definition.getId());
report.setFilter(filter);
//
// generate report
report = reportExecutor.generate(report);
Assert.assertNotNull(report.getData());
//
// test renderer
Assert.assertNotNull(xlsxRenderer.render(report));
//
attachmentManager.deleteAttachments(report);
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter in project CzechIdMng by bcvsolutions.
the class VsProvisioningMergeTest method testSwitchControlledValue.
@Test
public void testSwitchControlledValue() {
VsSystemDto config = new VsSystemDto();
config.setName(helper.createName());
config.setCreateDefaultRole(false);
SysSystemDto system = helper.createVirtualSystem(config);
IdmRoleDto roleOne = helper.createRole();
IdmRoleDto roleTwo = helper.createRole();
SysRoleSystemDto roleSystemOne = helper.createRoleSystem(roleOne, system);
SysRoleSystemDto roleSystemTwo = helper.createRoleSystem(roleTwo, system);
SysSystemMappingDto mapping = mappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
SysSystemAttributeMappingFilter attributeFilter = new SysSystemAttributeMappingFilter();
attributeFilter.setSystemMappingId(mapping.getId());
attributeFilter.setSchemaAttributeName(RIGHTS_ATTRIBUTE);
List<SysSystemAttributeMappingDto> attributes = attributeMappingService.find(attributeFilter, null).getContent();
assertEquals(1, attributes.size());
SysSystemAttributeMappingDto rightsAttribute = attributes.get(0);
SysRoleSystemAttributeDto roleAttributeOne = new SysRoleSystemAttributeDto();
roleAttributeOne.setName(RIGHTS_ATTRIBUTE);
roleAttributeOne.setRoleSystem(roleSystemOne.getId());
roleAttributeOne.setEntityAttribute(false);
roleAttributeOne.setExtendedAttribute(false);
roleAttributeOne.setUid(false);
roleAttributeOne.setStrategyType(AttributeMappingStrategyType.MERGE);
roleAttributeOne.setSystemAttributeMapping(rightsAttribute.getId());
roleAttributeOne.setTransformToResourceScript("return '" + ONE_VALUE + "';");
roleAttributeOne = roleSystemAttributeService.saveInternal(roleAttributeOne);
SysRoleSystemAttributeDto roleAttributeTwo = new SysRoleSystemAttributeDto();
roleAttributeTwo.setName(RIGHTS_ATTRIBUTE);
roleAttributeTwo.setRoleSystem(roleSystemTwo.getId());
roleAttributeTwo.setEntityAttribute(false);
roleAttributeTwo.setExtendedAttribute(false);
roleAttributeTwo.setUid(false);
roleAttributeTwo.setStrategyType(AttributeMappingStrategyType.MERGE);
roleAttributeTwo.setSystemAttributeMapping(rightsAttribute.getId());
roleAttributeTwo.setTransformToResourceScript("return '" + TWO_VALUE + "';");
roleAttributeTwo = roleSystemAttributeService.saveInternal(roleAttributeTwo);
IdmIdentityDto identity = helper.createIdentity();
helper.createIdentityRole(identity, roleOne);
helper.createIdentityRole(identity, roleTwo);
AccAccountFilter accountFilter = new AccAccountFilter();
accountFilter.setSystemId(system.getId());
List<AccAccountDto> accounts = accountService.find(accountFilter, null).getContent();
assertEquals(1, accounts.size());
AccAccountDto account = accounts.get(0);
IcConnectorObject connectorObject = accountService.getConnectorObject(account);
IcAttribute rightsAttributeFromSystem = connectorObject.getAttributeByName(RIGHTS_ATTRIBUTE);
List<Object> rightsValues = rightsAttributeFromSystem.getValues();
assertEquals(2, rightsValues.size());
assertTrue(rightsValues.contains(ONE_VALUE));
assertTrue(rightsValues.contains(TWO_VALUE));
// Change controlled value
roleAttributeOne.setTransformToResourceScript("return '" + ONE_VALUE + "_changed';");
roleAttributeOne = roleSystemAttributeService.saveInternal(roleAttributeOne);
SysAttributeControlledValueFilter controlledValueFilter = new SysAttributeControlledValueFilter();
controlledValueFilter.setHistoricValue(Boolean.TRUE);
controlledValueFilter.setAttributeMappingId(rightsAttribute.getId());
List<SysAttributeControlledValueDto> attributeControlledValues = controlledValueService.find(controlledValueFilter, null).getContent();
// One historic value should be exists
assertEquals(1, attributeControlledValues.size());
assertEquals(ONE_VALUE, attributeControlledValues.get(0).getValue());
// Deleting of old value ... we don't want controlled it from now
controlledValueService.delete(attributeControlledValues.get(0));
// Do provisioning
identityService.save(identity);
// Check values on target system
accounts = accountService.find(accountFilter, null).getContent();
assertEquals(1, accounts.size());
account = accounts.get(0);
connectorObject = accountService.getConnectorObject(account);
rightsAttributeFromSystem = connectorObject.getAttributeByName(RIGHTS_ATTRIBUTE);
rightsValues = rightsAttributeFromSystem.getValues();
assertEquals(3, rightsValues.size());
assertTrue(rightsValues.contains(ONE_VALUE));
assertTrue(rightsValues.contains(TWO_VALUE));
assertTrue(rightsValues.contains(ONE_VALUE + "_changed"));
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter in project CzechIdMng by bcvsolutions.
the class VsProvisioningMergeTest method testChangeControlledValue.
@Test
public void testChangeControlledValue() {
VsSystemDto config = new VsSystemDto();
config.setName(helper.createName());
config.setCreateDefaultRole(false);
SysSystemDto system = helper.createVirtualSystem(config);
IdmRoleDto roleOne = helper.createRole();
IdmRoleDto roleTwo = helper.createRole();
SysRoleSystemDto roleSystemOne = helper.createRoleSystem(roleOne, system);
SysRoleSystemDto roleSystemTwo = helper.createRoleSystem(roleTwo, system);
SysSystemMappingDto mapping = mappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
SysSystemAttributeMappingFilter attributeFilter = new SysSystemAttributeMappingFilter();
attributeFilter.setSystemMappingId(mapping.getId());
attributeFilter.setSchemaAttributeName(RIGHTS_ATTRIBUTE);
List<SysSystemAttributeMappingDto> attributes = attributeMappingService.find(attributeFilter, null).getContent();
assertEquals(1, attributes.size());
SysSystemAttributeMappingDto rightsAttribute = attributes.get(0);
SysRoleSystemAttributeDto roleAttributeOne = new SysRoleSystemAttributeDto();
roleAttributeOne.setName(RIGHTS_ATTRIBUTE);
roleAttributeOne.setRoleSystem(roleSystemOne.getId());
roleAttributeOne.setEntityAttribute(false);
roleAttributeOne.setExtendedAttribute(false);
roleAttributeOne.setUid(false);
roleAttributeOne.setStrategyType(AttributeMappingStrategyType.MERGE);
roleAttributeOne.setSystemAttributeMapping(rightsAttribute.getId());
roleAttributeOne.setTransformToResourceScript("return '" + ONE_VALUE + "';");
roleAttributeOne = roleSystemAttributeService.saveInternal(roleAttributeOne);
SysRoleSystemAttributeDto roleAttributeTwo = new SysRoleSystemAttributeDto();
roleAttributeTwo.setName(RIGHTS_ATTRIBUTE);
roleAttributeTwo.setRoleSystem(roleSystemTwo.getId());
roleAttributeTwo.setEntityAttribute(false);
roleAttributeTwo.setExtendedAttribute(false);
roleAttributeTwo.setUid(false);
roleAttributeTwo.setStrategyType(AttributeMappingStrategyType.MERGE);
roleAttributeTwo.setSystemAttributeMapping(rightsAttribute.getId());
roleAttributeTwo.setTransformToResourceScript("return '" + TWO_VALUE + "';");
roleAttributeTwo = roleSystemAttributeService.saveInternal(roleAttributeTwo);
IdmIdentityDto identity = helper.createIdentity();
helper.createIdentityRole(identity, roleOne);
helper.createIdentityRole(identity, roleTwo);
// Change controlled value
roleAttributeOne.setTransformToResourceScript("return '" + ONE_VALUE + "_changed';");
roleAttributeOne = roleSystemAttributeService.saveInternal(roleAttributeOne);
// Do provisioning
identityService.save(identity);
// Check values on target system
AccAccountFilter accountFilter = new AccAccountFilter();
accountFilter.setSystemId(system.getId());
List<AccAccountDto> accounts = accountService.find(accountFilter, null).getContent();
assertEquals(1, accounts.size());
AccAccountDto account = accounts.get(0);
IcConnectorObject connectorObject = accountService.getConnectorObject(account);
IcAttribute rightsAttributeFromSystem = connectorObject.getAttributeByName(RIGHTS_ATTRIBUTE);
List<Object> rightsValues = rightsAttributeFromSystem.getValues();
assertEquals(2, rightsValues.size());
assertTrue(rightsValues.contains(TWO_VALUE));
assertTrue(rightsValues.contains(ONE_VALUE + "_changed"));
}
Aggregations