Search in sources :

Example 41 with SysSystemDto

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

the class DefaultSysSystemServiceTest method testFormAttributes.

/**
 * Test add and delete extended attributes to owner
 */
@Test
public void testFormAttributes() {
    // create owner
    SysSystemDto system = new SysSystemDto();
    system.setName(SYSTEM_NAME_ONE);
    system = systemService.save(system);
    SysSystemDto systemOne = systemService.getByCode(SYSTEM_NAME_ONE);
    assertEquals(SYSTEM_NAME_ONE, systemOne.getName());
    // 
    // create definition one
    IdmFormDefinitionDto formDefinitionOne = new IdmFormDefinitionDto();
    formDefinitionOne.setType(SysSystem.class.getCanonicalName());
    formDefinitionOne.setCode("v1");
    formDefinitionOne = formDefinitionService.save(formDefinitionOne);
    IdmFormAttributeDto attributeDefinitionOne = new IdmFormAttributeDto();
    attributeDefinitionOne.setFormDefinition(formDefinitionOne.getId());
    attributeDefinitionOne.setCode("name_" + System.currentTimeMillis());
    attributeDefinitionOne.setName(attributeDefinitionOne.getCode());
    attributeDefinitionOne.setPersistentType(PersistentType.TEXT);
    attributeDefinitionOne = formAttributeService.save(attributeDefinitionOne);
    formDefinitionOne = formDefinitionService.get(formDefinitionOne.getId());
    // 
    // create definition two
    IdmFormDefinitionDto formDefinitionTwo = new IdmFormDefinitionDto();
    formDefinitionTwo.setType(SysSystem.class.getCanonicalName());
    formDefinitionTwo.setCode("v2");
    formDefinitionTwo = formDefinitionService.save(formDefinitionTwo);
    IdmFormAttributeDto attributeDefinitionTwo = new IdmFormAttributeDto();
    attributeDefinitionTwo.setFormDefinition(formDefinitionTwo.getId());
    attributeDefinitionTwo.setCode("name_" + System.currentTimeMillis());
    attributeDefinitionTwo.setName(attributeDefinitionTwo.getCode());
    attributeDefinitionTwo.setPersistentType(PersistentType.TEXT);
    attributeDefinitionTwo = formAttributeService.save(attributeDefinitionTwo);
    formDefinitionTwo = formDefinitionService.get(formDefinitionTwo.getId());
    // 
    IdmFormValueDto value1 = new IdmFormValueDto(attributeDefinitionOne);
    value1.setValue("test1");
    IdmFormValueDto value2 = new IdmFormValueDto(attributeDefinitionTwo);
    value2.setValue("test2");
    formService.saveValues(system, formDefinitionOne, Lists.newArrayList(value1));
    formService.saveValues(system, formDefinitionTwo, Lists.newArrayList(value2));
    assertEquals("test1", formService.getValues(system, formDefinitionOne).get(0).getStringValue());
    assertEquals("test2", formService.getValues(system, formDefinitionTwo).get(0).getStringValue());
    assertEquals("test2", formService.getValues(system, formDefinitionTwo, attributeDefinitionTwo.getName()).get(0).getValue());
    // 
    // create second owner
    SysSystemDto systemTwo = new SysSystemDto();
    systemTwo.setName(SYSTEM_NAME_TWO);
    systemTwo = systemService.save(systemTwo);
    assertEquals(0, formService.getValues(systemTwo, formDefinitionOne).size());
    assertEquals(0, formService.getValues(systemTwo, formDefinitionTwo).size());
    assertEquals(1, formService.getValues(system, formDefinitionOne).size());
    assertEquals(1, formService.getValues(system, formDefinitionTwo).size());
    systemService.delete(systemTwo);
    assertEquals(1, formService.getValues(system, formDefinitionOne).size());
    assertEquals(1, formService.getValues(system, formDefinitionTwo).size());
    formService.deleteValues(system, formDefinitionOne);
    assertEquals(0, formService.getValues(system, formDefinitionOne).size());
    assertEquals("test2", formService.getValues(system, formDefinitionTwo).get(0).getStringValue());
    systemService.delete(system);
}
Also used : SysSystem(eu.bcvsolutions.idm.acc.entity.SysSystem) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 42 with SysSystemDto

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

the class DefaultSysSystemServiceTest method checkSystemUnValid.

@Test(expected = RuntimeException.class)
public void checkSystemUnValid() {
    // create test system
    SysSystemDto system = helper.createSystem(TestResource.TABLE_NAME);
    // set wrong password
    formService.saveValues(system, "password", ImmutableList.of("wrongPassword"));
    // do test system
    systemService.checkSystem(system);
}
Also used : SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 43 with SysSystemDto

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

the class DefaultSysSystemServiceTest method testReferentialIntegritySystemEntityExists.

@Test
public void testReferentialIntegritySystemEntityExists() {
    SysSystemDto system = new SysSystemDto();
    String systemName = "t_s_" + System.currentTimeMillis();
    system.setName(systemName);
    system = systemService.save(system);
    // system entity
    SysSystemEntityDto systemEntity = new SysSystemEntityDto();
    systemEntity.setSystem(system.getId());
    systemEntity.setEntityType(SystemEntityType.IDENTITY);
    systemEntity.setUid("se_uid_" + System.currentTimeMillis());
    systemEntity = systemEntityService.save(systemEntity);
    systemService.delete(system);
    assertNull(systemService.getByCode(system.getCode()));
    assertNull(systemEntityService.get(systemEntity.getId()));
}
Also used : SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 44 with SysSystemDto

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

the class DefaultSysSystemServiceTest method testFillConnectorConfiguration.

@Test
public void testFillConnectorConfiguration() {
    // create owner
    @SuppressWarnings("deprecation") SysSystemDto system = systemService.createTestSystem();
    IcConnectorConfiguration connectorConfiguration = systemService.getConnectorConfiguration(system);
    assertEquals(15, connectorConfiguration.getConfigurationProperties().getProperties().size());
    // 
    // check all supported data types
    // TODO: add all supported types
    Integer checked = 0;
    for (IcConfigurationProperty property : connectorConfiguration.getConfigurationProperties().getProperties()) {
        switch(property.getName()) {
            case "host":
                {
                    assertEquals("localhost", property.getValue());
                    checked++;
                    break;
                }
            case "password":
                {
                    assertEquals(new org.identityconnectors.common.security.GuardedString("idmadmin".toCharArray()), property.getValue());
                    checked++;
                    break;
                }
            case "rethrowAllSQLExceptions":
                {
                    assertEquals(true, property.getValue());
                    checked++;
                    break;
                }
        }
    }
    ;
    assertEquals(Integer.valueOf(3), checked);
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IcConfigurationProperty(eu.bcvsolutions.idm.ic.api.IcConfigurationProperty) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 45 with SysSystemDto

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

the class DefaultSysSystemServiceTest method duplicateSystem.

@Test
public void duplicateSystem() {
    // create test system
    SysSystemDto system = helper.createTestResourceSystem(true);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(system.getId());
    // Number of schema attributes on original system
    int numberOfSchemaAttributesOrig = schemaAttributeService.find(schemaAttributeFilter, null).getContent().size();
    SysSystemMappingDto mappingOrig = helper.getDefaultMapping(system);
    // Number of mapping attributes on original system
    int numberOfMappingAttributesOrig = systemAttributeMappingService.findBySystemMapping(mappingOrig).size();
    SysSystemDto duplicatedSystem = systemService.duplicate(system.getId());
    // check duplicate
    systemService.checkSystem(duplicatedSystem);
    Assert.assertNotEquals(system.getId(), duplicatedSystem.getId());
    schemaAttributeFilter.setSystemId(duplicatedSystem.getId());
    // Number of schema attributes on duplicated system
    int numberOfSchemaAttributes = schemaAttributeService.find(schemaAttributeFilter, null).getContent().size();
    Assert.assertEquals(numberOfSchemaAttributesOrig, numberOfSchemaAttributes);
    SysSystemMappingDto mapping = helper.getDefaultMapping(duplicatedSystem);
    // Number of mapping attributes on duplicated system
    int numberOfMappingAttributes = systemAttributeMappingService.findBySystemMapping(mapping).size();
    Assert.assertEquals(numberOfMappingAttributesOrig, numberOfMappingAttributes);
}
Also used : SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)256 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)167 Test (org.junit.Test)167 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)98 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)82 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)56 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)52 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)50 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)45 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)42 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)42 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)32 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)32 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)30 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)29 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)29 SysProvisioningOperationFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter)29 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)28 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)27 IdmBasePermission (eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission)27