Upgrade to Java 8, Spring 5.0, and Boot 2.0.
This commit is contained in:
@@ -29,8 +29,9 @@ buildscript {
|
||||
}
|
||||
|
||||
ext {
|
||||
springVersion = "4.3.8.RELEASE"
|
||||
springVersion = "5.0.10.RELEASE"
|
||||
springCloudConnectorsVersion = "1.2.5.RELEASE"
|
||||
reactorVersion = "Bismuth-SR13"
|
||||
|
||||
junitVersion = "4.12"
|
||||
mockitoVersion = "2.7.22"
|
||||
@@ -52,6 +53,7 @@ allprojects {
|
||||
apply plugin: 'propdeps-maven'
|
||||
apply plugin: 'propdeps-idea'
|
||||
apply plugin: 'propdeps-eclipse'
|
||||
apply plugin: "io.spring.dependency-management"
|
||||
apply plugin: 'org.asciidoctor.gradle.asciidoctor'
|
||||
|
||||
group = 'org.springframework.credhub'
|
||||
|
||||
@@ -14,4 +14,4 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
version=1.1.0.BUILD-SNAPSHOT
|
||||
version=2.0.0.BUILD-SNAPSHOT
|
||||
|
||||
@@ -14,16 +14,23 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
dependencyManagement {
|
||||
imports {
|
||||
mavenBom "org.springframework:spring-framework-bom:${springVersion}"
|
||||
mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
|
||||
}
|
||||
}
|
||||
|
||||
description = 'Spring CredHub Cloud Connector'
|
||||
|
||||
dependencies {
|
||||
compile project(':spring-credhub-core')
|
||||
|
||||
compile "org.springframework:spring-core:${springVersion}"
|
||||
compile "org.springframework:spring-core"
|
||||
compile "org.springframework.cloud:spring-cloud-cloudfoundry-connector:${springCloudConnectorsVersion}"
|
||||
|
||||
testImplementation("org.springframework:spring-test:${springVersion}")
|
||||
testImplementation("junit:junit:${junitVersion}")
|
||||
testImplementation("org.mockito:mockito-core:${mockitoVersion}")
|
||||
testImplementation("org.springframework:spring-test")
|
||||
testImplementation("junit:junit")
|
||||
testImplementation("org.mockito:mockito-core")
|
||||
testImplementation("org.assertj:assertj-core:${assertJVersion}")
|
||||
}
|
||||
|
||||
@@ -14,24 +14,38 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
dependencyManagement {
|
||||
imports {
|
||||
mavenBom "org.springframework:spring-framework-bom:${springVersion}"
|
||||
mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
|
||||
}
|
||||
}
|
||||
|
||||
description = 'Spring CredHub Core'
|
||||
|
||||
dependencies {
|
||||
compile("org.springframework:spring-core:${springVersion}")
|
||||
compile("org.springframework:spring-beans:${springVersion}")
|
||||
compile("org.springframework:spring-web:${springVersion}")
|
||||
compile("com.fasterxml.jackson.core:jackson-databind:2.8.7")
|
||||
compile("org.springframework:spring-core")
|
||||
compile("org.springframework:spring-beans")
|
||||
compile("org.springframework:spring-context")
|
||||
compile("org.springframework:spring-web")
|
||||
compile("com.fasterxml.jackson.core:jackson-databind:2.9.7")
|
||||
|
||||
optional("org.springframework:spring-webflux")
|
||||
optional("io.projectreactor.ipc:reactor-netty")
|
||||
|
||||
optional("org.springframework.security.oauth:spring-security-oauth2:2.0.14.RELEASE") {
|
||||
exclude(group: 'org.springframework')
|
||||
}
|
||||
|
||||
optional("org.springframework.security.oauth:spring-security-oauth2:2.0.14.RELEASE")
|
||||
optional("org.apache.httpcomponents:httpclient:4.5.3") {
|
||||
exclude(group: 'commons-logging', module: 'commons-logging')
|
||||
}
|
||||
optional("com.squareup.okhttp3:okhttp:3.6.0")
|
||||
optional("io.netty:netty-all:4.1.8.Final")
|
||||
optional("io.netty:netty-all:4.1.30.Final")
|
||||
|
||||
testImplementation("org.springframework:spring-test:${springVersion}")
|
||||
testImplementation("junit:junit:${junitVersion}")
|
||||
testImplementation("org.mockito:mockito-core:${mockitoVersion}")
|
||||
testImplementation("org.springframework:spring-test")
|
||||
testImplementation("junit:junit")
|
||||
testImplementation("org.mockito:mockito-core")
|
||||
testImplementation("org.assertj:assertj-core:${assertJVersion}")
|
||||
testImplementation("com.jayway.jsonpath:json-path:2.4.0")
|
||||
}
|
||||
|
||||
@@ -114,10 +114,10 @@ public class ClientHttpRequestFactoryFactory {
|
||||
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
||||
|
||||
if (options.getConnectionTimeout() != null) {
|
||||
factory.setConnectTimeout(options.getConnectionTimeout());
|
||||
factory.setConnectTimeout(options.getConnectionTimeoutMillis());
|
||||
}
|
||||
if (options.getReadTimeout() != null) {
|
||||
factory.setReadTimeout(options.getReadTimeout());
|
||||
factory.setReadTimeout(options.getReadTimeoutMillis());
|
||||
}
|
||||
|
||||
return factory;
|
||||
@@ -154,10 +154,10 @@ public class ClientHttpRequestFactoryFactory {
|
||||
.setAuthenticationEnabled(true);
|
||||
|
||||
if (options.getConnectionTimeout() != null) {
|
||||
requestConfigBuilder.setConnectTimeout(options.getConnectionTimeout());
|
||||
requestConfigBuilder.setConnectTimeout(options.getConnectionTimeoutMillis());
|
||||
}
|
||||
if (options.getReadTimeout() != null) {
|
||||
requestConfigBuilder.setSocketTimeout(options.getReadTimeout());
|
||||
requestConfigBuilder.setSocketTimeout(options.getReadTimeoutMillis());
|
||||
}
|
||||
|
||||
httpClientBuilder.setDefaultRequestConfig(requestConfigBuilder.build());
|
||||
@@ -193,10 +193,10 @@ public class ClientHttpRequestFactoryFactory {
|
||||
}
|
||||
|
||||
if (options.getConnectionTimeout() != null) {
|
||||
builder.connectTimeout(options.getConnectionTimeout(), TimeUnit.MILLISECONDS);
|
||||
builder.connectTimeout(options.getConnectionTimeoutMillis(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
if (options.getReadTimeout() != null) {
|
||||
builder.readTimeout(options.getReadTimeout(), TimeUnit.MILLISECONDS);
|
||||
builder.readTimeout(options.getReadTimeoutMillis(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
return new OkHttp3ClientHttpRequestFactory(builder.build());
|
||||
@@ -219,10 +219,10 @@ public class ClientHttpRequestFactoryFactory {
|
||||
final Netty4ClientHttpRequestFactory requestFactory = new Netty4ClientHttpRequestFactory();
|
||||
|
||||
if (options.getConnectionTimeout() != null) {
|
||||
requestFactory.setConnectTimeout(options.getConnectionTimeout());
|
||||
requestFactory.setConnectTimeout(options.getConnectionTimeoutMillis());
|
||||
}
|
||||
if (options.getReadTimeout() != null) {
|
||||
requestFactory.setReadTimeout(options.getReadTimeout());
|
||||
requestFactory.setReadTimeout(options.getReadTimeoutMillis());
|
||||
}
|
||||
|
||||
if (usingCustomCerts(options)) {
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
public class CredHubTemplateFactory {
|
||||
|
||||
public CredHubTemplate credHubTemplate(CredHubProperties credHubProperties,
|
||||
ClientHttpRequestFactory clientHttpRequestFactory) {
|
||||
ClientHttpRequestFactory clientHttpRequestFactory) {
|
||||
return new CredHubTemplate(credHubProperties.getUrl(), clientHttpRequestFactory);
|
||||
}
|
||||
|
||||
@@ -38,30 +38,18 @@ public class CredHubTemplateFactory {
|
||||
* Create a {@link ClientHttpRequestFactory}.
|
||||
*
|
||||
* @return the {@link ClientHttpRequestFactory} instance.
|
||||
*
|
||||
* @see #clientOptions()
|
||||
*/
|
||||
public ClientHttpRequestFactory clientHttpRequestFactoryWrapper() {
|
||||
return ClientHttpRequestFactoryFactory.create(clientOptions());
|
||||
return ClientHttpRequestFactoryFactory.create(new ClientOptions());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link ClientHttpRequestFactory}.
|
||||
*
|
||||
* @return the {@link ClientHttpRequestFactory} instance.
|
||||
*
|
||||
* @param clientOptions options for creating the client connection
|
||||
* @return the {@link ClientHttpRequestFactory} instance.
|
||||
*/
|
||||
public ClientHttpRequestFactory clientHttpRequestFactoryWrapper(ClientOptions clientOptions) {
|
||||
return ClientHttpRequestFactoryFactory.create(clientOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the default {@link ClientOptions} to configure communication parameters.
|
||||
*
|
||||
* @return the default {@link ClientOptions}
|
||||
*/
|
||||
private ClientOptions clientOptions() {
|
||||
return new ClientOptions();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ import org.springframework.web.util.UriTemplateHandler;
|
||||
* @author Scott Frederick
|
||||
* @author Daniel Lavoie
|
||||
*/
|
||||
public class CredHubClient {
|
||||
class CredHubClientFactory {
|
||||
/**
|
||||
* Create a {@link RestTemplate} configured for communication with a CredHub server.
|
||||
*
|
||||
@@ -57,8 +57,8 @@ public class CredHubClient {
|
||||
* creating new connections
|
||||
* @return a configured {@link RestTemplate}
|
||||
*/
|
||||
public static RestTemplate createRestTemplate(String baseUri,
|
||||
ClientHttpRequestFactory clientHttpRequestFactory) {
|
||||
static RestTemplate createRestTemplate(String baseUri,
|
||||
ClientHttpRequestFactory clientHttpRequestFactory) {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
configureRestTemplate(restTemplate, baseUri, clientHttpRequestFactory);
|
||||
@@ -68,13 +68,14 @@ public class CredHubClient {
|
||||
|
||||
/**
|
||||
* Configure a {@link RestTemplate} for communication with a CredHub server.
|
||||
*
|
||||
* @param restTemplate an existing {@link RestTemplate} to configure
|
||||
* @param baseUri the base URI for the CredHub server
|
||||
* @param clientHttpRequestFactory the {@link ClientHttpRequestFactory} to use when
|
||||
* creating new connections
|
||||
*/
|
||||
public static void configureRestTemplate(RestTemplate restTemplate, String baseUri,
|
||||
ClientHttpRequestFactory clientHttpRequestFactory) {
|
||||
static void configureRestTemplate(RestTemplate restTemplate, String baseUri,
|
||||
ClientHttpRequestFactory clientHttpRequestFactory) {
|
||||
restTemplate.setRequestFactory(clientHttpRequestFactory);
|
||||
restTemplate.setUriTemplateHandler(createUriTemplateHandler(baseUri));
|
||||
restTemplate.setMessageConverters(createMessageConverters());
|
||||
@@ -101,7 +102,7 @@ public class CredHubClient {
|
||||
* @return the list of {@link HttpMessageConverter}s
|
||||
*/
|
||||
private static List<HttpMessageConverter<?>> createMessageConverters() {
|
||||
List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>(3);
|
||||
List<HttpMessageConverter<?>> messageConverters = new ArrayList<>(3);
|
||||
messageConverters.add(new ByteArrayHttpMessageConverter());
|
||||
messageConverters.add(new StringHttpMessageConverter());
|
||||
messageConverters.add(new MappingJackson2HttpMessageConverter(JsonUtils.buildObjectMapper()));
|
||||
@@ -115,7 +116,7 @@ public class CredHubClient {
|
||||
* @return the list of {@link ClientHttpRequestInterceptor}s
|
||||
*/
|
||||
private static List<ClientHttpRequestInterceptor> createInterceptors() {
|
||||
List<ClientHttpRequestInterceptor> interceptors = new ArrayList<ClientHttpRequestInterceptor>(1);
|
||||
List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>(1);
|
||||
interceptors.add(new CredHubRequestInterceptor());
|
||||
return interceptors;
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public class CredHubTemplate implements CredHubOperations {
|
||||
Assert.notNull(apiUriBase, "apiUriBase must not be null");
|
||||
Assert.notNull(clientHttpRequestFactory, "clientHttpRequestFactory must not be null");
|
||||
|
||||
this.restTemplate = CredHubClient.createRestTemplate(apiUriBase,
|
||||
this.restTemplate = CredHubClientFactory.createRestTemplate(apiUriBase,
|
||||
clientHttpRequestFactory);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public class OAuth2CredHubTemplate extends CredHubTemplate {
|
||||
String apiUriBase, ClientHttpRequestFactory clientHttpRequestFactory) {
|
||||
OAuth2RestTemplate restTemplate = new OAuth2RestTemplate(resource);
|
||||
|
||||
CredHubClient.configureRestTemplate(restTemplate, apiUriBase,
|
||||
CredHubClientFactory.configureRestTemplate(restTemplate, apiUriBase,
|
||||
clientHttpRequestFactory);
|
||||
|
||||
return restTemplate;
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.credhub.core.certificate;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.credhub.core.CredHubOperations;
|
||||
import org.springframework.credhub.core.ExceptionUtils;
|
||||
import org.springframework.credhub.core.RestOperationsCallback;
|
||||
import org.springframework.credhub.support.certificate.CertificateSummary;
|
||||
import org.springframework.credhub.support.certificate.CertificateSummaryData;
|
||||
import org.springframework.credhub.support.CredentialName;
|
||||
@@ -28,7 +27,6 @@ import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.client.RestOperations;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -65,17 +63,13 @@ public class CredHubCertificateTemplate implements CredHubCertificateOperations
|
||||
|
||||
@Override
|
||||
public List<CertificateSummary> getAll() {
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<List<CertificateSummary>>() {
|
||||
@Override
|
||||
public List<CertificateSummary> doWithRestOperations(
|
||||
RestOperations restOperations) {
|
||||
ResponseEntity<CertificateSummaryData> response = restOperations
|
||||
.getForEntity(BASE_URL_PATH, CertificateSummaryData.class);
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
ResponseEntity<CertificateSummaryData> response = restOperations
|
||||
.getForEntity(BASE_URL_PATH, CertificateSummaryData.class);
|
||||
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
|
||||
return response.getBody().getCertificates();
|
||||
}
|
||||
return response.getBody().getCertificates();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -83,17 +77,13 @@ public class CredHubCertificateTemplate implements CredHubCertificateOperations
|
||||
public CertificateSummary getByName(final CredentialName name) {
|
||||
Assert.notNull(name, "certificate name must not be null");
|
||||
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<CertificateSummary>() {
|
||||
@Override
|
||||
public CertificateSummary doWithRestOperations(
|
||||
RestOperations restOperations) {
|
||||
ResponseEntity<CertificateSummaryData> response = restOperations
|
||||
.getForEntity(NAME_URL_QUERY, CertificateSummaryData.class, name.getName());
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
ResponseEntity<CertificateSummaryData> response = restOperations
|
||||
.getForEntity(NAME_URL_QUERY, CertificateSummaryData.class, name.getName());
|
||||
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
|
||||
return response.getBody().getCertificates().get(0);
|
||||
}
|
||||
return response.getBody().getCertificates().get(0);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -104,20 +94,17 @@ public class CredHubCertificateTemplate implements CredHubCertificateOperations
|
||||
final ParameterizedTypeReference<CertificateCredentialDetails> ref =
|
||||
new ParameterizedTypeReference<CertificateCredentialDetails>() {};
|
||||
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<CertificateCredentialDetails>() {
|
||||
@Override
|
||||
public CertificateCredentialDetails doWithRestOperations(RestOperations restOperations) {
|
||||
Map<String, Boolean> request = new HashMap<>(1);
|
||||
request.put(TRANSITIONAL_REQUEST_FIELD, setAsTransitional);
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
Map<String, Boolean> request = new HashMap<>(1);
|
||||
request.put(TRANSITIONAL_REQUEST_FIELD, setAsTransitional);
|
||||
|
||||
ResponseEntity<CertificateCredentialDetails> response =
|
||||
restOperations.exchange(REGENERATE_URL_PATH, HttpMethod.POST,
|
||||
new HttpEntity<Object>(request), ref, id);
|
||||
ResponseEntity<CertificateCredentialDetails> response =
|
||||
restOperations.exchange(REGENERATE_URL_PATH, HttpMethod.POST,
|
||||
new HttpEntity<Object>(request), ref, id);
|
||||
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
|
||||
return response.getBody();
|
||||
}
|
||||
return response.getBody();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -128,20 +115,17 @@ public class CredHubCertificateTemplate implements CredHubCertificateOperations
|
||||
final ParameterizedTypeReference<Map<String, List<CredentialName>>> ref =
|
||||
new ParameterizedTypeReference<Map<String, List<CredentialName>>>() {};
|
||||
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<List<CredentialName>>() {
|
||||
@Override
|
||||
public List<CredentialName> doWithRestOperations(RestOperations restOperations) {
|
||||
Map<String, Object> request = new HashMap<>(1);
|
||||
request.put(SIGNED_BY_REQUEST_FIELD, certificateName.getName());
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
Map<String, Object> request = new HashMap<>(1);
|
||||
request.put(SIGNED_BY_REQUEST_FIELD, certificateName.getName());
|
||||
|
||||
ResponseEntity<Map<String, List<CredentialName>>> response =
|
||||
restOperations.exchange(BULK_REGENERATE_URL_PATH, HttpMethod.POST,
|
||||
new HttpEntity<>(request), ref);
|
||||
ResponseEntity<Map<String, List<CredentialName>>> response =
|
||||
restOperations.exchange(BULK_REGENERATE_URL_PATH, HttpMethod.POST,
|
||||
new HttpEntity<>(request), ref);
|
||||
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
|
||||
return response.getBody().get(REGENERATED_CREDENTIALS_RESPONSE_FIELD);
|
||||
}
|
||||
return response.getBody().get(REGENERATED_CREDENTIALS_RESPONSE_FIELD);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -152,20 +136,17 @@ public class CredHubCertificateTemplate implements CredHubCertificateOperations
|
||||
final ParameterizedTypeReference<List<CertificateCredentialDetails>> ref =
|
||||
new ParameterizedTypeReference<List<CertificateCredentialDetails>>() {};
|
||||
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<List<CertificateCredentialDetails>>() {
|
||||
@Override
|
||||
public List<CertificateCredentialDetails> doWithRestOperations(RestOperations restOperations) {
|
||||
Map<String, String> request = new HashMap<>(1);
|
||||
request.put(VERSION_REQUEST_FIELD, versionId);
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
Map<String, String> request = new HashMap<>(1);
|
||||
request.put(VERSION_REQUEST_FIELD, versionId);
|
||||
|
||||
ResponseEntity<List<CertificateCredentialDetails>> response =
|
||||
restOperations.exchange(UPDATE_TRANSITIONAL_URL_PATH, HttpMethod.PUT,
|
||||
new HttpEntity<Object>(request), ref, id);
|
||||
ResponseEntity<List<CertificateCredentialDetails>> response =
|
||||
restOperations.exchange(UPDATE_TRANSITIONAL_URL_PATH, HttpMethod.PUT,
|
||||
new HttpEntity<Object>(request), ref, id);
|
||||
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
|
||||
return response.getBody();
|
||||
}
|
||||
return response.getBody();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.credhub.core.credential;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.credhub.core.CredHubOperations;
|
||||
import org.springframework.credhub.core.ExceptionUtils;
|
||||
import org.springframework.credhub.core.RestOperationsCallback;
|
||||
import org.springframework.credhub.support.CredentialDetails;
|
||||
import org.springframework.credhub.support.CredentialDetailsData;
|
||||
import org.springframework.credhub.support.CredentialName;
|
||||
@@ -33,7 +32,6 @@ import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.client.RestOperations;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -76,17 +74,14 @@ public class CredHubCredentialTemplate implements CredHubCredentialOperations {
|
||||
final ParameterizedTypeReference<CredentialDetails<T>> ref =
|
||||
new ParameterizedTypeReference<CredentialDetails<T>>() {};
|
||||
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<CredentialDetails<T>>() {
|
||||
@Override
|
||||
public CredentialDetails<T> doWithRestOperations(RestOperations restOperations) {
|
||||
ResponseEntity<CredentialDetails<T>> response =
|
||||
restOperations.exchange(BASE_URL_PATH, HttpMethod.PUT,
|
||||
new HttpEntity<>(credentialRequest), ref);
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
ResponseEntity<CredentialDetails<T>> response =
|
||||
restOperations.exchange(BASE_URL_PATH, HttpMethod.PUT,
|
||||
new HttpEntity<>(credentialRequest), ref);
|
||||
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
|
||||
return response.getBody();
|
||||
}
|
||||
return response.getBody();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -97,17 +92,14 @@ public class CredHubCredentialTemplate implements CredHubCredentialOperations {
|
||||
final ParameterizedTypeReference<CredentialDetails<T>> ref =
|
||||
new ParameterizedTypeReference<CredentialDetails<T>>() {};
|
||||
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<CredentialDetails<T>>() {
|
||||
@Override
|
||||
public CredentialDetails<T> doWithRestOperations(RestOperations restOperations) {
|
||||
ResponseEntity<CredentialDetails<T>> response =
|
||||
restOperations.exchange(BASE_URL_PATH, HttpMethod.POST,
|
||||
new HttpEntity<>(parametersRequest), ref);
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
ResponseEntity<CredentialDetails<T>> response =
|
||||
restOperations.exchange(BASE_URL_PATH, HttpMethod.POST,
|
||||
new HttpEntity<>(parametersRequest), ref);
|
||||
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
|
||||
return response.getBody();
|
||||
}
|
||||
return response.getBody();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -119,20 +111,17 @@ public class CredHubCredentialTemplate implements CredHubCredentialOperations {
|
||||
final ParameterizedTypeReference<CredentialDetails<T>> ref =
|
||||
new ParameterizedTypeReference<CredentialDetails<T>>() {};
|
||||
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<CredentialDetails<T>>() {
|
||||
@Override
|
||||
public CredentialDetails<T> doWithRestOperations(RestOperations restOperations) {
|
||||
Map<String, Object> request = new HashMap<>(1);
|
||||
request.put(NAME_REQUEST_FIELD, name.getName());
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
Map<String, Object> request = new HashMap<>(1);
|
||||
request.put(NAME_REQUEST_FIELD, name.getName());
|
||||
|
||||
ResponseEntity<CredentialDetails<T>> response =
|
||||
restOperations.exchange(REGENERATE_URL_PATH, HttpMethod.POST,
|
||||
new HttpEntity<>(request), ref);
|
||||
ResponseEntity<CredentialDetails<T>> response =
|
||||
restOperations.exchange(REGENERATE_URL_PATH, HttpMethod.POST,
|
||||
new HttpEntity<>(request), ref);
|
||||
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
|
||||
return response.getBody();
|
||||
}
|
||||
return response.getBody();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -144,16 +133,13 @@ public class CredHubCredentialTemplate implements CredHubCredentialOperations {
|
||||
final ParameterizedTypeReference<CredentialDetails<T>> ref =
|
||||
new ParameterizedTypeReference<CredentialDetails<T>>() {};
|
||||
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<CredentialDetails<T>>() {
|
||||
@Override
|
||||
public CredentialDetails<T> doWithRestOperations(RestOperations restOperations) {
|
||||
ResponseEntity<CredentialDetails<T>> response =
|
||||
restOperations.exchange(ID_URL_PATH, HttpMethod.GET, null, ref, id);
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
ResponseEntity<CredentialDetails<T>> response =
|
||||
restOperations.exchange(ID_URL_PATH, HttpMethod.GET, null, ref, id);
|
||||
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
|
||||
return response.getBody();
|
||||
}
|
||||
return response.getBody();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -165,17 +151,14 @@ public class CredHubCredentialTemplate implements CredHubCredentialOperations {
|
||||
final ParameterizedTypeReference<CredentialDetailsData<T>> ref =
|
||||
new ParameterizedTypeReference<CredentialDetailsData<T>>() {};
|
||||
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<CredentialDetails<T>>() {
|
||||
@Override
|
||||
public CredentialDetails<T> doWithRestOperations(RestOperations restOperations) {
|
||||
ResponseEntity<CredentialDetailsData<T>> response =
|
||||
restOperations.exchange(NAME_URL_QUERY_CURRENT, HttpMethod.GET,
|
||||
null, ref, name.getName());
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
ResponseEntity<CredentialDetailsData<T>> response =
|
||||
restOperations.exchange(NAME_URL_QUERY_CURRENT, HttpMethod.GET,
|
||||
null, ref, name.getName());
|
||||
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
|
||||
return response.getBody().getData().get(0);
|
||||
}
|
||||
return response.getBody().getData().get(0);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -187,16 +170,13 @@ public class CredHubCredentialTemplate implements CredHubCredentialOperations {
|
||||
final ParameterizedTypeReference<CredentialDetailsData<T>> ref =
|
||||
new ParameterizedTypeReference<CredentialDetailsData<T>>() {};
|
||||
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<List<CredentialDetails<T>>>() {
|
||||
@Override
|
||||
public List<CredentialDetails<T>> doWithRestOperations(RestOperations restOperations) {
|
||||
ResponseEntity<CredentialDetailsData<T>> response =
|
||||
restOperations.exchange(NAME_URL_QUERY, HttpMethod.GET, null, ref, name.getName());
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
ResponseEntity<CredentialDetailsData<T>> response =
|
||||
restOperations.exchange(NAME_URL_QUERY, HttpMethod.GET, null, ref, name.getName());
|
||||
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
|
||||
return response.getBody().getData();
|
||||
}
|
||||
return response.getBody().getData();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -209,17 +189,14 @@ public class CredHubCredentialTemplate implements CredHubCredentialOperations {
|
||||
final ParameterizedTypeReference<CredentialDetailsData<T>> ref =
|
||||
new ParameterizedTypeReference<CredentialDetailsData<T>>() {};
|
||||
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<List<CredentialDetails<T>>>() {
|
||||
@Override
|
||||
public List<CredentialDetails<T>> doWithRestOperations(RestOperations restOperations) {
|
||||
ResponseEntity<CredentialDetailsData<T>> response =
|
||||
restOperations.exchange(NAME_URL_QUERY_VERSIONS, HttpMethod.GET, null, ref,
|
||||
name.getName(), versions);
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
ResponseEntity<CredentialDetailsData<T>> response =
|
||||
restOperations.exchange(NAME_URL_QUERY_VERSIONS, HttpMethod.GET, null, ref,
|
||||
name.getName(), versions);
|
||||
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
|
||||
return response.getBody().getData();
|
||||
}
|
||||
return response.getBody().getData();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -227,18 +204,14 @@ public class CredHubCredentialTemplate implements CredHubCredentialOperations {
|
||||
public List<CredentialSummary> findByName(final CredentialName name) {
|
||||
Assert.notNull(name, "credential name must not be null");
|
||||
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<List<CredentialSummary>>() {
|
||||
@Override
|
||||
public List<CredentialSummary> doWithRestOperations(
|
||||
RestOperations restOperations) {
|
||||
ResponseEntity<CredentialSummaryData> response = restOperations
|
||||
.getForEntity(NAME_LIKE_URL_QUERY,
|
||||
CredentialSummaryData.class, name.getName());
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
ResponseEntity<CredentialSummaryData> response = restOperations
|
||||
.getForEntity(NAME_LIKE_URL_QUERY,
|
||||
CredentialSummaryData.class, name.getName());
|
||||
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
|
||||
return response.getBody().getCredentials();
|
||||
}
|
||||
return response.getBody().getCredentials();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -246,35 +219,27 @@ public class CredHubCredentialTemplate implements CredHubCredentialOperations {
|
||||
public List<CredentialSummary> findByPath(final String path) {
|
||||
Assert.notNull(path, "credential path must not be null");
|
||||
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<List<CredentialSummary>>() {
|
||||
@Override
|
||||
public List<CredentialSummary> doWithRestOperations(
|
||||
RestOperations restOperations) {
|
||||
ResponseEntity<CredentialSummaryData> response = restOperations
|
||||
.getForEntity(PATH_URL_QUERY, CredentialSummaryData.class,
|
||||
path);
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
ResponseEntity<CredentialSummaryData> response = restOperations
|
||||
.getForEntity(PATH_URL_QUERY, CredentialSummaryData.class,
|
||||
path);
|
||||
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
|
||||
return response.getBody().getCredentials();
|
||||
}
|
||||
return response.getBody().getCredentials();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<CredentialPath> getAllPaths() {
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<List<CredentialPath>>() {
|
||||
@Override
|
||||
public List<CredentialPath> doWithRestOperations(
|
||||
RestOperations restOperations) {
|
||||
ResponseEntity<CredentialPathData> response = restOperations
|
||||
.getForEntity(SHOW_ALL_URL_QUERY, CredentialPathData.class);
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
ResponseEntity<CredentialPathData> response = restOperations
|
||||
.getForEntity(SHOW_ALL_URL_QUERY, CredentialPathData.class);
|
||||
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
|
||||
return response.getBody().getPaths();
|
||||
}
|
||||
return response.getBody().getPaths();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -282,15 +247,9 @@ public class CredHubCredentialTemplate implements CredHubCredentialOperations {
|
||||
public void deleteByName(final CredentialName name) {
|
||||
Assert.notNull(name, "credential name must not be null");
|
||||
|
||||
final String name1 = name.getName();
|
||||
Assert.notNull(name1, "credential name must not be null");
|
||||
|
||||
credHubOperations.doWithRest(new RestOperationsCallback<Void>() {
|
||||
@Override
|
||||
public Void doWithRestOperations(RestOperations restOperations) {
|
||||
restOperations.delete(NAME_URL_QUERY, name1);
|
||||
return null;
|
||||
}
|
||||
credHubOperations.doWithRest(restOperations -> {
|
||||
restOperations.delete(NAME_URL_QUERY, name.getName());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,8 @@ package org.springframework.credhub.core.info;
|
||||
|
||||
import org.springframework.credhub.core.CredHubOperations;
|
||||
import org.springframework.credhub.core.ExceptionUtils;
|
||||
import org.springframework.credhub.core.RestOperationsCallback;
|
||||
import org.springframework.credhub.support.info.VersionInfo;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestOperations;
|
||||
|
||||
/**
|
||||
* Implements the interaction with CredHub retrieve server information.
|
||||
@@ -49,16 +47,13 @@ public class CredHubInfoTemplate implements CredHubInfoOperations {
|
||||
*/
|
||||
@Override
|
||||
public VersionInfo version() {
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<VersionInfo>() {
|
||||
@Override
|
||||
public VersionInfo doWithRestOperations(RestOperations restOperations) {
|
||||
ResponseEntity<VersionInfo> response = restOperations
|
||||
.getForEntity(VERSION_URL_PATH, VersionInfo.class);
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
ResponseEntity<VersionInfo> response = restOperations
|
||||
.getForEntity(VERSION_URL_PATH, VersionInfo.class);
|
||||
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
|
||||
return response.getBody();
|
||||
}
|
||||
return response.getBody();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,13 +18,11 @@ package org.springframework.credhub.core.interpolation;
|
||||
|
||||
import org.springframework.credhub.core.CredHubOperations;
|
||||
import org.springframework.credhub.core.ExceptionUtils;
|
||||
import org.springframework.credhub.core.RestOperationsCallback;
|
||||
import org.springframework.credhub.support.ServicesData;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.client.RestOperations;
|
||||
|
||||
/**
|
||||
* Implements the main interaction with CredHub to interpolate service binding credentials.
|
||||
@@ -49,17 +47,14 @@ public class CredHubInterpolationTemplate implements CredHubInterpolationOperati
|
||||
public ServicesData interpolateServiceData(final ServicesData serviceData) {
|
||||
Assert.notNull(serviceData, "serviceData must not be null");
|
||||
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<ServicesData>() {
|
||||
@Override
|
||||
public ServicesData doWithRestOperations(RestOperations restOperations) {
|
||||
ResponseEntity<ServicesData> response = restOperations
|
||||
.exchange(INTERPOLATE_URL_PATH, HttpMethod.POST,
|
||||
new HttpEntity<>(serviceData), ServicesData.class);
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
ResponseEntity<ServicesData> response = restOperations
|
||||
.exchange(INTERPOLATE_URL_PATH, HttpMethod.POST,
|
||||
new HttpEntity<>(serviceData), ServicesData.class);
|
||||
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
ExceptionUtils.throwExceptionOnError(response);
|
||||
|
||||
return response.getBody();
|
||||
}
|
||||
return response.getBody();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.credhub.core.permission;
|
||||
|
||||
import org.springframework.credhub.core.CredHubOperations;
|
||||
import org.springframework.credhub.core.RestOperationsCallback;
|
||||
import org.springframework.credhub.support.CredentialName;
|
||||
import org.springframework.credhub.support.CredentialPermissions;
|
||||
import org.springframework.credhub.support.permissions.Actor;
|
||||
@@ -26,7 +25,6 @@ import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.client.RestOperations;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -56,14 +54,11 @@ public class CredHubPermissionTemplate implements CredHubPermissionOperations {
|
||||
public List<Permission> getPermissions(final CredentialName name) {
|
||||
Assert.notNull(name, "credential name must not be null");
|
||||
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<List<Permission>>() {
|
||||
@Override
|
||||
public List<Permission> doWithRestOperations(RestOperations restOperations) {
|
||||
ResponseEntity<CredentialPermissions> response =
|
||||
restOperations.getForEntity(PERMISSIONS_URL_QUERY,
|
||||
CredentialPermissions.class, name.getName());
|
||||
return response.getBody().getPermissions();
|
||||
}
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
ResponseEntity<CredentialPermissions> response =
|
||||
restOperations.getForEntity(PERMISSIONS_URL_QUERY,
|
||||
CredentialPermissions.class, name.getName());
|
||||
return response.getBody().getPermissions();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -74,14 +69,11 @@ public class CredHubPermissionTemplate implements CredHubPermissionOperations {
|
||||
|
||||
final CredentialPermissions credentialPermissions = new CredentialPermissions(name, permissions);
|
||||
|
||||
credHubOperations.doWithRest(new RestOperationsCallback<Void>() {
|
||||
@Override
|
||||
public Void doWithRestOperations(RestOperations restOperations) {
|
||||
restOperations.exchange(PERMISSIONS_URL_PATH, HttpMethod.POST,
|
||||
new HttpEntity<>(credentialPermissions),
|
||||
CredentialPermissions.class);
|
||||
return null;
|
||||
}
|
||||
credHubOperations.doWithRest(restOperations -> {
|
||||
restOperations.exchange(PERMISSIONS_URL_PATH, HttpMethod.POST,
|
||||
new HttpEntity<>(credentialPermissions),
|
||||
CredentialPermissions.class);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -90,12 +82,9 @@ public class CredHubPermissionTemplate implements CredHubPermissionOperations {
|
||||
Assert.notNull(name, "credential name must not be null");
|
||||
Assert.notNull(actor, "actor must not be null");
|
||||
|
||||
credHubOperations.doWithRest(new RestOperationsCallback<Void>() {
|
||||
@Override
|
||||
public Void doWithRestOperations(RestOperations restOperations) {
|
||||
restOperations.delete(PERMISSIONS_ACTOR_URL_QUERY, name.getName(), actor.getIdentity());
|
||||
return null;
|
||||
}
|
||||
credHubOperations.doWithRest(restOperations -> {
|
||||
restOperations.delete(PERMISSIONS_ACTOR_URL_QUERY, name.getName(), actor.getIdentity());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.credhub.core.permissionV2;
|
||||
|
||||
import org.springframework.credhub.core.CredHubOperations;
|
||||
import org.springframework.credhub.core.RestOperationsCallback;
|
||||
import org.springframework.credhub.support.CredentialName;
|
||||
import org.springframework.credhub.support.CredentialPermission;
|
||||
import org.springframework.credhub.support.permissions.Permission;
|
||||
@@ -25,7 +24,6 @@ import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.client.RestOperations;
|
||||
|
||||
/**
|
||||
* Implements the main interaction with CredHub to add, retrieve,
|
||||
@@ -52,14 +50,11 @@ public class CredHubPermissionV2Template implements CredHubPermissionV2Operation
|
||||
public CredentialPermission getPermissions(final String id) {
|
||||
Assert.notNull(id, "credential ID must not be null");
|
||||
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<CredentialPermission>() {
|
||||
@Override
|
||||
public CredentialPermission doWithRestOperations(RestOperations restOperations) {
|
||||
ResponseEntity<CredentialPermission> response =
|
||||
restOperations.getForEntity(PERMISSIONS_ID_URL_PATH,
|
||||
CredentialPermission.class, id);
|
||||
return response.getBody();
|
||||
}
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
ResponseEntity<CredentialPermission> response =
|
||||
restOperations.getForEntity(PERMISSIONS_ID_URL_PATH,
|
||||
CredentialPermission.class, id);
|
||||
return response.getBody();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -71,15 +66,12 @@ public class CredHubPermissionV2Template implements CredHubPermissionV2Operation
|
||||
|
||||
final CredentialPermission credentialPermission = new CredentialPermission(path, permission);
|
||||
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<CredentialPermission>() {
|
||||
@Override
|
||||
public CredentialPermission doWithRestOperations(RestOperations restOperations) {
|
||||
ResponseEntity<CredentialPermission> response =
|
||||
restOperations.exchange(PERMISSIONS_URL_PATH, HttpMethod.POST,
|
||||
new HttpEntity<>(credentialPermission),
|
||||
CredentialPermission.class);
|
||||
return response.getBody();
|
||||
}
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
ResponseEntity<CredentialPermission> response =
|
||||
restOperations.exchange(PERMISSIONS_URL_PATH, HttpMethod.POST,
|
||||
new HttpEntity<>(credentialPermission),
|
||||
CredentialPermission.class);
|
||||
return response.getBody();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -92,15 +84,12 @@ public class CredHubPermissionV2Template implements CredHubPermissionV2Operation
|
||||
|
||||
final CredentialPermission credentialPermission = new CredentialPermission(path, permission);
|
||||
|
||||
return credHubOperations.doWithRest(new RestOperationsCallback<CredentialPermission>() {
|
||||
@Override
|
||||
public CredentialPermission doWithRestOperations(RestOperations restOperations) {
|
||||
ResponseEntity<CredentialPermission> response =
|
||||
restOperations.exchange(PERMISSIONS_ID_URL_PATH, HttpMethod.PUT,
|
||||
new HttpEntity<>(credentialPermission),
|
||||
CredentialPermission.class, id);
|
||||
return response.getBody();
|
||||
}
|
||||
return credHubOperations.doWithRest(restOperations -> {
|
||||
ResponseEntity<CredentialPermission> response =
|
||||
restOperations.exchange(PERMISSIONS_ID_URL_PATH, HttpMethod.PUT,
|
||||
new HttpEntity<>(credentialPermission),
|
||||
CredentialPermission.class, id);
|
||||
return response.getBody();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -108,12 +97,9 @@ public class CredHubPermissionV2Template implements CredHubPermissionV2Operation
|
||||
public void deletePermission(final String id) {
|
||||
Assert.notNull(id, "credential ID must not be null");
|
||||
|
||||
credHubOperations.doWithRest(new RestOperationsCallback<Void>() {
|
||||
@Override
|
||||
public Void doWithRestOperations(RestOperations restOperations) {
|
||||
restOperations.delete(PERMISSIONS_ID_URL_PATH, id);
|
||||
return null;
|
||||
}
|
||||
credHubOperations.doWithRest(restOperations -> {
|
||||
restOperations.delete(PERMISSIONS_ID_URL_PATH, id);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.credhub.support;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@@ -25,9 +26,9 @@ import java.util.concurrent.TimeUnit;
|
||||
* @author Scott Frederick
|
||||
*/
|
||||
public class ClientOptions {
|
||||
private Integer connectionTimeout;
|
||||
private Duration connectionTimeout;
|
||||
|
||||
private Integer readTimeout;
|
||||
private Duration readTimeout;
|
||||
|
||||
private String[] caCertFiles;
|
||||
|
||||
@@ -49,7 +50,7 @@ public class ClientOptions {
|
||||
* {@literal 0}
|
||||
* @param caCertFiles one or more CA certificate files to use when connecting
|
||||
*/
|
||||
public ClientOptions(int connectionTimeout, int readTimeout, String[] caCertFiles) {
|
||||
public ClientOptions(Duration connectionTimeout, Duration readTimeout, String[] caCertFiles) {
|
||||
this.connectionTimeout = connectionTimeout;
|
||||
this.readTimeout = readTimeout;
|
||||
this.caCertFiles = caCertFiles;
|
||||
@@ -60,11 +61,20 @@ public class ClientOptions {
|
||||
*
|
||||
* @return the connection timeout; can be {@literal null if not explicitly set}
|
||||
*/
|
||||
public Integer getConnectionTimeout() {
|
||||
public Duration getConnectionTimeout() {
|
||||
return this.connectionTimeout;
|
||||
}
|
||||
|
||||
public void setConnectionTimeout(Integer connectionTimeout) {
|
||||
/**
|
||||
* Get the connection timeout in {@link TimeUnit#MILLISECONDS}.
|
||||
*
|
||||
* @return the connection timeout; can be {@literal null if not explicitly set}
|
||||
*/
|
||||
public Integer getConnectionTimeoutMillis() {
|
||||
return this.connectionTimeout == null ? null : Math.toIntExact(this.connectionTimeout.toMillis());
|
||||
}
|
||||
|
||||
public void setConnectionTimeout(Duration connectionTimeout) {
|
||||
this.connectionTimeout = connectionTimeout;
|
||||
}
|
||||
|
||||
@@ -73,11 +83,20 @@ public class ClientOptions {
|
||||
*
|
||||
* @return the read timeout; can be {@literal null if not explicitly set}
|
||||
*/
|
||||
public Integer getReadTimeout() {
|
||||
public Duration getReadTimeout() {
|
||||
return this.readTimeout;
|
||||
}
|
||||
|
||||
public void setReadTimeout(Integer readTimeout) {
|
||||
/**
|
||||
* Get the read timeout in {@link TimeUnit#MILLISECONDS}.
|
||||
*
|
||||
* @return the read timeout; can be {@literal null if not explicitly set}
|
||||
*/
|
||||
public Integer getReadTimeoutMillis() {
|
||||
return this.readTimeout == null ? null : Math.toIntExact(this.readTimeout.toMillis());
|
||||
}
|
||||
|
||||
public void setReadTimeout(Duration readTimeout) {
|
||||
this.readTimeout = readTimeout;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.web.util.AbstractUriTemplateHandler;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CredHubClientUnitTests {
|
||||
public class CredHubClientFactoryUnitTests {
|
||||
private static final String CREDHUB_URI = "https://credhub.cf.example.com:8844";
|
||||
|
||||
@Mock
|
||||
@@ -38,7 +38,7 @@ public class CredHubClientUnitTests {
|
||||
|
||||
@Test
|
||||
public void restTemplateIsCreated() {
|
||||
RestTemplate restTemplate = CredHubClient.createRestTemplate(CREDHUB_URI,
|
||||
RestTemplate restTemplate = CredHubClientFactory.createRestTemplate(CREDHUB_URI,
|
||||
clientHttpRequestFactory);
|
||||
|
||||
assertThat(restTemplate.getUriTemplateHandler())
|
||||
@@ -28,7 +28,7 @@ import org.springframework.credhub.core.CredHubOperations;
|
||||
import org.springframework.credhub.core.credential.CredHubCredentialOperations;
|
||||
import org.springframework.credhub.core.interpolation.CredHubInterpolationOperations;
|
||||
import org.springframework.credhub.core.permission.CredHubPermissionOperations;
|
||||
import org.springframework.credhub.support.permissions.CredentialPermission;
|
||||
import org.springframework.credhub.support.permissions.Permission;
|
||||
import org.springframework.credhub.support.CredentialDetails;
|
||||
import org.springframework.credhub.support.CredentialName;
|
||||
import org.springframework.credhub.support.CredentialSummary;
|
||||
@@ -150,7 +150,7 @@ public class CredHubDemoController {
|
||||
|
||||
private void getCredentialPermissions(CredentialName name, Results results) {
|
||||
try {
|
||||
List<CredentialPermission> retrievedDetails = permissionOperations.getPermissions(name);
|
||||
List<Permission> retrievedDetails = permissionOperations.getPermissions(name);
|
||||
saveResults(results, "Successfully retrieved credential permissions: ", retrievedDetails);
|
||||
} catch (Exception e) {
|
||||
saveResults(results, "Error retrieving credential permissions: ", e.getMessage());
|
||||
@@ -159,7 +159,7 @@ public class CredHubDemoController {
|
||||
|
||||
private void addCredentialPermissions(CredentialName name, Results results) {
|
||||
try {
|
||||
CredentialPermission permission = CredentialPermission.builder()
|
||||
Permission permission = Permission.builder()
|
||||
.app(APP_GUID_2)
|
||||
.operations(Operation.READ, Operation.WRITE, Operation.DELETE)
|
||||
.build();
|
||||
|
||||
@@ -18,6 +18,12 @@ plugins {
|
||||
id 'org.asciidoctor.convert'
|
||||
}
|
||||
|
||||
dependencyManagement {
|
||||
imports {
|
||||
mavenBom "org.springframework.boot:spring-boot-dependencies:2.0.6.RELEASE"
|
||||
}
|
||||
}
|
||||
|
||||
description = "Spring CredHub Documentation"
|
||||
|
||||
apply plugin: 'org.asciidoctor.convert'
|
||||
|
||||
@@ -14,33 +14,28 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
dependencyManagement {
|
||||
imports {
|
||||
mavenBom "org.springframework.boot:spring-boot-dependencies:2.0.6.RELEASE"
|
||||
}
|
||||
}
|
||||
|
||||
description = 'Spring CredHub Starter'
|
||||
|
||||
apply plugin: 'org.springframework.boot'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.8.RELEASE")
|
||||
}
|
||||
}
|
||||
|
||||
bootRepackage {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':spring-credhub-core')
|
||||
compile("org.springframework.boot:spring-boot-starter")
|
||||
compile("org.springframework.boot:spring-boot-autoconfigure")
|
||||
|
||||
optional("org.springframework.security.oauth:spring-security-oauth2")
|
||||
optional("org.apache.httpcomponents:httpclient:4.5.3") {
|
||||
optional("org.springframework.boot:spring-boot-starter-webflux")
|
||||
|
||||
optional("org.springframework.boot:spring-boot-starter-security")
|
||||
optional("org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.1.0.RELEASE")
|
||||
|
||||
optional("org.apache.httpcomponents:httpclient") {
|
||||
exclude(group: 'commons-logging', module: 'commons-logging')
|
||||
}
|
||||
optional("com.squareup.okhttp3:okhttp:3.6.0")
|
||||
optional("io.netty:netty-all:4.1.8.Final")
|
||||
optional("io.netty:netty-all:4.1.30.Final")
|
||||
|
||||
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
|
||||
annotationProcessor("org.springframework.boot:spring-boot-autoconfigure-processor")
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.credhub.configuration.CredHubTemplateFactory;
|
||||
@@ -35,8 +36,8 @@ import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
* @author Scott Frederick
|
||||
* @author Daniel Lavoie
|
||||
*/
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties
|
||||
@ConditionalOnProperty(value = "spring.credhub.url")
|
||||
public class CredHubAutoConfiguration {
|
||||
private final CredHubTemplateFactory credHubTemplateFactory = new CredHubTemplateFactory();
|
||||
|
||||
@@ -46,7 +46,8 @@ public class CredHubOAuth2TemplateAutoConfiguration {
|
||||
*
|
||||
* @param credHubProperties {@link CredHubProperties} for CredHub
|
||||
* @param credHubCredentialsDetails OAuth2 credentials for use with the {@link OAuth2RestTemplate}
|
||||
* @param clientFactoryWrapper a {@link ClientFactoryWrapper} to customize CredHub http requests
|
||||
* @param clientFactoryWrapper a {@link ClientFactoryWrapper}
|
||||
* to customize CredHub http requests
|
||||
*
|
||||
* @return the {@link CredHubOperations} bean
|
||||
*/
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.springframework.credhub.core.CredHubTemplate;
|
||||
* @author Scott Frederick
|
||||
* @author Daniel Lavoie
|
||||
*/
|
||||
|
||||
@Configuration
|
||||
@AutoConfigureAfter(CredHubOAuth2TemplateAutoConfiguration.class)
|
||||
@ConditionalOnProperty(value = "spring.credhub.url")
|
||||
@@ -45,9 +44,9 @@ public class CredHubTemplateAutoConfiguration {
|
||||
* Create the {@link CredHubTemplate} that the application will use to interact
|
||||
* with CredHub.
|
||||
*
|
||||
* @param credHubProperties {@link CredHubProperties} for CredHub
|
||||
* @param credHubProperties {@link CredHubProperties} for CredHub
|
||||
* @param clientFactoryWrapper a {@link ClientFactoryWrapper} to customize CredHub
|
||||
* http requests
|
||||
* http requests
|
||||
* @return the {@link CredHubTemplate} bean
|
||||
*/
|
||||
@Bean
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.credhub.configuration;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.credhub.autoconfig.CredHubAutoConfiguration;
|
||||
import org.springframework.credhub.autoconfig.CredHubAutoConfiguration.ClientFactoryWrapper;
|
||||
import org.springframework.credhub.core.CredHubProperties;
|
||||
import org.springframework.credhub.support.ClientOptions;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class CredHubAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(CredHubAutoConfiguration.class))
|
||||
.withPropertyValues(
|
||||
"spring.credhub.url=https://localhost",
|
||||
"spring.credhub.connection-timeout=30",
|
||||
"spring.credhub.read-timeout=60"
|
||||
)
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(CredHubProperties.class);
|
||||
CredHubProperties properties = context.getBean(CredHubProperties.class);
|
||||
assertThat(properties.getUrl()).isEqualTo("https://localhost");
|
||||
|
||||
assertThat(context).hasSingleBean(ClientOptions.class);
|
||||
ClientOptions options = context.getBean(ClientOptions.class);
|
||||
assertThat(options.getConnectionTimeout()).isEqualTo(Duration.ofMillis(30));
|
||||
assertThat(options.getReadTimeout()).isEqualTo(Duration.ofMillis(60));
|
||||
|
||||
assertThat(context).hasSingleBean(ClientFactoryWrapper.class);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package org.springframework.credhub.configuration;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.credhub.autoconfig.security.CredHubCredentialsDetails;
|
||||
import org.springframework.credhub.configuration.CredHubOAuth2TemplateAutoConfigurationTest.TestConfig;
|
||||
import org.springframework.credhub.core.CredHubOperations;
|
||||
import org.springframework.credhub.core.OAuth2CredHubTemplate;
|
||||
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Daniel Lavoie
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = TestConfig.class, properties = {
|
||||
"spring.credhub.url=https://localhost",
|
||||
"spring.credhub.oauth2.client-id=test-user",
|
||||
"spring.credhub.oauth2.client-secret=test-secret",
|
||||
"spring.credhub.oauth2.access-token-uri=https://uaa.example.com/oauth/token",
|
||||
"debug"
|
||||
})
|
||||
public class CredHubOAuth2TemplateAutoConfigurationTest {
|
||||
@Autowired
|
||||
private CredHubOperations credHubOperations;
|
||||
|
||||
@Autowired
|
||||
@CredHubCredentialsDetails
|
||||
private ClientCredentialsResourceDetails credentialsDetails;
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
assertThat(credHubOperations).isNotNull();
|
||||
assertThat(credHubOperations).isInstanceOf(OAuth2CredHubTemplate.class);
|
||||
|
||||
assertThat(credentialsDetails).isNotNull();
|
||||
assertThat("test-user").isEqualTo(credentialsDetails.getClientId());
|
||||
assertThat("test-secret").isEqualTo(credentialsDetails.getClientSecret());
|
||||
assertThat("https://uaa.example.com/oauth/token").isEqualTo(credentialsDetails.getAccessTokenUri());
|
||||
}
|
||||
|
||||
@SpringBootApplication
|
||||
public static class TestConfig {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.credhub.configuration;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.FilteredClassLoader;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.credhub.autoconfig.CredHubAutoConfiguration;
|
||||
import org.springframework.credhub.autoconfig.CredHubOAuth2TemplateAutoConfiguration;
|
||||
import org.springframework.credhub.autoconfig.CredHubTemplateAutoConfiguration;
|
||||
import org.springframework.credhub.core.CredHubTemplate;
|
||||
import org.springframework.credhub.core.OAuth2CredHubTemplate;
|
||||
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Daniel Lavoie
|
||||
*/
|
||||
public class CredHubOAuth2TemplateAutoConfigurationTests {
|
||||
|
||||
private ApplicationContextRunner context = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(CredHubAutoConfiguration.class,
|
||||
CredHubOAuth2TemplateAutoConfiguration.class,
|
||||
CredHubTemplateAutoConfiguration.class))
|
||||
.withPropertyValues(
|
||||
"spring.credhub.url=https://localhost",
|
||||
"spring.credhub.oauth2.client-id=test-user",
|
||||
"spring.credhub.oauth2.client-secret=test-secret",
|
||||
"spring.credhub.oauth2.access-token-uri=https://uaa.example.com/oauth/token",
|
||||
"debug"
|
||||
);
|
||||
|
||||
@Test
|
||||
public void contextLoadsWithSpringSecurityOAuth2() {
|
||||
context.run((context) -> {
|
||||
assertThat(context).hasSingleBean(OAuth2CredHubTemplate.class);
|
||||
|
||||
assertThat(context).hasSingleBean(ClientCredentialsResourceDetails.class);
|
||||
ClientCredentialsResourceDetails credentialsDetails =
|
||||
context.getBean(ClientCredentialsResourceDetails.class);
|
||||
assertThat(credentialsDetails).isNotNull();
|
||||
assertThat(credentialsDetails.getClientId()).isEqualTo("test-user");
|
||||
assertThat(credentialsDetails.getClientSecret()).isEqualTo("test-secret");
|
||||
assertThat(credentialsDetails.getAccessTokenUri())
|
||||
.isEqualTo("https://uaa.example.com/oauth/token");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void contextLoadsWithoutSpringSecurityOAuth2() {
|
||||
context.withClassLoader(new FilteredClassLoader(ClientCredentialsResourceDetails.class))
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(CredHubTemplate.class);
|
||||
assertThat(context).doesNotHaveBean(OAuth2CredHubTemplate.class);
|
||||
|
||||
assertThat(context).doesNotHaveBean(ClientCredentialsResourceDetails.class);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package org.springframework.credhub.configuration;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.credhub.configuration.CredHubTemplateAutoConfigurationTest.TestConfig;
|
||||
import org.springframework.credhub.core.CredHubTemplate;
|
||||
import org.springframework.credhub.core.OAuth2CredHubTemplate;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Daniel Lavoie
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = TestConfig.class, properties = "spring.credhub.url=http://localhost")
|
||||
public class CredHubTemplateAutoConfigurationTest {
|
||||
@Autowired
|
||||
private CredHubTemplate credHubTemplate;
|
||||
|
||||
@Autowired(required = false)
|
||||
private OAuth2CredHubTemplate oauth2CredHubTemplate;
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
assertThat(credHubTemplate).isNotNull();
|
||||
assertThat(credHubTemplate).isInstanceOf(CredHubTemplate.class);
|
||||
|
||||
assertThat(oauth2CredHubTemplate).isNull();
|
||||
}
|
||||
|
||||
@SpringBootApplication
|
||||
public static class TestConfig {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.credhub.configuration;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.credhub.autoconfig.CredHubAutoConfiguration;
|
||||
import org.springframework.credhub.autoconfig.CredHubOAuth2TemplateAutoConfiguration;
|
||||
import org.springframework.credhub.autoconfig.CredHubTemplateAutoConfiguration;
|
||||
import org.springframework.credhub.core.CredHubTemplate;
|
||||
import org.springframework.credhub.core.OAuth2CredHubTemplate;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Daniel Lavoie
|
||||
*/
|
||||
public class CredHubTemplateAutoConfigurationTests {
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(CredHubAutoConfiguration.class,
|
||||
CredHubOAuth2TemplateAutoConfiguration.class,
|
||||
CredHubTemplateAutoConfiguration.class))
|
||||
.withPropertyValues(
|
||||
"spring.credhub.url=https://localhost",
|
||||
"debug"
|
||||
)
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(CredHubTemplate.class);
|
||||
assertThat(context).doesNotHaveBean(OAuth2CredHubTemplate.class);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user