Search in sources :

Example 6 with IdmConfigurationDto

use of eu.bcvsolutions.idm.core.api.dto.IdmConfigurationDto in project CzechIdMng by bcvsolutions.

the class ConfigurationEvaluatorIntegrationTest method testReadSecuredWithPermissions.

@Test
public void testReadSecuredWithPermissions() {
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    // prepare role
    IdmRoleDto role = helper.createRole();
    // 
    IdmAuthorizationPolicyDto dto = new IdmAuthorizationPolicyDto();
    dto.setRole(role.getId());
    dto.setEvaluator(ConfigurationEvaluator.class);
    dto.setGroupPermission(CoreGroupPermission.CONFIGURATION.getName());
    dto.setAuthorizableType(IdmConfiguration.class.getCanonicalName());
    dto.getEvaluatorProperties().put(ConfigurationEvaluator.PARAMETER_SECURED, Boolean.TRUE.toString());
    dto.setPermissions(IdmBasePermission.READ);
    authorizationPolicyService.save(dto);
    // prepare identity
    IdmIdentityDto identity = helper.createIdentity();
    identity.setPassword(new GuardedString("heslo"));
    identityService.save(identity);
    // assign role
    helper.createIdentityRole(identity, role);
    logout();
    // 
    try {
        loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
        // 
        // evaluate	access
        List<IdmConfigurationDto> configs = configurationService.find(null, IdmBasePermission.READ).getContent();
        assertTrue(configs.contains(publicConfig));
        assertTrue(configs.contains(privateConfig));
    } finally {
        logout();
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmAuthorizationPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto) IdmConfigurationDto(eu.bcvsolutions.idm.core.api.dto.IdmConfigurationDto) IdmConfiguration(eu.bcvsolutions.idm.core.model.entity.IdmConfiguration) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 7 with IdmConfigurationDto

use of eu.bcvsolutions.idm.core.api.dto.IdmConfigurationDto in project CzechIdMng by bcvsolutions.

the class ConfigurationEvaluatorIntegrationTest method testReadWithPermissions.

@Test
public void testReadWithPermissions() {
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    // prepare role
    IdmRoleDto role = helper.createRole();
    // 
    IdmAuthorizationPolicyDto dto = new IdmAuthorizationPolicyDto();
    dto.setRole(role.getId());
    dto.setEvaluator(ConfigurationEvaluator.class);
    dto.setGroupPermission(CoreGroupPermission.CONFIGURATION.getName());
    dto.setAuthorizableType(IdmConfiguration.class.getCanonicalName());
    dto.setPermissions(IdmBasePermission.READ);
    authorizationPolicyService.save(dto);
    // prepare identity
    IdmIdentityDto identity = helper.createIdentity();
    identity.setPassword(new GuardedString("heslo"));
    identityService.save(identity);
    // assign role
    helper.createIdentityRole(identity, role);
    logout();
    // 
    try {
        loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
        // 
        // evaluate	access
        List<IdmConfigurationDto> configs = configurationService.find(null, IdmBasePermission.READ).getContent();
        assertTrue(configs.contains(publicConfig));
        assertFalse(configs.contains(privateConfig));
    } finally {
        logout();
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmAuthorizationPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto) IdmConfigurationDto(eu.bcvsolutions.idm.core.api.dto.IdmConfigurationDto) IdmConfiguration(eu.bcvsolutions.idm.core.model.entity.IdmConfiguration) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 8 with IdmConfigurationDto

use of eu.bcvsolutions.idm.core.api.dto.IdmConfigurationDto in project CzechIdMng by bcvsolutions.

the class DefaultConfigurationServiceIntegrationTest method testReadOverridenPropertyFromDb.

@Test
@Transactional
public void testReadOverridenPropertyFromDb() {
    configurationService.saveConfiguration(new IdmConfigurationDto(TEST_PROPERTY_KEY, "false"));
    assertEquals("false", configurationService.getValue(TEST_PROPERTY_KEY));
}
Also used : IdmConfigurationDto(eu.bcvsolutions.idm.core.api.dto.IdmConfigurationDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with IdmConfigurationDto

use of eu.bcvsolutions.idm.core.api.dto.IdmConfigurationDto in project CzechIdMng by bcvsolutions.

the class DefaultConfigurationServiceIntegrationTest method testReadPropertyFromDb.

@Test
@Transactional
public void testReadPropertyFromDb() {
    configurationService.saveConfiguration(new IdmConfigurationDto(TEST_PROPERTY_DB_KEY, "true"));
    assertTrue(configurationService.getBooleanValue(TEST_PROPERTY_DB_KEY));
}
Also used : IdmConfigurationDto(eu.bcvsolutions.idm.core.api.dto.IdmConfigurationDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with IdmConfigurationDto

use of eu.bcvsolutions.idm.core.api.dto.IdmConfigurationDto in project CzechIdMng by bcvsolutions.

the class PreserveUuidIntegrationTest method testCreateConfigurationWithUuid.

@Test
public void testCreateConfigurationWithUuid() {
    UUID id = UUID.randomUUID();
    IdmConfigurationDto configuration = new IdmConfigurationDto(id);
    configuration.setName("test-property-one");
    configuration.setValue("one");
    // 
    configuration = configurationService.save(configuration);
    // 
    assertEquals(id, configuration.getId());
}
Also used : IdmConfigurationDto(eu.bcvsolutions.idm.core.api.dto.IdmConfigurationDto) UUID(java.util.UUID) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmConfigurationDto (eu.bcvsolutions.idm.core.api.dto.IdmConfigurationDto)16 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)9 Test (org.junit.Test)9 Transactional (org.springframework.transaction.annotation.Transactional)8 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)5 IdmAuthorizationPolicyDto (eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto)2 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)2 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)2 IdmConfiguration (eu.bcvsolutions.idm.core.model.entity.IdmConfiguration)2 LoginDto (eu.bcvsolutions.idm.core.security.api.dto.LoginDto)2 UUID (java.util.UUID)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ValueWrapper (org.springframework.cache.Cache.ValueWrapper)1