Merge branch '3.0.x'
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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/");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user