Search in sources :

Example 86 with SysRoleSystemDto

use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedSamePriorityTest.

@Test
@Transactional
public void compileAttributesOverrloadedSamePriorityTest() {
    List<SysRoleSystemAttributeDto> overloadingAttributes = new ArrayList<>();
    List<AttributeMapping> defaultAttributes = new ArrayList<>();
    initDataSystem();
    initOverloadedAttributes(overloadingAttributes, defaultAttributes);
    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());
    // set name role One to zroleOne
    SysRoleSystemDto roleSystem = roleSystemService.get(overloadingAttributes.get(0).getRoleSystem());
    IdmRoleDto roleDto = roleService.get(roleSystem.getRole());
    roleDto.setCode("zroleOne");
    roleDto = roleService.save(roleDto);
    roleSystem = roleSystemService.save(roleSystem);
    List<SysRoleSystemAttributeDto> freshOverloadingAttributes = new ArrayList<>();
    overloadingAttributes.forEach(attributeOver -> {
        freshOverloadingAttributes.add(roleSystemAttributeService.get(attributeOver.getId()));
    });
    compilledAttributes = provisioningService.compileAttributes(defaultAttributes, freshOverloadingAttributes, SystemEntityType.IDENTITY);
    Assert.assertEquals(2, compilledAttributes.size());
    Assert.assertTrue(compilledAttributes.stream().filter(attribute -> {
        return "defOneOverloaded".equals(attribute.getName());
    }).findFirst().isPresent());
    // We set role mapping attribute to disabled, then must have higher
    // "priority", then role mapping one
    // and must missing in result
    SysRoleSystemAttributeDto attribute = overloadingAttributes.get(1);
    attribute.setDisabledDefaultAttribute(true);
    attribute = roleSystemAttributeService.save(attribute);
    overloadingAttributes.set(1, attribute);
    List<SysRoleSystemAttributeDto> freshOverloadingAttributesTwo = new ArrayList<>();
    overloadingAttributes.forEach(attributeOver -> {
        freshOverloadingAttributes.add(roleSystemAttributeService.get(attributeOver.getId()));
    });
    compilledAttributes = provisioningService.compileAttributes(defaultAttributes, freshOverloadingAttributesTwo, SystemEntityType.IDENTITY);
    Assert.assertEquals(1, compilledAttributes.size());
}
Also used : MethodSorters(org.junit.runners.MethodSorters) IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) AccIdentityAccount_(eu.bcvsolutions.idm.acc.entity.AccIdentityAccount_) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) SysRoleSystemService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemService) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) After(org.junit.After) ProvisioningConfiguration(eu.bcvsolutions.idm.acc.config.domain.ProvisioningConfiguration) Assert.fail(org.junit.Assert.fail) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) IdmIdentityContractService(eu.bcvsolutions.idm.core.api.service.IdmIdentityContractService) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SystemOperationType(eu.bcvsolutions.idm.acc.domain.SystemOperationType) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) Page(org.springframework.data.domain.Page) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) List(java.util.List) AccAccountService(eu.bcvsolutions.idm.acc.service.api.AccAccountService) AccountType(eu.bcvsolutions.idm.acc.domain.AccountType) AccIdentityAccountService(eu.bcvsolutions.idm.acc.service.api.AccIdentityAccountService) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) FixMethodOrder(org.junit.FixMethodOrder) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmTreeNodeService(eu.bcvsolutions.idm.core.api.service.IdmTreeNodeService) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) SystemEvent(eu.bcvsolutions.idm.acc.event.SystemEvent) AttributeMappingStrategyType(eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType) SystemEventType(eu.bcvsolutions.idm.acc.event.SystemEvent.SystemEventType) SysSystemEntityService(eu.bcvsolutions.idm.acc.service.api.SysSystemEntityService) IdmAccountDto(eu.bcvsolutions.idm.core.api.dto.IdmAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ArrayList(java.util.ArrayList) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) IdmPasswordPolicyGenerateType(eu.bcvsolutions.idm.core.api.domain.IdmPasswordPolicyGenerateType) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) ImmutableList(com.google.common.collect.ImmutableList) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) ProvisioningOperationType(eu.bcvsolutions.idm.acc.domain.ProvisioningOperationType) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) Before(org.junit.Before) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) SysRoleSystemAttributeService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemAttributeService) SysProvisioningArchiveService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningArchiveService) IdmPasswordPolicyType(eu.bcvsolutions.idm.core.api.domain.IdmPasswordPolicyType) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) Assert.assertNotNull(org.junit.Assert.assertNotNull) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) IdmTreeTypeService(eu.bcvsolutions.idm.core.api.service.IdmTreeTypeService) Test(org.junit.Test) EntityManager(javax.persistence.EntityManager) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) Assert.assertNull(org.junit.Assert.assertNull) AccAccount_(eu.bcvsolutions.idm.acc.entity.AccAccount_) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) ProvisioningService(eu.bcvsolutions.idm.acc.service.api.ProvisioningService) IdmIdentity_(eu.bcvsolutions.idm.core.model.entity.IdmIdentity_) TestHelper(eu.bcvsolutions.idm.acc.TestHelper) Assert(org.junit.Assert) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) Assert.assertEquals(org.junit.Assert.assertEquals) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) Transactional(org.springframework.transaction.annotation.Transactional) IdmPasswordPolicyService(eu.bcvsolutions.idm.core.api.service.IdmPasswordPolicyService) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) ArrayList(java.util.ArrayList) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 87 with SysRoleSystemDto

use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.

the class DefaultSysRoleSystemAttributeServiceTest method testArchiveControledValuesAfterRoleIsDeleted.

@Test
public void testArchiveControledValuesAfterRoleIsDeleted() {
    // prepare mapped attribute with controled value
    IdmRoleDto role = helper.createRole();
    SysSystemDto system = helper.createTestResourceSystem(true);
    systemService.generateSchema(system);
    // 
    // create eav attribute
    String attributeName = helper.getSchemaColumnName("EAV_ATTRIBUTE");
    SysSchemaAttributeFilter schemaAttFilter = new SysSchemaAttributeFilter();
    schemaAttFilter.setSystemId(system.getId());
    schemaAttFilter.setName(attributeName);
    List<SysSchemaAttributeDto> schemaAttrs = schemaAttributeService.find(schemaAttFilter, null).getContent();
    Assert.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(attributeName);
    List<SysSchemaAttributeDto> atts = schemaAttributeService.find(schemaAttributeFilter, null).getContent();
    Assert.assertEquals(1, atts.size());
    SysSchemaAttributeDto sysSchemaAttributeEav = atts.get(0);
    // 
    // create eav attribute mapping with merge
    SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
    attributeMapping.setExtendedAttribute(true);
    attributeMapping.setName(attributeName);
    attributeMapping.setIdmPropertyName(attributeName);
    attributeMapping.setStrategyType(AttributeMappingStrategyType.MERGE);
    attributeMapping.setSchemaAttribute(sysSchemaAttributeEav.getId());
    attributeMapping.setSystemMapping(systemMapping.getId());
    attributeMapping = systemAttributeMappingService.save(attributeMapping);
    // 
    // role system mapping with merge value
    SysRoleSystemDto roleSystem = helper.createRoleSystem(role, 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(attributeName);
    overloadedRoleOne.setRoleSystem(roleSystem.getId());
    String valueOne = helper.createName();
    overloadedRoleOne.setTransformToResourceScript("return '" + valueOne + "';");
    overloadedRoleOne = roleSystemAttributeService.save(overloadedRoleOne);
    // 
    // assign role to identity
    IdmIdentityDto identity = helper.createIdentity();
    attributeMapping = systemAttributeMappingService.get(attributeMapping.getId());
    Assert.assertTrue(attributeMapping.isEvictControlledValuesCache());
    IdmRoleRequestDto request = helper.createRoleRequest(identity, role);
    request = helper.executeRequest(request, false, true);
    UUID identityRoleId = request.getConceptRoles().get(0).getIdentityRole();
    IdmIdentityRoleDto identityRole = identityRoleService.get(identityRoleId);
    List<AccAccountDto> accounts = accountService.getAccounts(system.getId(), identity.getId());
    Assert.assertEquals(1, accounts.size());
    // Account was created, provisioning was finished, but attribute was still not
    // recalculated, because provisioning for create of account doesn't need a
    // controlled values, so attribute is not recalculated now.
    attributeMapping = systemAttributeMappingService.get(attributeMapping.getId());
    Assert.assertTrue(attributeMapping.isEvictControlledValuesCache());
    // Execute update provisioning -> executes recalculation of the attribute
    identityService.save(identity);
    attributeMapping = systemAttributeMappingService.get(attributeMapping.getId());
    Assert.assertFalse(attributeMapping.isEvictControlledValuesCache());
    // 
    // find controlled values
    SysAttributeControlledValueFilter valueFilter = new SysAttributeControlledValueFilter();
    valueFilter.setAttributeMappingId(attributeMapping.getId());
    List<SysAttributeControlledValueDto> controlledValues = attributeControlledValueService.find(valueFilter, null).getContent();
    Assert.assertEquals(1, controlledValues.size());
    Assert.assertEquals(valueOne, controlledValues.get(0).getValue());
    // try to delete role => role is still assigned
    try {
        roleService.delete(role);
    } catch (ResultCodeException ex) {
        Assert.assertEquals(CoreResultCode.ROLE_DELETE_FAILED_IDENTITY_ASSIGNED.getCode(), ((ResultCodeException) ex).getError().getError().getStatusEnum());
    }
    // 
    controlledValues = attributeControlledValueService.find(valueFilter, null).getContent();
    Assert.assertEquals(1, controlledValues.size());
    Assert.assertEquals(valueOne, controlledValues.get(0).getValue());
    Assert.assertTrue(controlledValues.stream().allMatch(v -> !v.isHistoricValue()));
    // 
    // remove assigned role and remove role with controller values
    identityRoleService.delete(identityRole);
    roleService.delete(role);
    attributeMapping = systemAttributeMappingService.get(attributeMapping.getId());
    Assert.assertTrue(attributeMapping.isEvictControlledValuesCache());
    // Manual recalculation of the attribute
    systemAttributeMappingService.recalculateAttributeControlledValues(system.getId(), SystemEntityType.IDENTITY, attributeName, attributeMapping);
    // Attribute must be recalculated now
    attributeMapping = systemAttributeMappingService.get(attributeMapping.getId());
    Assert.assertFalse(attributeMapping.isEvictControlledValuesCache());
    // 
    controlledValues = attributeControlledValueService.find(valueFilter, null).getContent();
    Assert.assertEquals(1, controlledValues.size());
    Assert.assertEquals(valueOne, controlledValues.get(0).getValue());
    Assert.assertTrue(controlledValues.stream().allMatch(v -> v.isHistoricValue()));
    // 
    // delete system (referential integrity just for sure)
    systemService.delete(system);
    controlledValues = attributeControlledValueService.find(valueFilter, null).getContent();
    Assert.assertTrue(controlledValues.isEmpty());
}
Also used : AttributeMappingStrategyType(eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) Autowired(org.springframework.beans.factory.annotation.Autowired) SysAttributeControlledValueDto(eu.bcvsolutions.idm.acc.dto.SysAttributeControlledValueDto) SysAttributeControlledValueFilter(eu.bcvsolutions.idm.acc.dto.filter.SysAttributeControlledValueFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysRoleSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter) IcObjectClassInfo(eu.bcvsolutions.idm.ic.api.IcObjectClassInfo) SysRoleSystemService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemService) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) SysRoleSystemAttributeService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemAttributeService) IdmIdentityRoleService(eu.bcvsolutions.idm.core.api.service.IdmIdentityRoleService) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysAttributeControlledValueService(eu.bcvsolutions.idm.acc.service.api.SysAttributeControlledValueService) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) SystemOperationType(eu.bcvsolutions.idm.acc.domain.SystemOperationType) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) Test(org.junit.Test) UUID(java.util.UUID) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) List(java.util.List) AccAccountService(eu.bcvsolutions.idm.acc.service.api.AccAccountService) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) TestHelper(eu.bcvsolutions.idm.acc.TestHelper) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) Assert(org.junit.Assert) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) SysAttributeControlledValueDto(eu.bcvsolutions.idm.acc.dto.SysAttributeControlledValueDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysAttributeControlledValueFilter(eu.bcvsolutions.idm.acc.dto.filter.SysAttributeControlledValueFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 88 with SysRoleSystemDto

use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.

the class DefaultSysRoleSystemAttributeServiceTest method testAddRoleMappingAttribute.

@Test
public void testAddRoleMappingAttribute() {
    IdmRoleDto role = helper.createRole();
    SysSystemDto system = helper.createTestResourceSystem(true);
    SysRoleSystemAttributeDto attribute = roleSystemAttributeService.addRoleMappingAttribute(system.getId(), role.getId(), helper.getSchemaColumnName(TestHelper.ATTRIBUTE_MAPPING_FIRSTNAME), null, IcObjectClassInfo.ACCOUNT);
    Assert.assertNotNull(attribute);
    SysRoleSystemFilter roleSystemFilter = new SysRoleSystemFilter();
    roleSystemFilter.setRoleId(role.getId());
    roleSystemFilter.setSystemId(system.getId());
    List<SysRoleSystemDto> roleSystems = roleSystemService.find(roleSystemFilter, null).getContent();
    Assert.assertEquals(1, roleSystems.size());
    SysRoleSystemDto roleSystem = roleSystems.get(0);
    SysSystemMappingDto systemMapping = roleSystemAttributeService.getSystemMapping(system.getId(), IcObjectClassInfo.ACCOUNT, SystemOperationType.PROVISIONING);
    Assert.assertNotNull(systemMapping);
    Assert.assertEquals(systemMapping.getId(), roleSystem.getSystemMapping());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysRoleSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 89 with SysRoleSystemDto

use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.

the class DefaultSysRoleSystemServiceFilterTest method testSystemIdFilter.

@Test
public void testSystemIdFilter() {
    IdmRoleDto role1 = helper.createRole();
    IdmRoleDto role2 = helper.createRole();
    SysSystemDto system1 = helper.createTestResourceSystem(true);
    SysSystemDto system2 = helper.createTestResourceSystem(true);
    // 
    SysSystemMappingDto sysSystemMapping1Dto = mappingService.findBySystemId(system1.getId(), SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY).get(0);
    SysSystemMappingDto sysSystemMapping2Dto = mappingService.findBySystemId(system2.getId(), SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY).get(0);
    createRoleSystem(role1.getId(), system1.getId(), sysSystemMapping1Dto.getId());
    SysRoleSystemDto roleSystem2 = createRoleSystem(role2.getId(), system2.getId(), sysSystemMapping2Dto.getId());
    // 
    SysRoleSystemFilter roleFilter = new SysRoleSystemFilter();
    roleFilter.setSystemId(system2.getId());
    Page<SysRoleSystemDto> pages = roleSystemService.find(roleFilter, null);
    // 
    assertEquals(1, pages.getTotalElements());
    assertEquals(roleSystem2.getId(), pages.getContent().get(0).getId());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysRoleSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 90 with SysRoleSystemDto

use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.

the class DefaultSysRoleSystemServiceFilterTest method createRoleSystem.

/**
 * Create {@link SysRoleSystemDto}
 *
 * @param roleId
 * @param systemId
 * @param systemMappingId
 * @return
 */
private SysRoleSystemDto createRoleSystem(UUID roleId, UUID systemId, UUID systemMappingId) {
    helper.createRole();
    SysRoleSystemDto role = new SysRoleSystemDto();
    role.setRole(roleId);
    role.setSystem(systemId);
    role.setSystemMapping(systemMappingId);
    return roleSystemService.save(role);
}
Also used : SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)

Aggregations

SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)110 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)82 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)80 Test (org.junit.Test)69 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)65 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)64 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)61 SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)59 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)50 SysRoleSystemFilter (eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter)48 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)43 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)40 UUID (java.util.UUID)35 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)34 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)33 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)27 SysProvisioningOperationFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter)27 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)26 List (java.util.List)26 SysRoleSystemAttributeService (eu.bcvsolutions.idm.acc.service.api.SysRoleSystemAttributeService)25