Migrate tests from JUnit 4 to JUnit 5
This commit is contained in:
14
build.gradle
14
build.gradle
@@ -33,9 +33,9 @@ ext {
|
||||
httpClientVersion = "4.5.13"
|
||||
nettyVersion = "4.1.68.Final"
|
||||
|
||||
junitVersion = "4.12"
|
||||
mockitoVersion = "3.1.0"
|
||||
assertJVersion = "3.6.1"
|
||||
junitVersion = "5.7.2"
|
||||
mockitoVersion = "3.9.0"
|
||||
assertJVersion = "3.19.0"
|
||||
|
||||
javadocLinks = [
|
||||
"https://docs.oracle.com/javase/8/docs/api/",
|
||||
@@ -145,8 +145,12 @@ subprojects {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile("junit:junit:$junitVersion")
|
||||
testCompile("org.mockito:mockito-core:$mockitoVersion")
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,10 @@ dependencies {
|
||||
|
||||
testImplementation("org.springframework:spring-test")
|
||||
testImplementation("io.projectreactor:reactor-test")
|
||||
testImplementation("junit:junit")
|
||||
testImplementation("org.mockito:mockito-core")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-params:${junitVersion}")
|
||||
testImplementation("org.mockito:mockito-core:${mockitoVersion}")
|
||||
testImplementation("org.mockito:mockito-junit-jupiter:${mockitoVersion}")
|
||||
testImplementation("org.assertj:assertj-core:${assertJVersion}")
|
||||
testImplementation("com.jayway.jsonpath:json-path:2.4.0")
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.credhub.configuration;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.ClientOptions;
|
||||
import org.springframework.http.client.reactive.ClientHttpConnector;
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.credhub.configuration;
|
||||
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.credhub.configuration.ClientHttpRequestFactoryFactory.HttpComponents;
|
||||
|
||||
@@ -16,17 +16,17 @@
|
||||
|
||||
package org.springframework.credhub.core;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class CredHubRestTemplateFactoryUnitTests {
|
||||
|
||||
@Mock
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
package org.springframework.credhub.core;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.http.client.reactive.ClientHttpConnector;
|
||||
import org.springframework.security.oauth2.client.registration.ReactiveClientRegistrationRepository;
|
||||
@@ -28,7 +28,7 @@ import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class CredHubWebClientFactoryTests {
|
||||
|
||||
@Mock
|
||||
|
||||
@@ -22,11 +22,11 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.credhub.core.CredHubTemplate;
|
||||
@@ -48,7 +48,7 @@ import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isA;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class CredHubCertificateTemplateUnitTests {
|
||||
|
||||
private static final SimpleCredentialName NAME = new SimpleCredentialName("example", "certificate");
|
||||
@@ -58,7 +58,7 @@ public class CredHubCertificateTemplateUnitTests {
|
||||
|
||||
private CredHubCertificateOperations credHubTemplate;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.credHubTemplate = new CredHubTemplate(this.restTemplate).certificates();
|
||||
}
|
||||
|
||||
@@ -17,12 +17,13 @@
|
||||
package org.springframework.credhub.core.credential;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.experimental.theories.DataPoint;
|
||||
import org.junit.experimental.theories.FromDataPoints;
|
||||
import org.junit.experimental.theories.Theories;
|
||||
import org.junit.experimental.theories.Theory;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.ArgumentsProvider;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
|
||||
import org.springframework.credhub.core.CredHubException;
|
||||
import org.springframework.credhub.support.CredentialSummary;
|
||||
@@ -34,19 +35,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
|
||||
@RunWith(Theories.class)
|
||||
public class CredHubCredentialTemplateSummaryUnitTests extends CredHubCredentialTemplateUnitTestsBase {
|
||||
|
||||
@DataPoint("responses")
|
||||
public static ResponseEntity<CredentialSummaryData> successfulResponse = ResponseEntity.ok()
|
||||
.body(new CredentialSummaryData(new CredentialSummary(NAME)));
|
||||
|
||||
@DataPoint("responses")
|
||||
public static ResponseEntity<CredentialSummaryData> httpErrorResponse = ResponseEntity
|
||||
.status(HttpStatus.UNAUTHORIZED).body(new CredentialSummaryData());
|
||||
|
||||
@Theory
|
||||
public void findByName(@FromDataPoints("responses") ResponseEntity<CredentialSummaryData> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(ResponseArgumentsProvider.class)
|
||||
public void findByName(ResponseEntity<CredentialSummaryData> expectedResponse) {
|
||||
given(this.restTemplate.getForEntity(CredHubCredentialTemplate.NAME_LIKE_URL_QUERY, CredentialSummaryData.class,
|
||||
NAME.getName())).willReturn(expectedResponse);
|
||||
|
||||
@@ -66,8 +59,9 @@ public class CredHubCredentialTemplateSummaryUnitTests extends CredHubCredential
|
||||
}
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void findByPath(@FromDataPoints("responses") ResponseEntity<CredentialSummaryData> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(ResponseArgumentsProvider.class)
|
||||
public void findByPath(ResponseEntity<CredentialSummaryData> expectedResponse) {
|
||||
given(this.restTemplate.getForEntity(CredHubCredentialTemplate.PATH_URL_QUERY, CredentialSummaryData.class,
|
||||
NAME.getName())).willReturn(expectedResponse);
|
||||
|
||||
@@ -94,4 +88,15 @@ public class CredHubCredentialTemplateSummaryUnitTests extends CredHubCredential
|
||||
assertThat(response).contains(expectedResponse.getBody().getCredentials().get(0));
|
||||
}
|
||||
|
||||
static class ResponseArgumentsProvider implements ArgumentsProvider {
|
||||
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
||||
return Stream.of(
|
||||
Arguments.of(ResponseEntity.ok().body(new CredentialSummaryData(new CredentialSummary(NAME)))),
|
||||
Arguments.of(ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(new CredentialSummaryData())));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ package org.springframework.credhub.core.credential;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.credhub.support.CredentialPath;
|
||||
import org.springframework.credhub.support.CredentialPathData;
|
||||
@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class CredHubCredentialTemplateUnitTests extends CredHubCredentialTemplateUnitTestsBase {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,30 +16,29 @@
|
||||
|
||||
package org.springframework.credhub.core.credential;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import org.springframework.credhub.core.CredHubTemplate;
|
||||
import org.springframework.credhub.support.SimpleCredentialName;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.STRICT_STUBS)
|
||||
public abstract class CredHubCredentialTemplateUnitTestsBase {
|
||||
|
||||
protected static final SimpleCredentialName NAME = new SimpleCredentialName("example", "credential");
|
||||
|
||||
@Rule
|
||||
public MockitoRule mockitoRule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS);
|
||||
|
||||
@Mock
|
||||
protected RestTemplate restTemplate;
|
||||
|
||||
protected CredHubCredentialOperations credHubTemplate;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUpCredHubTemplateUnitTests() {
|
||||
this.credHubTemplate = new CredHubTemplate(this.restTemplate).credentials();
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
package org.springframework.credhub.core.credential;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.experimental.theories.DataPoints;
|
||||
import org.junit.experimental.theories.FromDataPoints;
|
||||
import org.junit.experimental.theories.Theories;
|
||||
import org.junit.experimental.theories.Theory;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.ArgumentsProvider;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
|
||||
import org.springframework.credhub.support.CredentialDetails;
|
||||
import org.springframework.credhub.support.CredentialDetailsData;
|
||||
@@ -35,7 +35,6 @@ import org.springframework.credhub.support.certificate.CertificateParameters;
|
||||
import org.springframework.credhub.support.certificate.CertificateParametersRequest;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
@RunWith(Theories.class)
|
||||
public class CredHubTemplateDetailCertificateUnitTests
|
||||
extends CredHubTemplateDetailUnitTestsBase<CertificateCredential, CertificateParameters> {
|
||||
|
||||
@@ -45,16 +44,6 @@ public class CredHubTemplateDetailCertificateUnitTests
|
||||
private static final CertificateParameters PARAMETERS = CertificateParameters.builder().commonName("common")
|
||||
.certificateAuthorityCredential("credential").build();
|
||||
|
||||
@DataPoints("detail-responses")
|
||||
public static List<ResponseEntity<CredentialDetails<CertificateCredential>>> buildDetailResponses() {
|
||||
return buildDetailResponses(CredentialType.CERTIFICATE, CREDENTIAL);
|
||||
}
|
||||
|
||||
@DataPoints("data-responses")
|
||||
public static List<ResponseEntity<CredentialDetailsData<CertificateCredential>>> buildDataResponses() {
|
||||
return buildDataResponses(CredentialType.CERTIFICATE, CREDENTIAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CredentialRequest<CertificateCredential> getWriteRequest() {
|
||||
return CertificateCredentialRequest.builder().name(NAME).value(CREDENTIAL).build();
|
||||
@@ -70,46 +59,64 @@ public class CredHubTemplateDetailCertificateUnitTests
|
||||
return CertificateCredential.class;
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void write(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<CertificateCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void write(ResponseEntity<CredentialDetails<CertificateCredential>> expectedResponse) {
|
||||
verifyWrite(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void generate(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<CertificateCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void generate(ResponseEntity<CredentialDetails<CertificateCredential>> expectedResponse) {
|
||||
verifyGenerate(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void regenerate(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<CertificateCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void regenerate(ResponseEntity<CredentialDetails<CertificateCredential>> expectedResponse) {
|
||||
verifyRegenerate(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getById(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<CertificateCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void getById(ResponseEntity<CredentialDetails<CertificateCredential>> expectedResponse) {
|
||||
verifyGetById(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByName(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<CertificateCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByName(ResponseEntity<CredentialDetailsData<CertificateCredential>> expectedResponse) {
|
||||
verifyGetByName(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByNameWithHistory(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<CertificateCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByNameWithHistory(ResponseEntity<CredentialDetailsData<CertificateCredential>> expectedResponse) {
|
||||
verifyGetByNameWithHistory(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByNameWithVersions(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<CertificateCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByNameWithVersions(ResponseEntity<CredentialDetailsData<CertificateCredential>> expectedResponse) {
|
||||
verifyGetByNameWithVersions(expectedResponse);
|
||||
}
|
||||
|
||||
static class DetailResponseArgumentsProvider implements ArgumentsProvider {
|
||||
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
||||
return buildDetailArguments(CredentialType.CERTIFICATE, CREDENTIAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class DataResponseArgumentsProvider implements ArgumentsProvider {
|
||||
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
||||
return buildDataArguments(CredentialType.CERTIFICATE, CREDENTIAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
package org.springframework.credhub.core.credential;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.experimental.theories.DataPoints;
|
||||
import org.junit.experimental.theories.FromDataPoints;
|
||||
import org.junit.experimental.theories.Theories;
|
||||
import org.junit.experimental.theories.Theory;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.ArgumentsProvider;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
|
||||
import org.springframework.credhub.support.CredentialDetails;
|
||||
import org.springframework.credhub.support.CredentialDetailsData;
|
||||
@@ -32,7 +32,6 @@ import org.springframework.credhub.support.json.JsonCredential;
|
||||
import org.springframework.credhub.support.json.JsonCredentialRequest;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
@RunWith(Theories.class)
|
||||
public class CredHubTemplateDetailJsonUnitTests extends CredHubTemplateDetailUnitTestsBase<JsonCredential, Void> {
|
||||
|
||||
private static final JsonCredential CREDENTIAL = new JsonCredential() {
|
||||
@@ -42,16 +41,6 @@ public class CredHubTemplateDetailJsonUnitTests extends CredHubTemplateDetailUni
|
||||
}
|
||||
};
|
||||
|
||||
@DataPoints("detail-responses")
|
||||
public static List<ResponseEntity<CredentialDetails<JsonCredential>>> buildDetailResponses() {
|
||||
return buildDetailResponses(CredentialType.JSON, CREDENTIAL);
|
||||
}
|
||||
|
||||
@DataPoints("data-responses")
|
||||
public static List<ResponseEntity<CredentialDetailsData<JsonCredential>>> buildDataResponses() {
|
||||
return buildDataResponses(CredentialType.JSON, CREDENTIAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CredentialRequest<JsonCredential> getWriteRequest() {
|
||||
return JsonCredentialRequest.builder().name(NAME).value(CREDENTIAL).build();
|
||||
@@ -62,34 +51,52 @@ public class CredHubTemplateDetailJsonUnitTests extends CredHubTemplateDetailUni
|
||||
return JsonCredential.class;
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void write(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<JsonCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void write(ResponseEntity<CredentialDetails<JsonCredential>> expectedResponse) {
|
||||
verifyWrite(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getById(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<JsonCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void getById(ResponseEntity<CredentialDetails<JsonCredential>> expectedResponse) {
|
||||
verifyGetById(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByName(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<JsonCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByName(ResponseEntity<CredentialDetailsData<JsonCredential>> expectedResponse) {
|
||||
verifyGetByName(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByNameWithHistory(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<JsonCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByNameWithHistory(ResponseEntity<CredentialDetailsData<JsonCredential>> expectedResponse) {
|
||||
verifyGetByNameWithHistory(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByNameWithVersions(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<JsonCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByNameWithVersions(ResponseEntity<CredentialDetailsData<JsonCredential>> expectedResponse) {
|
||||
verifyGetByNameWithVersions(expectedResponse);
|
||||
}
|
||||
|
||||
static class DetailResponseArgumentsProvider implements ArgumentsProvider {
|
||||
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
||||
return buildDetailArguments(CredentialType.JSON, CREDENTIAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class DataResponseArgumentsProvider implements ArgumentsProvider {
|
||||
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
||||
return buildDataArguments(CredentialType.JSON, CREDENTIAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
package org.springframework.credhub.core.credential;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.experimental.theories.DataPoints;
|
||||
import org.junit.experimental.theories.FromDataPoints;
|
||||
import org.junit.experimental.theories.Theories;
|
||||
import org.junit.experimental.theories.Theory;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.ArgumentsProvider;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
|
||||
import org.springframework.credhub.support.CredentialDetails;
|
||||
import org.springframework.credhub.support.CredentialDetailsData;
|
||||
@@ -35,7 +35,6 @@ import org.springframework.credhub.support.password.PasswordParameters;
|
||||
import org.springframework.credhub.support.password.PasswordParametersRequest;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
@RunWith(Theories.class)
|
||||
public class CredHubTemplateDetailPasswordUnitTests
|
||||
extends CredHubTemplateDetailUnitTestsBase<PasswordCredential, PasswordParameters> {
|
||||
|
||||
@@ -43,16 +42,6 @@ public class CredHubTemplateDetailPasswordUnitTests
|
||||
|
||||
private static final PasswordParameters PARAMETERS = new PasswordParameters();
|
||||
|
||||
@DataPoints("detail-responses")
|
||||
public static List<ResponseEntity<CredentialDetails<PasswordCredential>>> buildDetailResponses() {
|
||||
return buildDetailResponses(CredentialType.PASSWORD, CREDENTIAL);
|
||||
}
|
||||
|
||||
@DataPoints("data-responses")
|
||||
public static List<ResponseEntity<CredentialDetailsData<PasswordCredential>>> buildDataResponses() {
|
||||
return buildDataResponses(CredentialType.PASSWORD, CREDENTIAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CredentialRequest<PasswordCredential> getWriteRequest() {
|
||||
return PasswordCredentialRequest.builder().name(NAME).value(CREDENTIAL).build();
|
||||
@@ -68,46 +57,64 @@ public class CredHubTemplateDetailPasswordUnitTests
|
||||
return PasswordCredential.class;
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void write(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<PasswordCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void write(ResponseEntity<CredentialDetails<PasswordCredential>> expectedResponse) {
|
||||
verifyWrite(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void generate(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<PasswordCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void generate(ResponseEntity<CredentialDetails<PasswordCredential>> expectedResponse) {
|
||||
verifyGenerate(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void regenerate(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<PasswordCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void regenerate(ResponseEntity<CredentialDetails<PasswordCredential>> expectedResponse) {
|
||||
verifyRegenerate(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getById(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<PasswordCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void getById(ResponseEntity<CredentialDetails<PasswordCredential>> expectedResponse) {
|
||||
verifyGetById(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByName(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<PasswordCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByName(ResponseEntity<CredentialDetailsData<PasswordCredential>> expectedResponse) {
|
||||
verifyGetByName(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByNameWithHistory(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<PasswordCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByNameWithHistory(ResponseEntity<CredentialDetailsData<PasswordCredential>> expectedResponse) {
|
||||
verifyGetByNameWithHistory(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByNameWithVersions(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<PasswordCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByNameWithVersions(ResponseEntity<CredentialDetailsData<PasswordCredential>> expectedResponse) {
|
||||
verifyGetByNameWithVersions(expectedResponse);
|
||||
}
|
||||
|
||||
static class DetailResponseArgumentsProvider implements ArgumentsProvider {
|
||||
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
||||
return buildDetailArguments(CredentialType.PASSWORD, CREDENTIAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class DataResponseArgumentsProvider implements ArgumentsProvider {
|
||||
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
||||
return buildDataArguments(CredentialType.PASSWORD, CREDENTIAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
package org.springframework.credhub.core.credential;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.experimental.theories.DataPoints;
|
||||
import org.junit.experimental.theories.FromDataPoints;
|
||||
import org.junit.experimental.theories.Theories;
|
||||
import org.junit.experimental.theories.Theory;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.ArgumentsProvider;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
|
||||
import org.springframework.credhub.support.CredentialDetails;
|
||||
import org.springframework.credhub.support.CredentialDetailsData;
|
||||
@@ -36,7 +36,6 @@ import org.springframework.credhub.support.rsa.RsaParameters;
|
||||
import org.springframework.credhub.support.rsa.RsaParametersRequest;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
@RunWith(Theories.class)
|
||||
public class CredHubTemplateDetailRsaUnitTests
|
||||
extends CredHubTemplateDetailUnitTestsBase<RsaCredential, RsaParameters> {
|
||||
|
||||
@@ -44,16 +43,6 @@ public class CredHubTemplateDetailRsaUnitTests
|
||||
|
||||
private static final RsaParameters PARAMETERS = new RsaParameters(KeyLength.LENGTH_4096);
|
||||
|
||||
@DataPoints("detail-responses")
|
||||
public static List<ResponseEntity<CredentialDetails<RsaCredential>>> buildDetailResponses() {
|
||||
return buildDetailResponses(CredentialType.RSA, CREDENTIAL);
|
||||
}
|
||||
|
||||
@DataPoints("data-responses")
|
||||
public static List<ResponseEntity<CredentialDetailsData<RsaCredential>>> buildDataResponses() {
|
||||
return buildDataResponses(CredentialType.RSA, CREDENTIAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CredentialRequest<RsaCredential> getWriteRequest() {
|
||||
return RsaCredentialRequest.builder().name(NAME).value(CREDENTIAL).build();
|
||||
@@ -69,46 +58,64 @@ public class CredHubTemplateDetailRsaUnitTests
|
||||
return RsaCredential.class;
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void write(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<RsaCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void write(ResponseEntity<CredentialDetails<RsaCredential>> expectedResponse) {
|
||||
verifyWrite(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void generate(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<RsaCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void generate(ResponseEntity<CredentialDetails<RsaCredential>> expectedResponse) {
|
||||
verifyGenerate(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void regenerate(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<RsaCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void regenerate(ResponseEntity<CredentialDetails<RsaCredential>> expectedResponse) {
|
||||
verifyRegenerate(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getById(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<RsaCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void getById(ResponseEntity<CredentialDetails<RsaCredential>> expectedResponse) {
|
||||
verifyGetById(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByName(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<RsaCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByName(ResponseEntity<CredentialDetailsData<RsaCredential>> expectedResponse) {
|
||||
verifyGetByName(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByNameWithHistory(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<RsaCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByNameWithHistory(ResponseEntity<CredentialDetailsData<RsaCredential>> expectedResponse) {
|
||||
verifyGetByNameWithHistory(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByNameWithVersions(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<RsaCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByNameWithVersions(ResponseEntity<CredentialDetailsData<RsaCredential>> expectedResponse) {
|
||||
verifyGetByNameWithVersions(expectedResponse);
|
||||
}
|
||||
|
||||
static class DetailResponseArgumentsProvider implements ArgumentsProvider {
|
||||
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
||||
return buildDetailArguments(CredentialType.RSA, CREDENTIAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class DataResponseArgumentsProvider implements ArgumentsProvider {
|
||||
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
||||
return buildDataArguments(CredentialType.RSA, CREDENTIAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
package org.springframework.credhub.core.credential;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.experimental.theories.DataPoints;
|
||||
import org.junit.experimental.theories.FromDataPoints;
|
||||
import org.junit.experimental.theories.Theories;
|
||||
import org.junit.experimental.theories.Theory;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.ArgumentsProvider;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
|
||||
import org.springframework.credhub.support.CredentialDetails;
|
||||
import org.springframework.credhub.support.CredentialDetailsData;
|
||||
@@ -36,7 +36,6 @@ import org.springframework.credhub.support.ssh.SshParameters;
|
||||
import org.springframework.credhub.support.ssh.SshParametersRequest;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
@RunWith(Theories.class)
|
||||
public class CredHubTemplateDetailSshUnitTests
|
||||
extends CredHubTemplateDetailUnitTestsBase<SshCredential, SshParameters> {
|
||||
|
||||
@@ -44,16 +43,6 @@ public class CredHubTemplateDetailSshUnitTests
|
||||
|
||||
private static final SshParameters PARAMETERS = new SshParameters(KeyLength.LENGTH_2048, "comment");
|
||||
|
||||
@DataPoints("detail-responses")
|
||||
public static List<ResponseEntity<CredentialDetails<SshCredential>>> buildDetailResponses() {
|
||||
return buildDetailResponses(CredentialType.SSH, CREDENTIAL);
|
||||
}
|
||||
|
||||
@DataPoints("data-responses")
|
||||
public static List<ResponseEntity<CredentialDetailsData<SshCredential>>> buildDataResponses() {
|
||||
return buildDataResponses(CredentialType.SSH, CREDENTIAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CredentialRequest<SshCredential> getWriteRequest() {
|
||||
return SshCredentialRequest.builder().name(NAME).value(CREDENTIAL).build();
|
||||
@@ -69,46 +58,64 @@ public class CredHubTemplateDetailSshUnitTests
|
||||
return SshCredential.class;
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void write(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<SshCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void write(ResponseEntity<CredentialDetails<SshCredential>> expectedResponse) {
|
||||
verifyWrite(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void generate(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<SshCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void generate(ResponseEntity<CredentialDetails<SshCredential>> expectedResponse) {
|
||||
verifyGenerate(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void regenerate(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<SshCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void regenerate(ResponseEntity<CredentialDetails<SshCredential>> expectedResponse) {
|
||||
verifyRegenerate(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getById(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<SshCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void getById(ResponseEntity<CredentialDetails<SshCredential>> expectedResponse) {
|
||||
verifyGetById(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByName(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<SshCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByName(ResponseEntity<CredentialDetailsData<SshCredential>> expectedResponse) {
|
||||
verifyGetByName(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByNameWithHistory(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<SshCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByNameWithHistory(ResponseEntity<CredentialDetailsData<SshCredential>> expectedResponse) {
|
||||
verifyGetByNameWithHistory(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByNameWithVersions(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<SshCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByNameWithVersions(ResponseEntity<CredentialDetailsData<SshCredential>> expectedResponse) {
|
||||
verifyGetByNameWithVersions(expectedResponse);
|
||||
}
|
||||
|
||||
static class DetailResponseArgumentsProvider implements ArgumentsProvider {
|
||||
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
||||
return buildDetailArguments(CredentialType.CERTIFICATE, CREDENTIAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class DataResponseArgumentsProvider implements ArgumentsProvider {
|
||||
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
||||
return buildDataArguments(CredentialType.CERTIFICATE, CREDENTIAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,9 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.credhub.core.CredHubException;
|
||||
@@ -53,6 +56,19 @@ public abstract class CredHubTemplateDetailUnitTestsBase<T, P> extends CredHubCr
|
||||
throw new IllegalStateException("Tests that verify credential generation must override this method");
|
||||
}
|
||||
|
||||
static <T> Stream<? extends Arguments> buildDetailArguments(CredentialType type, T credential) {
|
||||
return Stream.of(
|
||||
Arguments.of(ResponseEntity.ok().body(new CredentialDetails<>(CREDENTIAL_ID, NAME, type, credential))),
|
||||
Arguments.of(ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(new CredentialDetails<>())));
|
||||
}
|
||||
|
||||
static <T> Stream<? extends Arguments> buildDataArguments(CredentialType type, T credential) {
|
||||
return Stream.of(
|
||||
Arguments.of(ResponseEntity.ok().body(
|
||||
new CredentialDetailsData<>(new CredentialDetails<>(CREDENTIAL_ID, NAME, type, credential)))),
|
||||
Arguments.of(ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(new CredentialDetailsData<>())));
|
||||
}
|
||||
|
||||
static <T> List<ResponseEntity<CredentialDetails<T>>> buildDetailResponses(CredentialType type, T credential) {
|
||||
return Arrays.asList(ResponseEntity.ok().body(new CredentialDetails<>(CREDENTIAL_ID, NAME, type, credential)),
|
||||
ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(new CredentialDetails<>()));
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
package org.springframework.credhub.core.credential;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.experimental.theories.DataPoints;
|
||||
import org.junit.experimental.theories.FromDataPoints;
|
||||
import org.junit.experimental.theories.Theories;
|
||||
import org.junit.experimental.theories.Theory;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.ArgumentsProvider;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
|
||||
import org.springframework.credhub.support.CredentialDetails;
|
||||
import org.springframework.credhub.support.CredentialDetailsData;
|
||||
@@ -32,21 +32,10 @@ import org.springframework.credhub.support.user.UserCredential;
|
||||
import org.springframework.credhub.support.user.UserCredentialRequest;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
@RunWith(Theories.class)
|
||||
public class CredHubTemplateDetailUserUnitTests extends CredHubTemplateDetailUnitTestsBase<UserCredential, Void> {
|
||||
|
||||
private static final UserCredential CREDENTIAL = new UserCredential("myname", "secret");
|
||||
|
||||
@DataPoints("detail-responses")
|
||||
public static List<ResponseEntity<CredentialDetails<UserCredential>>> buildDetailResponses() {
|
||||
return buildDetailResponses(CredentialType.USER, CREDENTIAL);
|
||||
}
|
||||
|
||||
@DataPoints("data-responses")
|
||||
public static List<ResponseEntity<CredentialDetailsData<UserCredential>>> buildDataResponses() {
|
||||
return buildDataResponses(CredentialType.USER, CREDENTIAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CredentialRequest<UserCredential> getWriteRequest() {
|
||||
return UserCredentialRequest.builder().name(NAME).value(CREDENTIAL).build();
|
||||
@@ -57,34 +46,52 @@ public class CredHubTemplateDetailUserUnitTests extends CredHubTemplateDetailUni
|
||||
return UserCredential.class;
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void write(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<UserCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void write(ResponseEntity<CredentialDetails<UserCredential>> expectedResponse) {
|
||||
verifyWrite(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getById(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<UserCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void getById(ResponseEntity<CredentialDetails<UserCredential>> expectedResponse) {
|
||||
verifyGetById(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByName(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<UserCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByName(ResponseEntity<CredentialDetailsData<UserCredential>> expectedResponse) {
|
||||
verifyGetByName(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByNameWithHistory(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<UserCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByNameWithHistory(ResponseEntity<CredentialDetailsData<UserCredential>> expectedResponse) {
|
||||
verifyGetByNameWithHistory(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByNameWithVersions(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<UserCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByNameWithVersions(ResponseEntity<CredentialDetailsData<UserCredential>> expectedResponse) {
|
||||
verifyGetByNameWithVersions(expectedResponse);
|
||||
}
|
||||
|
||||
static class DetailResponseArgumentsProvider implements ArgumentsProvider {
|
||||
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
||||
return buildDetailArguments(CredentialType.USER, CREDENTIAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class DataResponseArgumentsProvider implements ArgumentsProvider {
|
||||
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
||||
return buildDataArguments(CredentialType.USER, CREDENTIAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
package org.springframework.credhub.core.credential;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.experimental.theories.DataPoints;
|
||||
import org.junit.experimental.theories.FromDataPoints;
|
||||
import org.junit.experimental.theories.Theories;
|
||||
import org.junit.experimental.theories.Theory;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.ArgumentsProvider;
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
|
||||
import org.springframework.credhub.support.CredentialDetails;
|
||||
import org.springframework.credhub.support.CredentialDetailsData;
|
||||
@@ -32,21 +32,10 @@ import org.springframework.credhub.support.value.ValueCredential;
|
||||
import org.springframework.credhub.support.value.ValueCredentialRequest;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
@RunWith(Theories.class)
|
||||
public class CredHubTemplateDetailValueUnitTests extends CredHubTemplateDetailUnitTestsBase<ValueCredential, Void> {
|
||||
|
||||
private static final ValueCredential CREDENTIAL = new ValueCredential("secret");
|
||||
|
||||
@DataPoints("detail-responses")
|
||||
public static List<ResponseEntity<CredentialDetails<ValueCredential>>> buildDetailResponses() {
|
||||
return buildDetailResponses(CredentialType.VALUE, CREDENTIAL);
|
||||
}
|
||||
|
||||
@DataPoints("data-responses")
|
||||
public static List<ResponseEntity<CredentialDetailsData<ValueCredential>>> buildDataResponses() {
|
||||
return buildDataResponses(CredentialType.VALUE, CREDENTIAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CredentialRequest<ValueCredential> getWriteRequest() {
|
||||
return ValueCredentialRequest.builder().name(NAME).value(CREDENTIAL).build();
|
||||
@@ -57,34 +46,52 @@ public class CredHubTemplateDetailValueUnitTests extends CredHubTemplateDetailUn
|
||||
return ValueCredential.class;
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void write(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<ValueCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void write(ResponseEntity<CredentialDetails<ValueCredential>> expectedResponse) {
|
||||
verifyWrite(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getById(
|
||||
@FromDataPoints("detail-responses") ResponseEntity<CredentialDetails<ValueCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DetailResponseArgumentsProvider.class)
|
||||
public void getById(ResponseEntity<CredentialDetails<ValueCredential>> expectedResponse) {
|
||||
verifyGetById(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByName(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<ValueCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByName(ResponseEntity<CredentialDetailsData<ValueCredential>> expectedResponse) {
|
||||
verifyGetByName(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByNameWithHistory(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<ValueCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByNameWithHistory(ResponseEntity<CredentialDetailsData<ValueCredential>> expectedResponse) {
|
||||
verifyGetByNameWithHistory(expectedResponse);
|
||||
}
|
||||
|
||||
@Theory
|
||||
public void getByNameWithVersions(
|
||||
@FromDataPoints("data-responses") ResponseEntity<CredentialDetailsData<ValueCredential>> expectedResponse) {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(DataResponseArgumentsProvider.class)
|
||||
public void getByNameWithVersions(ResponseEntity<CredentialDetailsData<ValueCredential>> expectedResponse) {
|
||||
verifyGetByNameWithVersions(expectedResponse);
|
||||
}
|
||||
|
||||
static class DetailResponseArgumentsProvider implements ArgumentsProvider {
|
||||
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
||||
return buildDetailArguments(CredentialType.VALUE, CREDENTIAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class DataResponseArgumentsProvider implements ArgumentsProvider {
|
||||
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
||||
return buildDataArguments(CredentialType.VALUE, CREDENTIAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,14 +16,12 @@
|
||||
|
||||
package org.springframework.credhub.core.info;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import org.springframework.credhub.core.CredHubTemplate;
|
||||
@@ -35,18 +33,16 @@ import org.springframework.web.client.RestTemplate;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.STRICT_STUBS)
|
||||
public class CredHubInfoTemplateUnitTests {
|
||||
|
||||
@Rule
|
||||
public MockitoRule mockitoRule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS);
|
||||
|
||||
@Mock
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
private CredHubInfoOperations credHubTemplate;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.credHubTemplate = new CredHubTemplate(this.restTemplate).info();
|
||||
}
|
||||
|
||||
@@ -19,14 +19,12 @@ package org.springframework.credhub.core.interpolation;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import org.springframework.credhub.core.CredHubTemplate;
|
||||
@@ -42,18 +40,16 @@ import org.springframework.web.client.RestTemplate;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.STRICT_STUBS)
|
||||
public class CredHubInterpolationTemplateUnitTests {
|
||||
|
||||
@Rule
|
||||
public MockitoRule mockitoRule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS);
|
||||
|
||||
@Mock
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
private CredHubInterpolationOperations credHubTemplate;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.credHubTemplate = new CredHubTemplate(this.restTemplate).interpolation();
|
||||
}
|
||||
|
||||
@@ -18,11 +18,13 @@ package org.springframework.credhub.core.permission;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import org.springframework.credhub.core.CredHubTemplate;
|
||||
import org.springframework.credhub.support.CredentialPermissions;
|
||||
@@ -41,7 +43,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.STRICT_STUBS)
|
||||
public class CredHubPermissionTemplateUnitTests {
|
||||
|
||||
private static final SimpleCredentialName NAME = new SimpleCredentialName("example", "credential");
|
||||
@@ -51,7 +54,7 @@ public class CredHubPermissionTemplateUnitTests {
|
||||
|
||||
private CredHubPermissionOperations credHubTemplate;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.credHubTemplate = new CredHubTemplate(this.restTemplate).permissions();
|
||||
}
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
package org.springframework.credhub.core.permissionV2;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.credhub.core.CredHubTemplate;
|
||||
import org.springframework.credhub.support.CredentialPermission;
|
||||
@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class CredHubPermissionV2TemplateUnitTests {
|
||||
|
||||
private static final SimpleCredentialName PATH = new SimpleCredentialName("example", "credential", "*");
|
||||
@@ -49,7 +49,7 @@ public class CredHubPermissionV2TemplateUnitTests {
|
||||
|
||||
private CredHubPermissionV2Operations credHubTemplate;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.credHubTemplate = new CredHubTemplate(this.restTemplate).permissionsV2();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.credhub.support;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.certificate.CertificateSummaryData;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.credhub.support;
|
||||
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredHubRequest.CredHubRequestBuilder;
|
||||
import org.springframework.credhub.support.permissions.Actor;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.credhub.support;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.credhub.support;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.credhub.support;
|
||||
import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
||||
import org.junit.Before;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -46,7 +46,7 @@ public abstract class JsonParsingUnitTestsBase {
|
||||
|
||||
Date testDate;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUpJsonParsing() throws Exception {
|
||||
this.testDate = new StdDateFormat().parse(TEST_DATE_STRING);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.credhub.support;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.credhub.support;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.credhub.support.certificate;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredentialDetails;
|
||||
import org.springframework.credhub.support.CredentialDetailsData;
|
||||
|
||||
@@ -17,17 +17,19 @@
|
||||
package org.springframework.credhub.support.certificate;
|
||||
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredHubRequestUnitTestsBase;
|
||||
import org.springframework.credhub.support.JsonPathAssert;
|
||||
import org.springframework.credhub.support.SimpleCredentialName;
|
||||
import org.springframework.credhub.support.WriteMode;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
public class CertificateCredentialRequestUnitTests extends CredHubRequestUnitTestsBase {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
buildRequest(new CertificateCredential("cert", "ca", "private-key"));
|
||||
}
|
||||
@@ -71,11 +73,13 @@ public class CertificateCredentialRequestUnitTests extends CredHubRequestUnitTes
|
||||
assertNoPermissions(json);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void serializeWithNoValues() {
|
||||
buildRequest(new CertificateCredential(null, null, null));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> {
|
||||
buildRequest(new CertificateCredential(null, null, null));
|
||||
|
||||
toJsonPath(this.requestBuilder);
|
||||
toJsonPath(this.requestBuilder);
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.credhub.support.certificate;
|
||||
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredHubRequestUnitTestsBase;
|
||||
import org.springframework.credhub.support.JsonPathAssert;
|
||||
@@ -26,10 +26,12 @@ import org.springframework.credhub.support.KeyLength;
|
||||
import org.springframework.credhub.support.SimpleCredentialName;
|
||||
import org.springframework.credhub.support.WriteMode;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class CertificateParametersRequestUnitTests extends CredHubRequestUnitTestsBase {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.requestBuilder = CertificateParametersRequest.builder();
|
||||
}
|
||||
@@ -132,13 +134,15 @@ public class CertificateParametersRequestUnitTests extends CredHubRequestUnitTes
|
||||
assertParametersNotSet(json);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void serializeWithEmptyParameters() {
|
||||
this.requestBuilder = CertificateParametersRequest.builder()
|
||||
.name(new SimpleCredentialName("example", "credential")).overwrite(true)
|
||||
.parameters(CertificateParameters.builder().keyLength(KeyLength.LENGTH_2048).build());
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> {
|
||||
this.requestBuilder = CertificateParametersRequest.builder()
|
||||
.name(new SimpleCredentialName("example", "credential")).overwrite(true)
|
||||
.parameters(CertificateParameters.builder().keyLength(KeyLength.LENGTH_2048).build());
|
||||
|
||||
toJsonPath(this.requestBuilder);
|
||||
toJsonPath(this.requestBuilder);
|
||||
});
|
||||
}
|
||||
|
||||
private void assertParametersNotSet(DocumentContext json) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.credhub.support.info;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.JsonParsingUnitTestsBase;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.credhub.support.json;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredentialDetails;
|
||||
import org.springframework.credhub.support.CredentialDetailsData;
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.credhub.support.json;
|
||||
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredHubRequestUnitTestsBase;
|
||||
import org.springframework.credhub.support.JsonPathAssert;
|
||||
@@ -27,7 +27,7 @@ import org.springframework.credhub.support.WriteMode;
|
||||
|
||||
public class JsonCredentialRequestUnitTests extends CredHubRequestUnitTestsBase {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.requestBuilder = JsonCredentialRequest.builder().name(new SimpleCredentialName("example", "credential"))
|
||||
.value(new JsonCredential() {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.credhub.support.password;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredentialDetails;
|
||||
import org.springframework.credhub.support.CredentialDetailsData;
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.credhub.support.password;
|
||||
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredHubRequestUnitTestsBase;
|
||||
import org.springframework.credhub.support.JsonPathAssert;
|
||||
@@ -28,7 +28,7 @@ import org.springframework.credhub.support.WriteMode;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class PasswordCredentialRequestUnitTests extends CredHubRequestUnitTestsBase {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.requestBuilder = PasswordCredentialRequest.builder()
|
||||
.name(new SimpleCredentialName("example", "credential")).overwrite(true).mode(WriteMode.OVERWRITE)
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.credhub.support.password;
|
||||
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredHubRequestUnitTestsBase;
|
||||
import org.springframework.credhub.support.JsonPathAssert;
|
||||
@@ -28,7 +28,7 @@ import org.springframework.credhub.support.WriteMode;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class PasswordParametersRequestUnitTests extends CredHubRequestUnitTestsBase {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.requestBuilder = PasswordParametersRequest.builder();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.credhub.support.permissions;
|
||||
import java.util.List;
|
||||
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredentialPermission;
|
||||
import org.springframework.credhub.support.JsonParsingUnitTestsBase;
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.credhub.support.permissions;
|
||||
import java.util.List;
|
||||
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredentialPermissions;
|
||||
import org.springframework.credhub.support.JsonParsingUnitTestsBase;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.credhub.support.rsa;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredentialDetails;
|
||||
import org.springframework.credhub.support.CredentialDetailsData;
|
||||
|
||||
@@ -17,17 +17,19 @@
|
||||
package org.springframework.credhub.support.rsa;
|
||||
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredHubRequestUnitTestsBase;
|
||||
import org.springframework.credhub.support.JsonPathAssert;
|
||||
import org.springframework.credhub.support.SimpleCredentialName;
|
||||
import org.springframework.credhub.support.WriteMode;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
public class RsaCredentialRequestUnitTests extends CredHubRequestUnitTestsBase {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
buildRequest(new RsaCredential("public-key", "private-key"));
|
||||
}
|
||||
@@ -70,11 +72,13 @@ public class RsaCredentialRequestUnitTests extends CredHubRequestUnitTestsBase {
|
||||
assertNoPermissions(json);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void serializeWithNeitherKey() {
|
||||
buildRequest(new RsaCredential(null, null));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> {
|
||||
buildRequest(new RsaCredential(null, null));
|
||||
|
||||
toJsonPath(this.requestBuilder);
|
||||
toJsonPath(this.requestBuilder);
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.credhub.support.rsa;
|
||||
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredHubRequestUnitTestsBase;
|
||||
import org.springframework.credhub.support.JsonPathAssert;
|
||||
@@ -29,7 +29,7 @@ import org.springframework.credhub.support.WriteMode;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class RsaParametersRequestUnitTests extends CredHubRequestUnitTestsBase {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.requestBuilder = RsaParametersRequest.builder();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.credhub.support.ssh;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredentialDetails;
|
||||
import org.springframework.credhub.support.CredentialDetailsData;
|
||||
|
||||
@@ -17,17 +17,19 @@
|
||||
package org.springframework.credhub.support.ssh;
|
||||
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredHubRequestUnitTestsBase;
|
||||
import org.springframework.credhub.support.JsonPathAssert;
|
||||
import org.springframework.credhub.support.SimpleCredentialName;
|
||||
import org.springframework.credhub.support.WriteMode;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
public class SshCredentialRequestUnitTests extends CredHubRequestUnitTestsBase {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
buildRequest(new SshCredential("public-key", "private-key"));
|
||||
}
|
||||
@@ -69,11 +71,13 @@ public class SshCredentialRequestUnitTests extends CredHubRequestUnitTestsBase {
|
||||
assertNoPermissions(json);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void serializeWithNeitherKey() {
|
||||
buildRequest(new SshCredential(null, null));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> {
|
||||
buildRequest(new SshCredential(null, null));
|
||||
|
||||
toJsonPath(this.requestBuilder);
|
||||
toJsonPath(this.requestBuilder);
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.credhub.support.ssh;
|
||||
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredHubRequestUnitTestsBase;
|
||||
import org.springframework.credhub.support.JsonPathAssert;
|
||||
@@ -29,7 +29,7 @@ import org.springframework.credhub.support.WriteMode;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class SshParametersRequestUnitTests extends CredHubRequestUnitTestsBase {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.requestBuilder = SshParametersRequest.builder();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.credhub.support.user;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredentialDetails;
|
||||
import org.springframework.credhub.support.CredentialDetailsData;
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.credhub.support.user;
|
||||
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredHubRequestUnitTestsBase;
|
||||
import org.springframework.credhub.support.JsonPathAssert;
|
||||
@@ -29,7 +29,7 @@ import org.springframework.credhub.support.user.UserCredentialRequest.UserCreden
|
||||
@SuppressWarnings("deprecation")
|
||||
public class UserCredentialRequestUnitTests extends CredHubRequestUnitTestsBase {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.requestBuilder = UserCredentialRequest.builder().name(new SimpleCredentialName("example", "credential"))
|
||||
.overwrite(true).mode(WriteMode.OVERWRITE).value(new UserCredential("myname", "secret"));
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.credhub.support.user;
|
||||
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredHubRequestUnitTestsBase;
|
||||
import org.springframework.credhub.support.JsonPathAssert;
|
||||
@@ -29,7 +29,7 @@ import org.springframework.credhub.support.password.PasswordParameters;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class UserParametersRequestUnitTests extends CredHubRequestUnitTestsBase {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.requestBuilder = UserParametersRequest.builder();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.credhub.support.value;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredentialDetails;
|
||||
import org.springframework.credhub.support.CredentialDetailsData;
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.credhub.support.value;
|
||||
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.support.CredHubRequestUnitTestsBase;
|
||||
import org.springframework.credhub.support.JsonPathAssert;
|
||||
@@ -26,7 +26,7 @@ import org.springframework.credhub.support.SimpleCredentialName;
|
||||
|
||||
public class ValueCredentialRequestUnitTests extends CredHubRequestUnitTestsBase {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setUp() {
|
||||
this.requestBuilder = ValueCredentialRequest.builder().name(new SimpleCredentialName("example", "credential"))
|
||||
|
||||
@@ -48,8 +48,9 @@ dependencies {
|
||||
compile("org.apache.httpcomponents:httpclient")
|
||||
}
|
||||
|
||||
testCompile("org.springframework.boot:spring-boot-starter-test")
|
||||
testCompile("org.assertj:assertj-core")
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
|
||||
testImplementation("org.assertj:assertj-core:${assertJVersion}")
|
||||
}
|
||||
|
||||
test {
|
||||
|
||||
@@ -18,9 +18,9 @@ package org.springframework.credhub.integration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.core.certificate.CredHubCertificateOperations;
|
||||
import org.springframework.credhub.core.credential.CredHubCredentialOperations;
|
||||
@@ -35,7 +35,7 @@ import org.springframework.credhub.support.certificate.CertificateParametersRequ
|
||||
import org.springframework.credhub.support.certificate.CertificateSummary;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||
|
||||
public class CertificateIntegrationTests extends CredHubIntegrationTests {
|
||||
|
||||
@@ -49,7 +49,7 @@ public class CertificateIntegrationTests extends CredHubIntegrationTests {
|
||||
|
||||
private CredHubCertificateOperations certificates;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.credentials = this.operations.credentials();
|
||||
this.certificates = this.operations.certificates();
|
||||
@@ -58,7 +58,7 @@ public class CertificateIntegrationTests extends CredHubIntegrationTests {
|
||||
deleteCredentialIfExists(ROOT_CERT_NAME);
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
deleteCredentialIfExists(TEST_CERT_NAME);
|
||||
deleteCredentialIfExists(ROOT_CERT_NAME);
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.credhub.integration;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -27,10 +26,8 @@ import org.springframework.credhub.core.CredHubOperations;
|
||||
import org.springframework.credhub.support.CredentialName;
|
||||
import org.springframework.credhub.support.info.VersionInfo;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = { TestApplication.class })
|
||||
@ActiveProfiles("test")
|
||||
public abstract class CredHubIntegrationTests {
|
||||
@@ -43,7 +40,7 @@ public abstract class CredHubIntegrationTests {
|
||||
@Autowired
|
||||
protected CredHubOperations operations;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setupVersionInfo() {
|
||||
if (StringUtils.hasText(this.serverVersion)) {
|
||||
this.versionInfo = new VersionInfo(this.serverVersion);
|
||||
|
||||
@@ -18,9 +18,9 @@ package org.springframework.credhub.integration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.core.credential.CredHubCredentialOperations;
|
||||
import org.springframework.credhub.support.CredentialDetails;
|
||||
@@ -35,7 +35,7 @@ import org.springframework.credhub.support.value.ValueCredential;
|
||||
import org.springframework.credhub.support.value.ValueCredentialRequest;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||
|
||||
public class CredentialIntegrationTests extends CredHubIntegrationTests {
|
||||
|
||||
@@ -48,7 +48,7 @@ public class CredentialIntegrationTests extends CredHubIntegrationTests {
|
||||
|
||||
private PasswordParameters.PasswordParametersBuilder passwordParameters;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.credentials = this.operations.credentials();
|
||||
|
||||
@@ -58,7 +58,7 @@ public class CredentialIntegrationTests extends CredHubIntegrationTests {
|
||||
deleteCredentialIfExists(CREDENTIAL_NAME);
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
deleteCredentialIfExists(CREDENTIAL_NAME);
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.credhub.integration;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.core.info.CredHubInfoOperations;
|
||||
import org.springframework.credhub.support.info.VersionInfo;
|
||||
@@ -28,7 +28,7 @@ public class InfoIntegrationTests extends CredHubIntegrationTests {
|
||||
|
||||
private CredHubInfoOperations info;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.info = this.operations.info();
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.core.credential.CredHubCredentialOperations;
|
||||
import org.springframework.credhub.core.interpolation.CredHubInterpolationOperations;
|
||||
@@ -46,13 +46,13 @@ public class InterpolationIntegrationTests extends CredHubIntegrationTests {
|
||||
|
||||
private CredHubCredentialOperations credentials;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.interpolation = this.operations.interpolation();
|
||||
this.credentials = this.operations.credentials();
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
deleteCredentialIfExists(CREDENTIAL_NAME);
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ package org.springframework.credhub.integration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.core.credential.CredHubCredentialOperations;
|
||||
import org.springframework.credhub.core.permission.CredHubPermissionOperations;
|
||||
@@ -31,7 +31,7 @@ import org.springframework.credhub.support.permissions.Permission;
|
||||
import org.springframework.credhub.support.value.ValueCredentialRequest;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||
|
||||
public class PermissionIntegrationTests extends CredHubIntegrationTests {
|
||||
|
||||
@@ -44,7 +44,7 @@ public class PermissionIntegrationTests extends CredHubIntegrationTests {
|
||||
|
||||
private CredHubPermissionOperations permissions;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.credentials = this.operations.credentials();
|
||||
this.permissions = this.operations.permissions();
|
||||
@@ -52,7 +52,7 @@ public class PermissionIntegrationTests extends CredHubIntegrationTests {
|
||||
deleteCredentialIfExists(CREDENTIAL_NAME);
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
deleteCredentialIfExists(CREDENTIAL_NAME);
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ package org.springframework.credhub.integration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.credhub.core.credential.CredHubCredentialOperations;
|
||||
import org.springframework.credhub.core.permissionV2.CredHubPermissionV2Operations;
|
||||
@@ -33,7 +33,7 @@ import org.springframework.credhub.support.permissions.Permission;
|
||||
import org.springframework.credhub.support.value.ValueCredentialRequest;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||
|
||||
public class PermissionV2IntegrationTests extends CredHubIntegrationTests {
|
||||
|
||||
@@ -46,7 +46,7 @@ public class PermissionV2IntegrationTests extends CredHubIntegrationTests {
|
||||
|
||||
private CredHubPermissionV2Operations permissions;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.credentials = this.operations.credentials();
|
||||
this.permissions = this.operations.permissionsV2();
|
||||
@@ -54,7 +54,7 @@ public class PermissionV2IntegrationTests extends CredHubIntegrationTests {
|
||||
deleteCredentialIfExists(CREDENTIAL_NAME);
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
deleteCredentialIfExists(CREDENTIAL_NAME);
|
||||
}
|
||||
|
||||
@@ -41,9 +41,10 @@ dependencies {
|
||||
compile("org.springframework.security:spring-security-config")
|
||||
compile("org.springframework.security:spring-security-oauth2-client")
|
||||
|
||||
testCompile("org.springframework.boot:spring-boot-starter-test")
|
||||
testCompile("io.projectreactor:reactor-test")
|
||||
testCompile("org.assertj:assertj-core")
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
testImplementation("io.projectreactor:reactor-test")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
|
||||
testImplementation("org.assertj:assertj-core:${assertJVersion}")
|
||||
}
|
||||
|
||||
test {
|
||||
|
||||
@@ -18,9 +18,9 @@ package org.springframework.credhub.integration;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.credhub.core.certificate.ReactiveCredHubCertificateOperations;
|
||||
@@ -32,7 +32,7 @@ import org.springframework.credhub.support.certificate.CertificateParameters;
|
||||
import org.springframework.credhub.support.certificate.CertificateParametersRequest;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||
|
||||
public class ReactiveCertificateIntegrationTests extends ReactiveCredHubIntegrationTests {
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ReactiveCertificateIntegrationTests extends ReactiveCredHubIntegrat
|
||||
|
||||
private ReactiveCredHubCertificateOperations certificates;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.credentials = this.operations.credentials();
|
||||
this.certificates = this.operations.certificates();
|
||||
@@ -55,7 +55,7 @@ public class ReactiveCertificateIntegrationTests extends ReactiveCredHubIntegrat
|
||||
deleteCredentialIfExists(ROOT_CERT_NAME);
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
deleteCredentialIfExists(TEST_CERT_NAME);
|
||||
deleteCredentialIfExists(ROOT_CERT_NAME);
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.credhub.integration;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -27,10 +26,8 @@ import org.springframework.credhub.core.ReactiveCredHubOperations;
|
||||
import org.springframework.credhub.support.CredentialName;
|
||||
import org.springframework.credhub.support.info.VersionInfo;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = { TestApplication.class })
|
||||
@ActiveProfiles("test")
|
||||
public abstract class ReactiveCredHubIntegrationTests {
|
||||
@@ -43,7 +40,7 @@ public abstract class ReactiveCredHubIntegrationTests {
|
||||
@Autowired
|
||||
protected ReactiveCredHubOperations operations;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setupVersionInfo() {
|
||||
if (StringUtils.hasText(this.serverVersion)) {
|
||||
this.versionInfo = new VersionInfo(this.serverVersion);
|
||||
|
||||
@@ -18,9 +18,9 @@ package org.springframework.credhub.integration;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.credhub.core.credential.ReactiveCredHubCredentialOperations;
|
||||
@@ -35,7 +35,7 @@ import org.springframework.credhub.support.value.ValueCredential;
|
||||
import org.springframework.credhub.support.value.ValueCredentialRequest;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||
|
||||
public class ReactiveCredentialIntegrationTests extends ReactiveCredHubIntegrationTests {
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ReactiveCredentialIntegrationTests extends ReactiveCredHubIntegrati
|
||||
|
||||
private PasswordParameters.PasswordParametersBuilder passwordParameters;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.credentials = this.operations.credentials();
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ReactiveCredentialIntegrationTests extends ReactiveCredHubIntegrati
|
||||
deleteCredentialIfExists(CREDENTIAL_NAME);
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
deleteCredentialIfExists(CREDENTIAL_NAME);
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.credhub.integration;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.credhub.core.info.ReactiveCredHubInfoOperations;
|
||||
@@ -28,7 +28,7 @@ public class ReactiveInfoIntegrationTests extends ReactiveCredHubIntegrationTest
|
||||
|
||||
private ReactiveCredHubInfoOperations info;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.info = this.operations.info();
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.credhub.core.credential.ReactiveCredHubCredentialOperations;
|
||||
@@ -45,13 +45,13 @@ public class ReactiveInterpolationIntegrationTests extends ReactiveCredHubIntegr
|
||||
|
||||
private ReactiveCredHubCredentialOperations credentials;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.interpolation = this.operations.interpolation();
|
||||
this.credentials = this.operations.credentials();
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
deleteCredentialIfExists(CREDENTIAL_NAME);
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package org.springframework.credhub.integration;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.credhub.support.permissions.Permission;
|
||||
import org.springframework.credhub.support.value.ValueCredentialRequest;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||
|
||||
public class ReactivePermissionIntegrationTests extends ReactiveCredHubIntegrationTests {
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ReactivePermissionIntegrationTests extends ReactiveCredHubIntegrati
|
||||
|
||||
private ReactiveCredHubPermissionOperations permissions;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.credentials = this.operations.credentials();
|
||||
this.permissions = this.operations.permissions();
|
||||
@@ -54,7 +54,7 @@ public class ReactivePermissionIntegrationTests extends ReactiveCredHubIntegrati
|
||||
deletePermissionsIfExist();
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
deleteCredentialIfExists(CREDENTIAL_NAME);
|
||||
deletePermissionsIfExist();
|
||||
|
||||
@@ -19,9 +19,9 @@ package org.springframework.credhub.integration;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.credhub.core.credential.ReactiveCredHubCredentialOperations;
|
||||
@@ -35,7 +35,7 @@ import org.springframework.credhub.support.permissions.Permission;
|
||||
import org.springframework.credhub.support.value.ValueCredentialRequest;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||
|
||||
public class ReactivePermissionV2IntegrationTests extends ReactiveCredHubIntegrationTests {
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ReactivePermissionV2IntegrationTests extends ReactiveCredHubIntegra
|
||||
|
||||
private ReactiveCredHubPermissionV2Operations permissions;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.credentials = this.operations.credentials();
|
||||
this.permissions = this.operations.permissionsV2();
|
||||
@@ -56,7 +56,7 @@ public class ReactivePermissionV2IntegrationTests extends ReactiveCredHubIntegra
|
||||
deleteCredentialIfExists(CREDENTIAL_NAME);
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
deleteCredentialIfExists(CREDENTIAL_NAME);
|
||||
}
|
||||
|
||||
@@ -43,5 +43,6 @@ dependencies {
|
||||
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-web")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
|
||||
testImplementation("org.assertj:assertj-core:${assertJVersion}")
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.credhub.autoconfig;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.credhub.autoconfig;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.FilteredClassLoader;
|
||||
@@ -35,7 +35,6 @@ public class CredHubOAuth2AutoConfigurationTests {
|
||||
private final Class[] configurations = { CredHubAutoConfiguration.class, CredHubOAuth2AutoConfiguration.class };
|
||||
|
||||
private final String[] oAuth2ClientProperties = { "spring.credhub.oauth2.registration-id=test-client",
|
||||
|
||||
"spring.security.oauth2.client.registration.credhub-client.provider=uaa",
|
||||
"spring.security.oauth2.client.registration.credhub-client.client-id=test-client",
|
||||
"spring.security.oauth2.client.registration.credhub-client.client-secret=test-secret",
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.credhub.autoconfig;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener;
|
||||
|
||||
Reference in New Issue
Block a user