use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class DefaultRoleSynchronizationServiceTest method provisioningB_CreateAccounts.
@Test
public void provisioningB_CreateAccounts() {
IdmRoleFilter filter = new IdmRoleFilter();
filter.setProperty(IdmRole_.name.getName());
filter.setValue(ROLE_NAME_TEN);
IdmRoleDto roleTen = roleService.find(filter, null).getContent().get(0);
Assert.assertNotNull(roleTen);
// Check state before provisioning
TestRoleResource ten = entityManager.find(TestRoleResource.class, ROLE_NAME_TEN);
Assert.assertNull(ten);
// Create mapping for provisioning
this.createProvisionigMapping();
// Save IDM role (must invoke provisioning)
roleService.save(roleTen);
// Check state before provisioning
ten = entityManager.find(TestRoleResource.class, ROLE_NAME_TEN);
Assert.assertNotNull(ten);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedDiffPriorityTest.
@Test
@Transactional
public void compileAttributesOverrloadedDiffPriorityTest() {
List<SysRoleSystemAttributeDto> overloadingAttributes = new ArrayList<>();
List<AttributeMapping> defaultAttributes = new ArrayList<>();
initDataSystem();
initOverloadedAttributes(overloadingAttributes, defaultAttributes);
// roleOne
SysRoleSystemDto roleSystem1 = roleSystemService.get(overloadingAttributes.get(0).getRoleSystem());
IdmRoleDto roleDto = roleService.get(roleSystem1.getRole());
roleDto.setPriority(200);
roleDto = roleService.save(roleDto);
// roleTwo
SysRoleSystemDto roleSystem2 = roleSystemService.get(overloadingAttributes.get(1).getRoleSystem());
roleDto = roleService.get(roleSystem2.getRole());
roleDto.setPriority(100);
roleDto = roleService.save(roleDto);
List<AttributeMapping> compilledAttributes = provisioningService.compileAttributes(defaultAttributes, overloadingAttributes, SystemEntityType.IDENTITY);
Assert.assertEquals(2, compilledAttributes.size());
Assert.assertTrue(compilledAttributes.stream().filter(attribute -> {
return "defOneOverloaded".equals(attribute.getName());
}).findFirst().isPresent());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedDisabledTest.
@Test
@Transactional
public void compileAttributesOverrloadedDisabledTest() {
List<AttributeMapping> defaultAttributes = new ArrayList<>();
List<SysRoleSystemAttributeDto> overloadingAttributes = new ArrayList<>();
initDataSystem();
SysSchemaAttributeDto attOne = new SysSchemaAttributeDto();
attOne.setName("attOne");
attOne.setObjectClass(objectClasses.get(0).getId());
attOne.setClassType(String.class.getName());
attOne = schemaAttributeService.save(attOne);
SysSchemaAttributeDto attTwo = new SysSchemaAttributeDto();
attTwo.setName("attTwo");
attTwo.setObjectClass(objectClasses.get(0).getId());
attTwo.setClassType(String.class.getName());
attTwo = schemaAttributeService.save(attTwo);
SysSystemAttributeMappingDto defOne = new SysSystemAttributeMappingDto();
defOne.setEntityAttribute(true);
defOne.setIdmPropertyName("one");
defOne.setName("defOne");
defOne.setDisabledAttribute(true);
defOne.setSchemaAttribute(attOne.getId());
defOne.setSystemMapping(systemMapping.getId());
defOne = systemAttributeMappingService.save(defOne);
defaultAttributes.add(defOne);
SysSystemAttributeMappingDto defTwo = new SysSystemAttributeMappingDto();
defTwo.setEntityAttribute(true);
defTwo.setIdmPropertyName("two");
defTwo.setName("defTwo");
defTwo.setSchemaAttribute(attTwo.getId());
defTwo.setSystemMapping(systemMapping.getId());
defTwo = systemAttributeMappingService.save(defTwo);
defaultAttributes.add(defTwo);
IdmRoleDto roleOne = new IdmRoleDto();
roleOne.setName("roleOne");
roleOne.setPriority(100);
roleOne = roleService.save(roleOne);
SysRoleSystemDto roleSystem = new SysRoleSystemDto();
roleSystem.setRole(roleOne.getId());
roleSystem.setSystem(system.getId());
roleSystem.setSystemMapping(systemMapping.getId());
roleSystem = roleSystemService.save(roleSystem);
SysRoleSystemAttributeDto overloadedOne = new SysRoleSystemAttributeDto();
overloadedOne.setSystemAttributeMapping(defOne.getId());
overloadedOne.setEntityAttribute(true);
overloadedOne.setIdmPropertyName("one");
overloadedOne.setName("defOneOverloaded");
overloadedOne.setDisabledDefaultAttribute(false);
overloadedOne.setRoleSystem(roleSystem.getId());
overloadedOne = roleSystemAttributeService.save(overloadedOne);
overloadingAttributes.add(overloadedOne);
List<AttributeMapping> compilledAttributes = provisioningService.compileAttributes(defaultAttributes, overloadingAttributes, SystemEntityType.IDENTITY);
Assert.assertEquals(2, compilledAttributes.size());
Assert.assertTrue(compilledAttributes.stream().filter(attribute -> {
return "defOneOverloaded".equals(attribute.getName());
}).findFirst().isPresent());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedConflictStrategies.
@Test(expected = ProvisioningException.class)
@Transactional
public void compileAttributesOverrloadedConflictStrategies() {
List<SysRoleSystemAttributeDto> overloadingAttributes = new ArrayList<>();
List<AttributeMapping> defaultAttributes = new ArrayList<>();
initDataSystem();
initOverloadedAttributes(overloadingAttributes, defaultAttributes);
// roleOne
SysRoleSystemDto roleSystem1 = roleSystemService.get(overloadingAttributes.get(0).getRoleSystem());
IdmRoleDto roleDto = roleService.get(roleSystem1.getRole());
roleDto.setPriority(200);
roleDto = roleService.save(roleDto);
// roleTwo
SysRoleSystemDto roleSystem2 = roleSystemService.get(overloadingAttributes.get(1).getRoleSystem());
roleDto = roleService.get(roleSystem2.getRole());
roleDto.setPriority(500);
roleDto = roleService.save(roleDto);
// overloadedRoleOne
SysRoleSystemAttributeDto roleSystemAttribute1 = overloadingAttributes.get(0);
roleSystemAttribute1.setStrategyType(AttributeMappingStrategyType.SET);
roleSystemAttribute1 = roleSystemAttributeService.save(roleSystemAttribute1);
overloadingAttributes.set(0, roleSystemAttribute1);
// overloadedRoleTwo
SysRoleSystemAttributeDto roleSystemAttribute2 = overloadingAttributes.get(1);
roleSystemAttribute2.setStrategyType(AttributeMappingStrategyType.AUTHORITATIVE_MERGE);
roleSystemAttribute2 = roleSystemAttributeService.save(roleSystemAttribute2);
overloadingAttributes.set(1, roleSystemAttribute2);
provisioningService.compileAttributes(defaultAttributes, overloadingAttributes, SystemEntityType.IDENTITY);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method testPasswordChangeWithAdditionalAttributesInTwoOperations.
@Test
public void testPasswordChangeWithAdditionalAttributesInTwoOperations() {
configurationService.setBooleanValue(ProvisioningConfiguration.PROPERTY_SEND_PASSWORD_ATTRIBUTES_TOGETHER, false);
try {
Assert.assertFalse(provisioningConfiguration.isSendPasswordAttributesTogether());
// prepare account on target system
SysSystemDto system = helper.createTestResourceSystem(true);
SysSystemMappingDto systemMapping = helper.getDefaultMapping(system);
SysSystemAttributeMappingDto firtstNameAttribute = systemAttributeMappingService.findBySystemMappingAndName(systemMapping.getId(), TestHelper.ATTRIBUTE_MAPPING_FIRSTNAME);
firtstNameAttribute.setSendOnPasswordChange(Boolean.TRUE);
systemAttributeMappingService.save(firtstNameAttribute);
IdmRoleDto role = helper.createRole();
helper.createRoleSystem(role, system);
IdmIdentityDto identity = helper.createIdentity();
helper.createIdentityRole(identity, role);
//
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
AccAccountDto account = accountService.get(accountIdentityOne.getAccount());
// Create new password one
PasswordChangeDto passwordChange = new PasswordChangeDto();
passwordChange.setAccounts(ImmutableList.of(account.getId().toString()));
passwordChange.setNewPassword(new GuardedString(IDENTITY_PASSWORD_ONE));
passwordChange.setIdm(true);
//
// Do change of password for selected accounts
String firstNameChange = "firstname-change";
identity.setFirstName(firstNameChange);
idmIdentityService.passwordChange(identity, passwordChange);
//
// Check correct password One
TestResource resource = helper.findResource(account.getRealUid());
Assert.assertNotNull(resource);
Assert.assertEquals(IDENTITY_PASSWORD_ONE, resource.getPassword());
Assert.assertEquals(firstNameChange, resource.getFirstname());
} finally {
configurationService.setBooleanValue(ProvisioningConfiguration.PROPERTY_SEND_PASSWORD_ATTRIBUTES_TOGETHER, true);
Assert.assertTrue(provisioningConfiguration.isSendPasswordAttributesTogether());
}
}
Aggregations