Commit a83d8181 authored by abirembaut's avatar abirembaut Committed by GitHub
Browse files

fix(configuration) erroneous space at the end of a property value breaks (#649)

the configuration

* apply trim() when reading a property value

Covers [BPO-645](https://bonitasoft.atlassian.net/browse/BPO-645)
parent 4b7afe07
......@@ -39,7 +39,8 @@ public class ConfigurationFile {
}
public String getProperty(final String propertyName) {
return getPropertiesOfScope().getProperty(propertyName);
final String propertyValue = getPropertiesOfScope().getProperty(propertyName);
return propertyValue != null ? propertyValue.trim() : null;
}
private Properties getPropertiesOfScope() {
......
......@@ -35,9 +35,31 @@ public class ConfigurationFileTest {
@Test
public void should_getProperty_return_the_right_custom_permissions_with_special_characters() throws Exception {
final ConfigurationFile tenantProperties = new ConfigurationFile(CUSTOM_PERMISSIONS_MAPPING_FILE, TENANT_ID);
final String customValue = tenantProperties.getProperty("profile|HR manager");
Assert.assertEquals("[ManageProfiles]", customValue);
}
@Test
public void should_getProperty_return_the_right_permissions_with_trailing_spaces() throws Exception {
final ConfigurationFile tenantProperties = new ConfigurationFile(COMPOUND_PERMISSIONS_MAPPING_FILE, TENANT_ID);
final String value = tenantProperties.getProperty("caseListingPage");
final Set<String> valueAsList = tenantProperties.getPropertyAsSet("caseListingPage");
Assert.assertEquals("caseVisualizationWithTrailingSpace", value);
assertThat(valueAsList).containsOnly("caseVisualizationWithTrailingSpace");
}
@Test
public void should_getProperty_return_null_with_unknown_permissions() throws Exception {
final ConfigurationFile tenantProperties = new ConfigurationFile(COMPOUND_PERMISSIONS_MAPPING_FILE, TENANT_ID);
final String value = tenantProperties.getProperty("unknownListingPage");
Assert.assertNull(value);
}
@Test
public void should_getProperty_return_the_right_compound_permissions() throws Exception {
......
processListingPage processVisualization
caseListingPage caseVisualizationWithTrailingSpace
taskListingPage [TaskVisualization, CaseVisualization]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment