Merge branch '3.0.x'

This commit is contained in:
spencergibb
2021-09-10 14:06:10 -04:00
2 changed files with 12 additions and 1 deletions

View File

@@ -63,6 +63,9 @@ public class ConsulPropertySource extends EnumerablePropertySource<ConsulClient>
if (!this.context.endsWith("/")) {
this.context = this.context + "/";
}
if (this.context.startsWith("/")) {
this.context = this.context.substring(1);
}
Response<List<GetValue>> response = this.source.getKVValues(this.context, this.configProperties.getAclToken(),
QueryParams.DEFAULT);

View File

@@ -43,7 +43,7 @@ public class ConsulPropertySourceTests {
@Before
public void setup() {
ConsulTestcontainers.start();
this.prefix = "consulPropertySourceTests" + new Random().nextInt(Integer.MAX_VALUE);
this.prefix = "/consulPropertySourceTests" + new Random().nextInt(Integer.MAX_VALUE);
this.client = ConsulTestcontainers.client();
}
@@ -117,4 +117,12 @@ public class ConsulPropertySourceTests {
return source;
}
@Test
public void testExtraSlashInContext() {
ConsulPropertySource source = new ConsulPropertySource("/my/very/custom/context", this.client,
new ConsulConfigProperties());
source.init();
assertThat(source.getContext()).as("context was wrong").isEqualTo("my/very/custom/context/");
}
}