Search in sources :

Example 11 with SysSchemaAttributeDto

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

the class ProvisioningMergeTest method testSkipMergeValueIfContractExcluded.

@Test
public void testSkipMergeValueIfContractExcluded() {
    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);
    SysSchemaAttributeDto rightsSchemaAttribute = new SysSchemaAttributeDto();
    rightsSchemaAttribute.setObjectClass(mapping.getObjectClass());
    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.setEntityAttribute(false);
    roleAttributeOne.setExtendedAttribute(false);
    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.setEntityAttribute(false);
    roleAttributeTwo.setExtendedAttribute(false);
    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());
    IdmIdentityDto identity = this.getHelper().createIdentity();
    IdmIdentityContractDto contract = this.getHelper().getPrimeContract(identity);
    // Set contract as excluded
    contract.setState(ContractState.EXCLUDED);
    contract = identityContractService.save(contract);
    assertTrue(contract.isExcluded());
    this.getHelper().createIdentityRole(identity, roleOne);
    this.getHelper().createIdentityRole(identity, roleTwo);
    SysProvisioningOperationFilter operationFilter = new SysProvisioningOperationFilter();
    operationFilter.setEntityIdentifier(identity.getId());
    List<SysProvisioningArchiveDto> archives = provisioningArchiveService.find(operationFilter, PageRequest.of(0, 1, new Sort(Direction.DESC, AbstractEntity_.created.getName()))).getContent();
    assertEquals(1, archives.size());
    SysProvisioningArchiveDto archive = archives.get(0);
    assertEquals(ProvisioningEventType.UPDATE, archive.getOperationType());
    ProvisioningContext provisioningContext = archive.getProvisioningContext();
    Map<ProvisioningAttributeDto, Object> accountObject = provisioningContext.getAccountObject();
    Entry<ProvisioningAttributeDto, Object> attributeEntry = accountObject.entrySet().stream().filter(entry -> RIGHTS_ATTRIBUTE.equals(entry.getKey().getSchemaAttributeName())).findFirst().get();
    List<?> values = (List<?>) attributeEntry.getValue();
    assertEquals(2, values.size());
    // Set attribute TWO to skip value if contract is excluded
    roleAttributeTwo.setSkipValueIfExcluded(true);
    roleAttributeTwo = roleSystemAttributeService.saveInternal(roleAttributeTwo);
    // Save identity -> execute provisioning
    identityService.save(identity);
    archives = provisioningArchiveService.find(operationFilter, PageRequest.of(0, 1, new Sort(Direction.DESC, AbstractEntity_.created.getName()))).getContent();
    assertEquals(1, archives.size());
    archive = archives.get(0);
    assertEquals(ProvisioningEventType.UPDATE, archive.getOperationType());
    provisioningContext = archive.getProvisioningContext();
    accountObject = provisioningContext.getAccountObject();
    attributeEntry = // 
    accountObject.entrySet().stream().filter(// 
    entry -> RIGHTS_ATTRIBUTE.equals(entry.getKey().getSchemaAttributeName())).findFirst().get();
    values = (List<?>) attributeEntry.getValue();
    assertEquals(1, values.size());
    assertEquals(ONE_VALUE, values.get(0));
    // Set contract as not excluded
    contract.setState(null);
    contract = identityContractService.save(contract);
    assertFalse(contract.isExcluded());
    // Save identity -> execute provisioning
    identityService.save(identity);
    archives = provisioningArchiveService.find(operationFilter, PageRequest.of(0, 1, new Sort(Direction.DESC, AbstractEntity_.created.getName()))).getContent();
    assertEquals(1, archives.size());
    archive = archives.get(0);
    assertEquals(ProvisioningEventType.UPDATE, archive.getOperationType());
    provisioningContext = archive.getProvisioningContext();
    accountObject = provisioningContext.getAccountObject();
    attributeEntry = // 
    accountObject.entrySet().stream().filter(// 
    entry -> RIGHTS_ATTRIBUTE.equals(entry.getKey().getSchemaAttributeName())).findFirst().get();
    values = (List<?>) attributeEntry.getValue();
    assertEquals(2, values.size());
}
Also used : AttributeMappingStrategyType(eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) ProvisioningEventType(eu.bcvsolutions.idm.acc.domain.ProvisioningEventType) 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) SysRoleSystemService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemService) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) Map(java.util.Map) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Sort(org.springframework.data.domain.Sort) Direction(org.springframework.data.domain.Sort.Direction) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) SysRoleSystemAttributeService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemAttributeService) SysProvisioningArchiveService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningArchiveService) AbstractEntity_(eu.bcvsolutions.idm.core.api.entity.AbstractEntity_) IdmIdentityContractService(eu.bcvsolutions.idm.core.api.service.IdmIdentityContractService) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) Assert.assertNotNull(org.junit.Assert.assertNotNull) ContractState(eu.bcvsolutions.idm.core.api.domain.ContractState) SysAttributeControlledValueService(eu.bcvsolutions.idm.acc.service.api.SysAttributeControlledValueService) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Assert.assertTrue(org.junit.Assert.assertTrue) PageRequest(org.springframework.data.domain.PageRequest) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) Test(org.junit.Test) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) List(java.util.List) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) Assert.assertFalse(org.junit.Assert.assertFalse) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) Entry(java.util.Map.Entry) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) TestHelper(eu.bcvsolutions.idm.acc.TestHelper) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysSchemaObjectClassService(eu.bcvsolutions.idm.acc.service.api.SysSchemaObjectClassService) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) Assert.assertEquals(org.junit.Assert.assertEquals) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) Serializable(java.io.Serializable) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) Sort(org.springframework.data.domain.Sort) List(java.util.List) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysAttributeControlledValueFilter(eu.bcvsolutions.idm.acc.dto.filter.SysAttributeControlledValueFilter) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 12 with SysSchemaAttributeDto

use of eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto 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.setCode("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());
}
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) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) ArrayList(java.util.ArrayList) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) 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 13 with SysSchemaAttributeDto

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

the class DefaultSysSystemAttributeMappingServiceTest method transformationFromScriptFailure.

@Test
public void transformationFromScriptFailure() {
    SysSystemDto system = createSystem();
    SysSchemaObjectClassDto objClass = createObjectClass(system);
    SysSchemaAttributeDto schemaAttr = createSchemaAttribute(objClass);
    SysSystemMappingDto systemMapping = testHelper.createMappingSystem(SystemEntityType.IDENTITY, objClass);
    SysSystemAttributeMappingDto attrMapping = createAttributeMappingSystem(systemMapping, AttributeMappingStrategyType.CREATE, schemaAttr.getId());
    // script consists of just one missing symbol,
    // which is supposed to be part of error message
    String script = "xxxxx";
    attrMapping.setTransformFromResourceScript(script);
    systemMapping = mappingService.save(systemMapping);
    try {
        attributeMappingService.transformValueFromResource("testValue", attrMapping, new ArrayList<IcAttribute>());
        fail();
    } catch (ResultCodeException ex) {
        ErrorModel errModel = ex.getError().getError();
        String message = (String) errModel.getParameters().get(SysSystemAttributeMappingService.MAPPING_SCRIPT_FAIL_MESSAGE_KEY);
        String idmPath = (String) errModel.getParameters().get(SysSystemAttributeMappingService.MAPPING_SCRIPT_FAIL_IDM_PATH_KEY);
        assertEquals(errModel.getStatusEnum(), AccResultCode.GROOVY_SCRIPT_ATTR_TRANSFORMATION_FAILED.getCode());
        assertTrue(message.contains(script));
        assertTrue(idmPath.contains(system.getCode()));
        assertTrue(idmPath.contains(systemMapping.getName()));
        assertTrue(idmPath.contains(attrMapping.getName()));
    } catch (Exception e) {
        fail();
    }
}
Also used : IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) 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) ErrorModel(eu.bcvsolutions.idm.core.api.exception.ErrorModel) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 14 with SysSchemaAttributeDto

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

the class DefaultSysSystemAttributeMappingServiceTest method textFilterTest.

@Test
public void textFilterTest() {
    IdmBasePermission permission = IdmBasePermission.ADMIN;
    SystemEntityType entityType = SystemEntityType.IDENTITY;
    AttributeMappingStrategyType strategyType = AttributeMappingStrategyType.MERGE;
    SysSystemDto system = createSystem();
    SysSchemaObjectClassDto objectClass = createObjectClass(system);
    SysSystemMappingDto systemMapping = testHelper.createMappingSystem(entityType, objectClass);
    SysSchemaAttributeDto schemaAttribute = createSchemaAttribute(objectClass);
    SysSystemAttributeMappingDto attributeMapping1 = createAttributeMappingSystem(systemMapping, strategyType, schemaAttribute.getId());
    attributeMapping1.setName("OriginalName01");
    attributeMappingService.save(attributeMapping1);
    SysSystemAttributeMappingDto attributeMapping2 = createAttributeMappingSystem(systemMapping, AttributeMappingStrategyType.CREATE, schemaAttribute.getId());
    attributeMapping2.setName("OriginalName21");
    attributeMappingService.save(attributeMapping2);
    SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
    filter.setText("OriginalName0");
    Page<SysSystemAttributeMappingDto> result = attributeMappingService.find(filter, null, permission);
    assertEquals(1, result.getTotalElements());
    assertTrue(result.getContent().contains(attributeMapping1));
    assertFalse(result.getContent().contains(attributeMapping2));
}
Also used : SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) AttributeMappingStrategyType(eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 15 with SysSchemaAttributeDto

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

the class DefaultSysSystemAttributeMappingServiceTest method isUidFitlerTest.

@Test
public void isUidFitlerTest() {
    IdmBasePermission permission = IdmBasePermission.ADMIN;
    SystemEntityType entityType = SystemEntityType.IDENTITY;
    AttributeMappingStrategyType strategyType = AttributeMappingStrategyType.MERGE;
    SysSystemDto system = createSystem();
    SysSchemaObjectClassDto objectClass = createObjectClass(system);
    SysSystemMappingDto systemMapping1 = testHelper.createMappingSystem(entityType, objectClass);
    SysSystemMappingDto systemMapping2 = testHelper.createMappingSystem(entityType, objectClass);
    SysSchemaAttributeDto schemaAttribute = createSchemaAttribute(objectClass);
    SysSystemAttributeMappingDto attributeMapping1 = createAttributeMappingSystem(systemMapping1, AttributeMappingStrategyType.CREATE, schemaAttribute.getId());
    SysSystemAttributeMappingDto attributeMapping2 = createAttributeMappingSystem(systemMapping2, strategyType, schemaAttribute.getId());
    attributeMapping2.setUid(true);
    attributeMappingService.save(attributeMapping2);
    createAttributeMappingSystem(systemMapping1, AttributeMappingStrategyType.SET, schemaAttribute.getId());
    SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
    filter.setIsUid(true);
    filter.setSystemId(system.getId());
    Page<SysSystemAttributeMappingDto> result = attributeMappingService.find(filter, null, permission);
    assertEquals(1, result.getTotalElements());
    assertTrue(result.getContent().contains(attributeMapping2));
    assertFalse(result.getContent().contains(attributeMapping1));
}
Also used : SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) AttributeMappingStrategyType(eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)168 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)119 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)96 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)89 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)86 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)79 Test (org.junit.Test)73 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)52 UUID (java.util.UUID)40 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)39 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)36 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)35 SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)34 AttributeMappingStrategyType (eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType)28 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)27 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)27 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)26 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)26 Serializable (java.io.Serializable)26 List (java.util.List)25