Consider Vault base path in VaultClients
VaultClients.toBaseUri(…) now properly renders endpoints considering the path segment from VaultEndpoint. Resolves: gh-413.
This commit is contained in:
@@ -207,8 +207,9 @@ public class VaultClients {
|
||||
}
|
||||
|
||||
private static String toBaseUri(VaultEndpoint endpoint) {
|
||||
return endpoint.getScheme() + "://" + endpoint.getHost() + ":"
|
||||
+ endpoint.getPort() + "/v1";
|
||||
|
||||
return String.format("%s://%s:%s/%s", endpoint.getScheme(), endpoint.getHost(),
|
||||
endpoint.getPort(), endpoint.getPath());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -81,4 +81,17 @@ public class VaultClientsUnitTests {
|
||||
assertThat(uri).hasScheme("https").hasHost("foo").hasPort(-1)
|
||||
.hasPath("/path/bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldApplyBasepath() {
|
||||
|
||||
VaultEndpoint localhost = VaultEndpoint.create("localhost", 8200);
|
||||
localhost.setPath("foo/v1");
|
||||
PrefixAwareUriTemplateHandler handler = new PrefixAwareUriTemplateHandler(
|
||||
() -> localhost);
|
||||
|
||||
URI uri = handler.expand("/path/{bar}", "bar");
|
||||
|
||||
assertThat(uri).hasHost("localhost").hasPort(8200).hasPath("/foo/v1/path/bar");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user