use of org.springframework.vault.support.ClientOptions in project spring-vault by spring-projects.
the class VaultNamespaceSecretIntegrationTests method before.
@BeforeEach
void before() {
Assumptions.assumeTrue(prepare().getVersion().isEnterprise(), "Namespaces require enterprise version");
List<String> namespaces = new ArrayList<>(Arrays.asList("dev/", "marketing/"));
List<String> list = prepare().getVaultOperations().list("sys/namespaces");
namespaces.removeAll(list);
for (String namespace : namespaces) {
prepare().getVaultOperations().write("sys/namespaces/" + namespace.replaceAll("/", ""));
}
this.devRestTemplate = RestTemplateBuilder.builder().requestFactory(ClientHttpRequestFactoryFactory.create(new ClientOptions(), Settings.createSslConfiguration())).endpoint(TestRestTemplateFactory.TEST_VAULT_ENDPOINT).customizers(restTemplate -> restTemplate.getInterceptors().add(VaultClients.createNamespaceInterceptor("dev")));
this.marketingRestTemplate = RestTemplateBuilder.builder().requestFactory(ClientHttpRequestFactoryFactory.create(new ClientOptions(), Settings.createSslConfiguration())).endpoint(TestRestTemplateFactory.TEST_VAULT_ENDPOINT).defaultHeader(VaultHttpHeaders.VAULT_NAMESPACE, "marketing");
VaultTemplate dev = new VaultTemplate(this.devRestTemplate, new SimpleSessionManager(new TokenAuthentication(Settings.token())));
mountKv(dev, "dev-secrets");
dev.opsForSys().createOrUpdatePolicy("relaxed", POLICY);
this.devToken = dev.opsForToken().create(VaultTokenRequest.builder().withPolicy("relaxed").build()).getToken().getToken();
VaultTemplate marketing = new VaultTemplate(this.marketingRestTemplate, new SimpleSessionManager(new TokenAuthentication(Settings.token())));
mountKv(marketing, "marketing-secrets");
marketing.opsForSys().createOrUpdatePolicy("relaxed", POLICY);
this.marketingToken = marketing.opsForToken().create(VaultTokenRequest.builder().withPolicy("relaxed").build()).getToken().getToken();
}
use of org.springframework.vault.support.ClientOptions in project spring-vault by spring-projects.
the class ClientHttpConnectorFactoryIntegrationTests method jettyClientWithExplicitEnabledProtocolsShouldWork.
@Test
void jettyClientWithExplicitEnabledProtocolsShouldWork() {
List<String> enabledProtocols = new ArrayList<String>();
enabledProtocols.add("TLSv1.2");
ClientHttpConnector factory = JettyClient.usingJetty(new ClientOptions(), Settings.createSslConfiguration().withEnabledProtocols(enabledProtocols));
WebClient webClient = WebClient.builder().clientConnector(factory).build();
String response = request(webClient);
assertThat(response).isNotNull().contains("initialized");
}
use of org.springframework.vault.support.ClientOptions in project spring-vault by spring-projects.
the class ClientHttpConnectorFactoryIntegrationTests method reactorNettyClientShouldWork.
@Test
void reactorNettyClientShouldWork() {
ClientHttpConnector factory = ReactorNetty.usingReactorNetty(new ClientOptions(), Settings.createSslConfiguration());
WebClient webClient = WebClient.builder().clientConnector(factory).build();
String response = request(webClient);
assertThat(response).isNotNull().contains("initialized");
}
use of org.springframework.vault.support.ClientOptions in project spring-vault by spring-projects.
the class ClientHttpConnectorFactoryIntegrationTests method jettyClientShouldWork.
@Test
void jettyClientShouldWork() {
ClientHttpConnector factory = JettyClient.usingJetty(new ClientOptions(), Settings.createSslConfiguration());
WebClient webClient = WebClient.builder().clientConnector(factory).build();
String response = request(webClient);
assertThat(response).isNotNull().contains("initialized");
}
use of org.springframework.vault.support.ClientOptions in project spring-vault by spring-projects.
the class ClientHttpRequestFactoryFactoryIntegrationTests method okHttp3ClientWithExplicitCipherSuitesShouldWork.
@Test
void okHttp3ClientWithExplicitCipherSuitesShouldWork() throws Exception {
List<String> enabledCipherSuites = new ArrayList<String>();
enabledCipherSuites.add("TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384");
enabledCipherSuites.add("TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256");
ClientHttpRequestFactory factory = OkHttp3.usingOkHttp3(new ClientOptions(), Settings.createSslConfiguration().withEnabledCipherSuites(enabledCipherSuites));
RestTemplate template = new RestTemplate(factory);
String response = request(template);
assertThat(factory).isInstanceOf(OkHttp3ClientHttpRequestFactory.class);
assertThat(response).isNotNull().contains("initialized");
((DisposableBean) factory).destroy();
}
Aggregations