use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemServiceIntegrationTest method testReferentialIntegrity.
@Test
public void testReferentialIntegrity() {
SysSystemDto system = new SysSystemDto();
String systemName = getHelper().createName();
system.setName(systemName);
system = systemService.save(system);
// object class
SysSchemaObjectClassDto objectClass = new SysSchemaObjectClassDto();
objectClass.setSystem(system.getId());
objectClass.setObjectClassName("obj_class");
objectClass = schemaObjectClassService.save(objectClass);
SysSchemaObjectClassFilter objectClassFilter = new SysSchemaObjectClassFilter();
objectClassFilter.setSystemId(system.getId());
// schema attribute
SysSchemaAttributeDto schemaAttribute = new SysSchemaAttributeDto();
schemaAttribute.setObjectClass(objectClass.getId());
schemaAttribute.setName("name");
schemaAttribute.setClassType("class");
schemaAttribute = schemaAttributeService.save(schemaAttribute);
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
// system entity handling
SysSystemMappingDto systemMapping = new SysSystemMappingDto();
systemMapping.setName("default_" + System.currentTimeMillis());
systemMapping.setObjectClass(objectClass.getId());
systemMapping.setOperationType(SystemOperationType.PROVISIONING);
systemMapping.setEntityType(SystemEntityType.IDENTITY);
systemMapping = systemMappingService.save(systemMapping);
SysSystemMappingFilter entityHandlingFilter = new SysSystemMappingFilter();
entityHandlingFilter.setSystemId(system.getId());
// schema attribute handling
SysSystemAttributeMappingDto schemaAttributeHandling = new SysSystemAttributeMappingDto();
schemaAttributeHandling.setSchemaAttribute(schemaAttribute.getId());
schemaAttributeHandling.setSystemMapping(systemMapping.getId());
schemaAttributeHandling.setName("name");
schemaAttributeHandling.setIdmPropertyName("name");
schemaAttributeHandling = systemAttributeMappingService.save(schemaAttributeHandling);
SysSystemAttributeMappingFilter schemaAttributeHandlingFilter = new SysSystemAttributeMappingFilter();
schemaAttributeHandlingFilter.setSystemId(system.getId());
// role system
IdmRoleDto role = helper.createRole();
SysRoleSystemDto roleSystem = new SysRoleSystemDto();
roleSystem.setSystem(system.getId());
roleSystem.setRole(role.getId());
roleSystem.setSystemMapping(systemMapping.getId());
roleSystem = roleSystemService.save(roleSystem);
SysRoleSystemFilter roleSystemFilter = new SysRoleSystemFilter();
roleSystemFilter.setRoleId(role.getId());
// role system attributes
SysRoleSystemAttributeDto roleSystemAttribute = new SysRoleSystemAttributeDto();
roleSystemAttribute.setRoleSystem(roleSystem.getId());
roleSystemAttribute.setSystemAttributeMapping(schemaAttributeHandling.getId());
roleSystemAttribute.setName("name");
roleSystemAttribute.setIdmPropertyName("name");
roleSystemAttribute = roleSystemAttributeService.save(roleSystemAttribute);
assertEquals(systemName, systemService.getByCode(systemName).getName());
assertEquals(1, schemaObjectClassService.find(objectClassFilter, null).getTotalElements());
assertEquals(1, schemaAttributeService.find(schemaAttributeFilter, null).getTotalElements());
assertEquals(1, systemMappingService.find(entityHandlingFilter, null).getTotalElements());
assertEquals(1, systemAttributeMappingService.find(schemaAttributeHandlingFilter, null).getTotalElements());
assertEquals(1, roleSystemService.find(roleSystemFilter, null).getTotalElements());
assertNotNull(roleSystemAttributeService.get(roleSystemAttribute.getId()));
systemService.delete(system);
assertNull(systemService.getByCode(systemName));
assertEquals(0, schemaObjectClassService.find(objectClassFilter, null).getTotalElements());
assertEquals(0, schemaAttributeService.find(schemaAttributeFilter, null).getTotalElements());
assertEquals(0, systemMappingService.find(entityHandlingFilter, null).getTotalElements());
assertEquals(0, systemAttributeMappingService.find(schemaAttributeHandlingFilter, null).getTotalElements());
assertEquals(0, roleSystemService.find(roleSystemFilter, null).getTotalElements());
assertNull(roleSystemAttributeService.get(roleSystemAttribute.getId()));
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class DefaultUniformPasswordManagerIntegrationTest method initData.
private SysSystemDto initData() {
// create test system
SysSystemDto system = helper.createSystem(TestContractResource.TABLE_NAME, null, null, "ID");
Assert.assertNotNull(system);
// generate schema for system
List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
// Create synchronization mapping
SysSystemMappingDto syncSystemMapping = new SysSystemMappingDto();
syncSystemMapping.setName("default_" + System.currentTimeMillis());
syncSystemMapping.setEntityType(SystemEntityType.CONTRACT);
syncSystemMapping.setOperationType(SystemOperationType.SYNCHRONIZATION);
syncSystemMapping.setObjectClass(objectClasses.get(0).getId());
final SysSystemMappingDto syncMapping = systemMappingService.save(syncSystemMapping);
createMapping(system, syncMapping);
return system;
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingServiceFilterTest method testFilterBySendOnPasswordChange.
@Test
public void testFilterBySendOnPasswordChange() {
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());
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSystemId(system.getId());
List<SysSystemAttributeMappingDto> attributeMappings = systemAttributeMappingService.find(filter, null).getContent();
// Six is default for standard test resource
assertEquals(6, attributeMappings.size());
filter.setPasswordAttribute(Boolean.TRUE);
attributeMappings = systemAttributeMappingService.find(filter, null).getContent();
assertEquals(1, attributeMappings.size());
SysSystemAttributeMappingDto attributeMappingDto = attributeMappings.get(0);
assertEquals(TestHelper.ATTRIBUTE_MAPPING_PASSWORD, attributeMappingDto.getName());
assertTrue(attributeMappingDto.isPasswordAttribute());
filter.setPasswordAttribute(Boolean.FALSE);
attributeMappings = systemAttributeMappingService.find(filter, null).getContent();
// Withotu password
assertEquals(5, attributeMappings.size());
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingServiceFilterTest method testFilterBySystemMapping.
@Test
public void testFilterBySystemMapping() {
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);
SysSystemAttributeMappingFilter filterAttributeMapping = new SysSystemAttributeMappingFilter();
filterAttributeMapping.setSystemMappingId(mappingDto.getId());
List<SysSystemAttributeMappingDto> attributeMappings = systemAttributeMappingService.find(filterAttributeMapping, null).getContent();
// Six is default for standard test resource
assertEquals(6, attributeMappings.size());
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto 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());
}
Aggregations