Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ private String getPropertyName(String path, String key) {
if (key.startsWith("[")) {
return path + key;
}
if (key.contains(".")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd have to do this for any characters that are not alpha-numeric or -.

return path + "[" + key + "]";
}
return path + "." + key;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ void testServicePropertiesWithoutNA() {
assertThat(getProperty("vcap.services.mysql.credentials.port")).isEqualTo("3306");
}

@Test
void testServicePropertiesContainingKeysWithDot() {
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context,
"VCAP_SERVICES={\"user-provided\":[{\"name\":\"test\",\"label\":\"test-label\","
+ "\"credentials\":{\"key.with.dots\":\"some-value\"}}]}");
this.initializer.postProcessEnvironment(this.context.getEnvironment(), null);
assertThat(getProperty("vcap.services.test.name")).isEqualTo("test");
assertThat(getProperty("vcap.services.test.credentials[key.with.dots]")).isEqualTo("some-value");
}

private String getProperty(String key) {
return this.context.getEnvironment().getProperty(key);
}
Expand Down