use of org.springframework.vault.client.VaultClients.PrefixAwareUriTemplateHandler in project spring-vault by spring-projects.
the class VaultClientsUnitTests method shouldAllowNamespaceOverride.
@Test
void shouldAllowNamespaceOverride() {
RestTemplate restTemplate = VaultClients.createRestTemplate();
restTemplate.getInterceptors().add(VaultClients.createNamespaceInterceptor("foo/bar"));
restTemplate.setUriTemplateHandler(new PrefixAwareUriTemplateHandler());
MockRestServiceServer mockRest = MockRestServiceServer.createServer(restTemplate);
mockRest.expect(requestTo("/auth/foo")).andExpect(method(HttpMethod.GET)).andExpect(header(VaultHttpHeaders.VAULT_NAMESPACE, "baz")).andRespond(withSuccess());
HttpHeaders headers = new HttpHeaders();
headers.add(VaultHttpHeaders.VAULT_NAMESPACE, "baz");
restTemplate.exchange("/auth/foo", HttpMethod.GET, new HttpEntity<>(headers), String.class);
}
use of org.springframework.vault.client.VaultClients.PrefixAwareUriTemplateHandler in project spring-vault by spring-projects.
the class VaultClientsUnitTests method uriHandlerShouldNotPrefixAbsoluteUrl.
@Test
void uriHandlerShouldNotPrefixAbsoluteUrl() {
VaultEndpoint localhost = VaultEndpoint.create("localhost", 8200);
PrefixAwareUriTemplateHandler handler = new PrefixAwareUriTemplateHandler(() -> localhost);
URI uri = handler.expand("https://foo/path/{bar}", "bar");
assertThat(uri).hasScheme("https").hasHost("foo").hasPort(-1).hasPath("/path/bar");
}
use of org.springframework.vault.client.VaultClients.PrefixAwareUriTemplateHandler in project spring-vault by spring-projects.
the class LoginTokenAdapterUnitTests method before.
@BeforeEach
void before() throws Exception {
RestTemplate restTemplate = new RestTemplate();
restTemplate.setUriTemplateHandler(new PrefixAwareUriTemplateHandler());
this.mockRest = MockRestServiceServer.createServer(restTemplate);
this.restTemplate = restTemplate;
}
use of org.springframework.vault.client.VaultClients.PrefixAwareUriTemplateHandler in project spring-vault by spring-projects.
the class ClientCertificateAuthenticationUnitTests method before.
@BeforeEach
void before() {
RestTemplate restTemplate = VaultClients.createRestTemplate();
restTemplate.setUriTemplateHandler(new PrefixAwareUriTemplateHandler());
this.mockRest = MockRestServiceServer.createServer(restTemplate);
this.restTemplate = restTemplate;
}
use of org.springframework.vault.client.VaultClients.PrefixAwareUriTemplateHandler in project spring-vault by spring-projects.
the class CubbyholeAuthenticationUnitTests method before.
@BeforeEach
void before() {
RestTemplate restTemplate = new RestTemplate();
restTemplate.setUriTemplateHandler(new PrefixAwareUriTemplateHandler());
this.mockRest = MockRestServiceServer.createServer(restTemplate);
this.restTemplate = restTemplate;
}
Aggregations