use of eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemMappingServiceIntegrationTest method testIdentityStateAndDisabledWArning.
@Test
public void testIdentityStateAndDisabledWArning() {
SysSystemDto system = testHelper.createSystem(testHelper.createName());
SysSchemaObjectClassDto schema = this.createObjectClass(system);
SysSchemaAttributeDto nameSchemaAttr = createSchemaAttribute("name", schema);
SysSchemaAttributeDto stateSchemaAttr = createSchemaAttribute("state", schema);
SysSchemaAttributeDto disabledSchemaAttr = createSchemaAttribute("disabled", schema);
SysSystemMappingDto mappingDto = this.createProvisioningMappingSystem(SystemEntityType.IDENTITY, schema);
SysSystemAttributeMappingDto nameAttrMap = new SysSystemAttributeMappingDto();
nameAttrMap.setUid(true);
nameAttrMap.setEntityAttribute(true);
nameAttrMap.setSystemMapping(mappingDto.getId());
nameAttrMap.setIdmPropertyName("username");
nameAttrMap.setName(nameSchemaAttr.getName());
nameAttrMap.setSchemaAttribute(nameSchemaAttr.getId());
nameAttrMap = mappingAttributeService.save(nameAttrMap);
SysSystemAttributeMappingDto stateAttrMap = new SysSystemAttributeMappingDto();
stateAttrMap.setUid(false);
stateAttrMap.setEntityAttribute(true);
stateAttrMap.setSystemMapping(mappingDto.getId());
stateAttrMap.setIdmPropertyName("state");
stateAttrMap.setName(stateSchemaAttr.getName());
stateAttrMap.setSchemaAttribute(stateSchemaAttr.getId());
stateAttrMap = mappingAttributeService.save(stateAttrMap);
// SHOULD NOT THROW only state attribute mapped
mappingService.validate(mappingDto.getId());
SysSystemAttributeMappingDto disabledAttrMap = new SysSystemAttributeMappingDto();
disabledAttrMap.setUid(false);
disabledAttrMap.setEntityAttribute(true);
disabledAttrMap.setSystemMapping(mappingDto.getId());
disabledAttrMap.setIdmPropertyName("disabled");
disabledAttrMap.setName(disabledSchemaAttr.getName());
disabledAttrMap.setSchemaAttribute(disabledSchemaAttr.getId());
disabledAttrMap = mappingAttributeService.save(disabledAttrMap);
// both state and disabled attributes are mapped SHOULD THROW
try {
mappingService.validate(mappingDto.getId());
fail("Should throw");
} catch (ResultCodeException e) {
Assert.assertTrue(e.getError().getError().getParameters().containsKey(DefaultSysSystemMappingService.IDENTITY_STATE_USED_WITH_DISABLED));
}
mappingAttributeService.delete(stateAttrMap);
// SHOULD NOT THROW only disabled attribute mapped
mappingService.validate(mappingDto.getId());
}
use of eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingServiceFilterTest method testFilterBySchemaAttributeId.
@Test
public void testFilterBySchemaAttributeId() {
SysSystemDto system = this.getHelper().createTestResourceSystem(true, getHelper().createName());
// Generate second system for add mapped attributes
this.getHelper().createTestResourceSystem(true, getHelper().createName());
SysSystemMappingFilter filterMapping = new SysSystemMappingFilter();
filterMapping.setSystemId(system.getId());
List<SysSystemMappingDto> mappings = systemMappingService.find(filterMapping, null).getContent();
assertEquals(1, mappings.size());
SysSystemMappingDto mappingDto = mappings.get(0);
SysSchemaAttributeFilter schemaFilter = new SysSchemaAttributeFilter();
schemaFilter.setSystemId(system.getId());
schemaFilter.setName(TestHelper.ATTRIBUTE_MAPPING_EMAIL);
List<SysSchemaAttributeDto> schemaAttributes = schemaAttributeService.find(schemaFilter, null).getContent();
assertEquals(1, schemaAttributes.size());
SysSchemaAttributeDto schemaAttributeDto = schemaAttributes.get(0);
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSchemaAttributeId(schemaAttributeDto.getId());
List<SysSystemAttributeMappingDto> attributeMappings = systemAttributeMappingService.find(filter, null).getContent();
assertEquals(1, attributeMappings.size());
SysSystemAttributeMappingDto attributeMappingDto = attributeMappings.get(0);
assertEquals(TestHelper.ATTRIBUTE_MAPPING_EMAIL, attributeMappingDto.getName());
assertEquals(mappingDto.getId(), attributeMappingDto.getSystemMapping());
assertEquals(schemaAttributeDto.getId(), attributeMappingDto.getSchemaAttribute());
}
use of eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto in project CzechIdMng by bcvsolutions.
the class ProvisioningMergeTest method testChangeStrategyAttribteControlledValues.
@Test
public void testChangeStrategyAttribteControlledValues() {
SysSystemDto system = helper.createSystem("test_resource");
SysSystemMappingDto mapping = helper.createMapping(system);
IdmRoleDto roleOne = helper.createRole();
IdmRoleDto roleTwo = helper.createRole();
SysRoleSystemDto roleSystemOne = helper.createRoleSystem(roleOne, system);
SysRoleSystemDto roleSystemTwo = helper.createRoleSystem(roleTwo, system);
SysSchemaObjectClassDto objectClass = schemaService.get(mapping.getObjectClass());
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setObjectClassId(objectClass.getId());
schemaAttributeService.find(schemaAttributeFilter, null);
SysSchemaAttributeDto rightsSchemaAttribute = new SysSchemaAttributeDto();
rightsSchemaAttribute.setObjectClass(objectClass.getId());
rightsSchemaAttribute.setName(RIGHTS_ATTRIBUTE);
rightsSchemaAttribute.setMultivalued(true);
rightsSchemaAttribute.setClassType(String.class.getName());
rightsSchemaAttribute.setReadable(true);
rightsSchemaAttribute.setUpdateable(true);
rightsSchemaAttribute = schemaAttributeService.save(rightsSchemaAttribute);
SysSystemAttributeMappingDto rightsAttribute = new SysSystemAttributeMappingDto();
rightsAttribute.setSchemaAttribute(rightsSchemaAttribute.getId());
rightsAttribute.setSystemMapping(mapping.getId());
rightsAttribute.setName(RIGHTS_ATTRIBUTE);
rightsAttribute.setStrategyType(AttributeMappingStrategyType.MERGE);
rightsAttribute = attributeMappingService.save(rightsAttribute);
SysRoleSystemAttributeDto roleAttributeOne = new SysRoleSystemAttributeDto();
roleAttributeOne.setName(RIGHTS_ATTRIBUTE);
roleAttributeOne.setRoleSystem(roleSystemOne.getId());
roleAttributeOne.setStrategyType(AttributeMappingStrategyType.MERGE);
roleAttributeOne.setSystemAttributeMapping(rightsAttribute.getId());
roleAttributeOne.setTransformToResourceScript("return '" + ONE_VALUE + "';");
roleAttributeOne = roleSystemAttributeService.saveInternal(roleAttributeOne);
List<Serializable> controlledAttributeValues = attributeMappingService.getControlledAttributeValues(system.getId(), mapping.getEntityType(), RIGHTS_ATTRIBUTE);
SysRoleSystemAttributeDto roleAttributeTwo = new SysRoleSystemAttributeDto();
roleAttributeTwo.setName(RIGHTS_ATTRIBUTE);
roleAttributeTwo.setRoleSystem(roleSystemTwo.getId());
roleAttributeTwo.setStrategyType(AttributeMappingStrategyType.MERGE);
roleAttributeTwo.setSystemAttributeMapping(rightsAttribute.getId());
roleAttributeTwo.setTransformToResourceScript("return '" + TWO_VALUE + "';");
roleAttributeTwo = roleSystemAttributeService.saveInternal(roleAttributeTwo);
controlledAttributeValues = attributeMappingService.getControlledAttributeValues(system.getId(), mapping.getEntityType(), RIGHTS_ATTRIBUTE);
assertNotNull(controlledAttributeValues);
assertEquals(2, controlledAttributeValues.size());
assertTrue(controlledAttributeValues.contains(ONE_VALUE));
assertTrue(controlledAttributeValues.contains(TWO_VALUE));
SysAttributeControlledValueFilter attributeControlledValueFilter = new SysAttributeControlledValueFilter();
attributeControlledValueFilter.setAttributeMappingId(rightsAttribute.getId());
attributeControlledValueFilter.setHistoricValue(Boolean.TRUE);
List<Serializable> historicControlledValues = //
attributeControlledValueService.find(attributeControlledValueFilter, //
null).getContent().stream().map(//
SysAttributeControlledValueDto::getValue).collect(Collectors.toList());
assertNotNull(historicControlledValues);
assertEquals(0, historicControlledValues.size());
// Set attribute TWO as SET (should be disappears from controlled values
// and appears in the history)
roleAttributeTwo.setStrategyType(AttributeMappingStrategyType.SET);
roleAttributeTwo = roleSystemAttributeService.saveInternal(roleAttributeTwo);
controlledAttributeValues = attributeMappingService.getControlledAttributeValues(system.getId(), mapping.getEntityType(), RIGHTS_ATTRIBUTE);
assertNotNull(controlledAttributeValues);
assertEquals(1, controlledAttributeValues.size());
assertTrue(controlledAttributeValues.contains(ONE_VALUE));
// Search historic controlled values for that attribute
historicControlledValues = //
attributeControlledValueService.find(attributeControlledValueFilter, //
null).getContent().stream().map(//
SysAttributeControlledValueDto::getValue).collect(Collectors.toList());
assertNotNull(historicControlledValues);
assertEquals(1, historicControlledValues.size());
assertTrue(historicControlledValues.contains(TWO_VALUE));
// Set attribute TWO as MERGE (should be appears in controlled values
// and disappears from the history)
roleAttributeTwo.setStrategyType(AttributeMappingStrategyType.MERGE);
roleAttributeTwo = roleSystemAttributeService.saveInternal(roleAttributeTwo);
controlledAttributeValues = attributeMappingService.getControlledAttributeValues(system.getId(), mapping.getEntityType(), RIGHTS_ATTRIBUTE);
assertNotNull(controlledAttributeValues);
assertEquals(2, controlledAttributeValues.size());
assertTrue(controlledAttributeValues.contains(ONE_VALUE));
assertTrue(controlledAttributeValues.contains(TWO_VALUE));
// Manual recalculation (needed for deleting redundant historic value)
attributeMappingService.recalculateAttributeControlledValues(system.getId(), mapping.getEntityType(), RIGHTS_ATTRIBUTE, rightsAttribute);
// Search historic controlled values for that attribute
historicControlledValues = //
attributeControlledValueService.find(attributeControlledValueFilter, //
null).getContent().stream().map(//
SysAttributeControlledValueDto::getValue).collect(Collectors.toList());
assertNotNull(historicControlledValues);
assertEquals(0, historicControlledValues.size());
}
use of eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto in project CzechIdMng by bcvsolutions.
the class SysSystemMappingServiceValidationTest method testSystemMappingValidationNotMissingIdentifier.
@Test
public void testSystemMappingValidationNotMissingIdentifier() {
SysSystemDto system = createSystem();
SysSchemaObjectClassDto schema = createSchema(system.getId());
SysSystemMappingDto mapping = createMapping(schema.getId(), SystemOperationType.PROVISIONING);
SysSchemaAttributeDto schemaAttribute = createSchemaAttribute(schema.getId());
createAttributeMapping(mapping.getId(), schemaAttribute.getId(), true, "");
mappingService.validate(mapping.getId());
}
use of eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto in project CzechIdMng by bcvsolutions.
the class SysSystemMappingServiceValidationTest method testSystemMappingValidationMissingIdentifier.
@Test(expected = ResultCodeException.class)
public void testSystemMappingValidationMissingIdentifier() {
SysSystemDto system = createSystem();
SysSchemaObjectClassDto schema = createSchema(system.getId());
SysSystemMappingDto mapping = createMapping(schema.getId(), SystemOperationType.PROVISIONING);
SysSchemaAttributeDto schemaAttribute = createSchemaAttribute(schema.getId());
createAttributeMapping(mapping.getId(), schemaAttribute.getId(), false, "");
mappingService.validate(mapping.getId());
}
Aggregations