use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedStrategyMergeAuthoDisableTest.
@Test
@Transactional
public void compileAttributesOverrloadedStrategyMergeAuthoDisableTest() {
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 attribute1 = overloadingAttributes.get(0);
attribute1.setStrategyType(AttributeMappingStrategyType.AUTHORITATIVE_MERGE);
attribute1 = roleSystemAttributeService.save(attribute1);
overloadingAttributes.set(0, attribute1);
// overloadedRoleTwo
SysRoleSystemAttributeDto attribute2 = overloadingAttributes.get(1);
attribute2.setStrategyType(AttributeMappingStrategyType.AUTHORITATIVE_MERGE);
attribute2.setDisabledDefaultAttribute(true);
attribute2 = roleSystemAttributeService.save(attribute2);
overloadingAttributes.set(1, attribute2);
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 testPasswordChangeWithoutAdditionalAttributes.
@Test
public void testPasswordChangeWithoutAdditionalAttributes() {
// prepare account on target system
SysSystemDto system = helper.createTestResourceSystem(true);
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 previousFirtsName = identity.getFirstName();
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(previousFirtsName, resource.getFirstname());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method testPasswordChangeWithAdditionalAttributesInOneOperation.
@Test
public void testPasswordChangeWithAdditionalAttributesInOneOperation() {
Assert.assertTrue(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());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedStrategyCreateTest.
@Test
@Transactional
public void compileAttributesOverrloadedStrategyCreateTest() {
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 attribute1 = overloadingAttributes.get(0);
attribute1.setStrategyType(AttributeMappingStrategyType.CREATE);
attribute1 = roleSystemAttributeService.save(attribute1);
overloadingAttributes.set(0, attribute1);
// overloadedRoleTwo
SysRoleSystemAttributeDto attribute2 = overloadingAttributes.get(1);
attribute2.setStrategyType(AttributeMappingStrategyType.CREATE);
attribute2 = roleSystemAttributeService.save(attribute2);
overloadingAttributes.set(1, attribute2);
List<AttributeMapping> compilledAttributes = provisioningService.compileAttributes(defaultAttributes, overloadingAttributes, SystemEntityType.IDENTITY);
Assert.assertEquals(2, compilledAttributes.size());
Assert.assertTrue(compilledAttributes.stream().filter(attribute -> {
return "defOneOverloadedRoleTwo".equals(attribute.getName());
}).findFirst().isPresent());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedStrategyMergeWithDuplTest.
@Test
public void compileAttributesOverrloadedStrategyMergeWithDuplTest() {
String sameValue = "sameValue-" + System.currentTimeMillis();
String eavAttribute = "EAV_ATTRIBUTE";
IdmRoleDto role1 = helper.createRole();
IdmRoleDto role2 = helper.createRole();
IdmIdentityDto identity = helper.createIdentity();
helper.createIdentityRole(identity, role1);
helper.createIdentityRole(identity, role2);
SysSystemDto system = helper.createTestResourceSystem(true);
systemService.generateSchema(system);
SysSchemaAttributeFilter schemaAttFilter = new SysSchemaAttributeFilter();
schemaAttFilter.setSystemId(system.getId());
schemaAttFilter.setName(eavAttribute);
List<SysSchemaAttributeDto> schemaAttrs = schemaAttributeService.find(schemaAttFilter, null).getContent();
assertEquals(1, schemaAttrs.size());
SysSchemaAttributeDto schemaAttributeDto = schemaAttrs.get(0);
schemaAttributeDto.setMultivalued(true);
schemaAttributeDto = schemaAttributeService.save(schemaAttributeDto);
SysSystemMappingDto systemMapping = helper.getDefaultMapping(system);
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
schemaAttributeFilter.setName(eavAttribute);
List<SysSchemaAttributeDto> atts = schemaAttributeService.find(schemaAttributeFilter, null).getContent();
assertEquals(1, atts.size());
SysSchemaAttributeDto sysSchemaAttributeEav = atts.get(0);
// create eav attribute with merge
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setExtendedAttribute(true);
attributeMapping.setName(eavAttribute);
attributeMapping.setIdmPropertyName(eavAttribute);
attributeMapping.setStrategyType(AttributeMappingStrategyType.MERGE);
attributeMapping.setSchemaAttribute(sysSchemaAttributeEav.getId());
attributeMapping.setSystemMapping(systemMapping.getId());
attributeMapping = systemAttributeMappingService.save(attributeMapping);
SysRoleSystemDto roleSystem1 = helper.createRoleSystem(role1, system);
SysRoleSystemDto roleSystem2 = helper.createRoleSystem(role2, system);
SysRoleSystemAttributeDto overloadedRoleOne = new SysRoleSystemAttributeDto();
overloadedRoleOne.setSystemAttributeMapping(attributeMapping.getId());
overloadedRoleOne.setEntityAttribute(false);
overloadedRoleOne.setExtendedAttribute(true);
overloadedRoleOne.setStrategyType(AttributeMappingStrategyType.MERGE);
overloadedRoleOne.setName(attributeMapping.getName());
overloadedRoleOne.setDisabledDefaultAttribute(false);
overloadedRoleOne.setIdmPropertyName(eavAttribute);
overloadedRoleOne.setRoleSystem(roleSystem1.getId());
overloadedRoleOne.setTransformToResourceScript("return '" + sameValue + "';");
overloadedRoleOne = roleSystemAttributeService.save(overloadedRoleOne);
SysRoleSystemAttributeDto overloadedRoleTwo = new SysRoleSystemAttributeDto();
overloadedRoleTwo.setSystemAttributeMapping(attributeMapping.getId());
overloadedRoleTwo.setEntityAttribute(false);
overloadedRoleTwo.setExtendedAttribute(true);
overloadedRoleTwo.setStrategyType(AttributeMappingStrategyType.MERGE);
overloadedRoleTwo.setName(attributeMapping.getName());
overloadedRoleTwo.setDisabledDefaultAttribute(false);
overloadedRoleTwo.setIdmPropertyName(eavAttribute);
overloadedRoleTwo.setRoleSystem(roleSystem2.getId());
overloadedRoleTwo.setTransformToResourceScript("return '" + sameValue + "';");
overloadedRoleTwo = roleSystemAttributeService.save(overloadedRoleTwo);
provisioningService.accountManagement(identity);
provisioningService.doProvisioning(identity);
List<AccAccountDto> accounts = accountService.getAccounts(system.getId(), identity.getId());
assertEquals(1, accounts.size());
SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
filter.setSystemId(system.getId());
List<SysProvisioningArchiveDto> archives = porvisioningArchiveService.find(filter, null).getContent();
assertEquals(1, archives.size());
SysProvisioningArchiveDto archive = archives.get(0);
assertEquals(OperationState.EXECUTED, archive.getResultState());
ProvisioningContext provisioningContext = archive.getProvisioningContext();
Object values = null;
for (ProvisioningAttributeDto key : provisioningContext.getAccountObject().keySet()) {
if (key.getSchemaAttributeName().equals(eavAttribute)) {
values = provisioningContext.getAccountObject().get(key);
break;
}
}
assertNotNull(values);
if (values instanceof ArrayList<?>) {
ArrayList<?> colleaction = (ArrayList<?>) values;
assertEquals(1, colleaction.size());
Object object = colleaction.get(0);
assertEquals(sameValue, object);
} else {
fail();
}
}
Aggregations