Search in sources :

Example 51 with SysSystemMappingDto

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

the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedStrategyMergeWithDuplTest.

@Test
public void compileAttributesOverrloadedStrategyMergeWithDuplTest() {
    String sameValue = "sameValue-" + System.currentTimeMillis();
    String eavAttribute = helper.getSchemaColumnName("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();
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) ArrayList(java.util.ArrayList) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 52 with SysSystemMappingDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto 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(), helper.getSchemaColumnName(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 = identityAccountService.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);
    identityService.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());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 53 with SysSystemMappingDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto 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(), helper.getSchemaColumnName(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 = identityAccountService.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);
        identityService.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());
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 54 with SysSystemMappingDto

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

the class DefaultSysSystemMappingServiceIntegrationTest method systemIdFilterTest.

@Test
public void systemIdFilterTest() {
    IdmBasePermission permission = IdmBasePermission.ADMIN;
    SystemEntityType entityType = SystemEntityType.IDENTITY;
    SysSystemDto system = createSystem();
    SysSchemaObjectClassDto objectClass = createObjectClass(system);
    SysSystemDto system2 = createSystem();
    SysSchemaObjectClassDto objectClass2 = createObjectClass(system2);
    SysSystemMappingDto mappingSystem1 = testHelper.createMappingSystem(entityType, objectClass);
    SysSystemMappingDto mappingSystem2 = testHelper.createMappingSystem(entityType, objectClass2);
    SysSystemMappingFilter filter = new SysSystemMappingFilter();
    filter.setSystemId(system.getId());
    Page<SysSystemMappingDto> result = mappingService.find(filter, null, permission);
    assertEquals(1, result.getTotalElements());
    assertTrue(result.getContent().contains(mappingSystem1));
    assertFalse(result.getContent().contains(mappingSystem2));
}
Also used : SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) 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 55 with SysSystemMappingDto

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

the class DefaultSysSystemMappingServiceIntegrationTest method testAutomaticGenerateOfMappedAttributes.

@Test
public void testAutomaticGenerateOfMappedAttributes() {
    SysSystemDto system = testHelper.createSystem(testHelper.createName());
    SysSchemaObjectClassDto schema = this.createObjectClass(system);
    createSchemaAttribute("__NAME__", schema);
    createSchemaAttribute("first_name", schema);
    // redundant to lastname
    createSchemaAttribute("surname", schema);
    createSchemaAttribute("lastname", schema);
    // redundant to __NAME__
    createSchemaAttribute("__UID__", schema);
    createSchemaAttribute("email", schema);
    createSchemaAttribute("titleBefore", schema);
    createSchemaAttribute("title_after", schema);
    createSchemaAttribute("not_exist", schema);
    createPasswordSchemaAttribute("__PASSWORD__", schema);
    SysSystemMappingDto mappingDto = new SysSystemMappingDto();
    mappingDto.setName(testHelper.createName());
    mappingDto.setEntityType(SystemEntityType.IDENTITY);
    mappingDto.setObjectClass(schema.getId());
    mappingDto.setOperationType(SystemOperationType.PROVISIONING);
    mappingDto = mappingService.publish(new SystemMappingEvent(SystemMappingEvent.SystemMappingEventType.CREATE, mappingDto, ImmutableMap.of(SysSystemMappingService.ENABLE_AUTOMATIC_CREATION_OF_MAPPING, true))).getContent();
    SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
    attributeMappingFilter.setSystemMappingId(mappingDto.getId());
    List<SysSystemAttributeMappingDto> mappingAttributes = mappingAttributeService.find(attributeMappingFilter, null).getContent();
    // Automatic attribute generating is enabled.
    assertEquals(7, mappingAttributes.size());
    SysSystemAttributeMappingDto usernameAttribute = mappingAttributes.stream().filter(attribute -> attribute.getName().equals("__NAME__")).findFirst().orElse(null);
    assertNotNull(usernameAttribute);
    assertTrue(usernameAttribute.isUid());
    assertEquals(IdmIdentity_.username.getName(), usernameAttribute.getIdmPropertyName());
    SysSystemAttributeMappingDto lastnameAttribute = mappingAttributes.stream().filter(attribute -> attribute.getName().equals("lastname")).findFirst().orElse(null);
    assertNotNull(lastnameAttribute);
    assertFalse(lastnameAttribute.isUid());
    assertEquals(IdmIdentity_.lastName.getName(), lastnameAttribute.getIdmPropertyName());
    SysSystemAttributeMappingDto firstNameAttribute = mappingAttributes.stream().filter(attribute -> attribute.getName().equals("first_name")).findFirst().orElse(null);
    assertNotNull(firstNameAttribute);
    assertFalse(firstNameAttribute.isUid());
    assertEquals(IdmIdentity_.firstName.getName(), firstNameAttribute.getIdmPropertyName());
    SysSystemAttributeMappingDto titleBeforeAttribute = mappingAttributes.stream().filter(attribute -> attribute.getName().equals("titleBefore")).findFirst().orElse(null);
    assertNotNull(titleBeforeAttribute);
    assertFalse(titleBeforeAttribute.isUid());
    assertEquals(IdmIdentity_.titleBefore.getName(), titleBeforeAttribute.getIdmPropertyName());
    SysSystemAttributeMappingDto titleAfterAttribute = mappingAttributes.stream().filter(attribute -> attribute.getName().equals("title_after")).findFirst().orElse(null);
    assertNotNull(titleAfterAttribute);
    assertFalse(titleAfterAttribute.isUid());
    assertEquals(IdmIdentity_.titleAfter.getName(), titleAfterAttribute.getIdmPropertyName());
    SysSystemAttributeMappingDto emailAttribute = mappingAttributes.stream().filter(attribute -> attribute.getName().equals("email")).findFirst().orElse(null);
    assertNotNull(emailAttribute);
    assertFalse(emailAttribute.isUid());
    assertEquals(IdmIdentity_.email.getName(), emailAttribute.getIdmPropertyName());
    SysSystemAttributeMappingDto passwordAttribute = mappingAttributes.stream().filter(attribute -> attribute.getName().equals("__PASSWORD__")).findFirst().orElse(null);
    assertNotNull(passwordAttribute);
    assertFalse(passwordAttribute.isUid());
    assertTrue(passwordAttribute.isPasswordAttribute());
}
Also used : SystemMappingEvent(eu.bcvsolutions.idm.acc.event.SystemMappingEvent) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) 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

SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)359 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)269 Test (org.junit.Test)208 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)180 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)172 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)134 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)106 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)95 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)90 SysSystemMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter)89 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)80 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)70 UUID (java.util.UUID)60 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)58 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)56 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)42 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)38 TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)38 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)36 SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)36