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();
}
}
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();
}
}
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));
}
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));
}
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());
}
Aggregations