summaryrefslogtreecommitdiffstats
path: root/certServiceClient/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'certServiceClient/src/test')
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/CertServiceClientTest.java2
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/CsrFactoryTest.java3
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/PrivateKeyToPemEncoderTest.java4
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvProviderTest.java13
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvsForCsrTest.java59
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvsForTlsTest.java36
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/exception/TlsConfigurationExceptionTest.java9
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactoryTest.java22
8 files changed, 80 insertions, 68 deletions
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/CertServiceClientTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/CertServiceClientTest.java
index 36808941..9e256f98 100644
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/CertServiceClientTest.java
+++ b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/CertServiceClientTest.java
@@ -35,7 +35,7 @@ class CertServiceClientTest {
AppExitHandler appExitHandler = new AppExitHandler();
@Test
- public void shouldExitWithDefinedExitCode_onRunCallWhenNoEnvsPresent() {
+ void shouldExitWithDefinedExitCode_onRunCallWhenNoEnvsPresent() {
// given
doNothing().when(appExitHandler).exit(CLIENT_CONFIGURATION_EXCEPTION);
doNothing().when(appExitHandler).exit(SUCCESS);
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/CsrFactoryTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/CsrFactoryTest.java
index e88976bf..ae18e6fb 100644
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/CsrFactoryTest.java
+++ b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/CsrFactoryTest.java
@@ -31,8 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-
-public class CsrFactoryTest {
+class CsrFactoryTest {
CsrConfiguration config = mock(CsrConfiguration.class);
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/PrivateKeyToPemEncoderTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/PrivateKeyToPemEncoderTest.java
index def9c1d5..41f15bb7 100644
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/PrivateKeyToPemEncoderTest.java
+++ b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/PrivateKeyToPemEncoderTest.java
@@ -44,7 +44,7 @@ class PrivateKeyToPemEncoderTest {
private static final String PRIVATE_KEY_PEM_PATH = RESOURCES_DIR + "rsaPrivateKeyPem";
@Test
- public void shouldReturnProperlyEncodedPrivateKey() throws InvalidKeySpecException, NoSuchAlgorithmException, PkEncodingException, IOException {
+ void shouldReturnProperlyEncodedPrivateKey() throws InvalidKeySpecException, NoSuchAlgorithmException, PkEncodingException, IOException {
//given
String expectedPem = Files.readString(Paths.get(PRIVATE_KEY_PEM_PATH));
PrivateKeyToPemEncoder testedPkEncoder = new PrivateKeyToPemEncoder();
@@ -63,4 +63,4 @@ class PrivateKeyToPemEncoderTest {
KeyFactory kf = KeyFactory.getInstance(ENCRYPTION_ALGORITHM);
return kf.generatePrivate(spec);
}
-} \ No newline at end of file
+}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvProviderTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvProviderTest.java
index af6b2d9f..74c8c2a1 100644
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvProviderTest.java
+++ b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvProviderTest.java
@@ -36,12 +36,12 @@ class EnvProviderTest {
private EnvProvider envProvider;
@BeforeEach
- public void setUp() {
+ void setUp() {
envProvider = Mockito.spy(EnvProvider.class);
}
@Test
- public void shouldReturnSystemEnvVariableWhenItWasDefined() {
+ void shouldReturnSystemEnvVariableWhenItWasDefined() {
// given
when(envProvider.getSystemEnv(TEST_ENV)).thenReturn(TEST_ENV_VALUE);
@@ -49,16 +49,17 @@ class EnvProviderTest {
final Optional<String> testEnv = envProvider.readEnvVariable(TEST_ENV);
// then
- assertThat(testEnv.isPresent()).isTrue();
- assertThat(testEnv.get()).isEqualTo(TEST_ENV_VALUE);
+ assertThat(testEnv)
+ .isPresent()
+ .contains(TEST_ENV_VALUE);
}
@Test
- public void shouldReportThatSystemEnvVariableIsNotPresentWhenItWasNotDefined() {
+ void shouldReportThatSystemEnvVariableIsNotPresentWhenItWasNotDefined() {
// when
final Optional<String> testEnv = envProvider.readEnvVariable(TEST_ENV);
// then
- assertThat(testEnv.isPresent()).isFalse();
+ assertThat(testEnv).isNotPresent();
}
}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvsForCsrTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvsForCsrTest.java
index 656bbe59..d6af20c6 100644
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvsForCsrTest.java
+++ b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvsForCsrTest.java
@@ -47,17 +47,18 @@ class EnvsForCsrTest {
final Optional<String> testEnv = envsForCsr.getCommonName();
// then
- assertThat(testEnv.isPresent()).isTrue();
- assertThat(testEnv.get()).isEqualTo(TEST_ENV);
+ assertThat(testEnv)
+ .isPresent()
+ .contains(TEST_ENV);
}
@Test
- public void shouldReportThatSystemEnvCommonNameVariableIsNotPresentWhenItWasNotDefined() {
+ void shouldReportThatSystemEnvCommonNameVariableIsNotPresentWhenItWasNotDefined() {
// when
final Optional<String> testEnv = envsForCsr.getCommonName();
// then
- assertThat(testEnv.isPresent()).isFalse();
+ assertThat(testEnv).isNotPresent();
}
@Test
@@ -69,17 +70,18 @@ class EnvsForCsrTest {
final Optional<String> testEnv = envsForCsr.getOrganization();
// then
- assertThat(testEnv.isPresent()).isTrue();
- assertThat(testEnv.get()).isEqualTo(TEST_ENV);
+ assertThat(testEnv)
+ .isPresent()
+ .contains(TEST_ENV);
}
@Test
- public void shouldReportThatSystemEnvOrganizationVariableIsNotPresentWhenItWasNotDefined() {
+ void shouldReportThatSystemEnvOrganizationVariableIsNotPresentWhenItWasNotDefined() {
// when
final Optional<String> testEnv = envsForCsr.getOrganization();
// then
- assertThat(testEnv.isPresent()).isFalse();
+ assertThat(testEnv).isNotPresent();
}
@Test
@@ -91,8 +93,9 @@ class EnvsForCsrTest {
final Optional<String> testEnv = envsForCsr.getOrganizationUnit();
// then
- assertThat(testEnv.isPresent()).isTrue();
- assertThat(testEnv.get()).isEqualTo(TEST_ENV);
+ assertThat(testEnv)
+ .isPresent()
+ .contains(TEST_ENV);
}
@Test
@@ -101,7 +104,7 @@ class EnvsForCsrTest {
final Optional<String> testEnv = envsForCsr.getOrganizationUnit();
// then
- assertThat(testEnv.isPresent()).isFalse();
+ assertThat(testEnv).isNotPresent();
}
@Test
@@ -113,17 +116,18 @@ class EnvsForCsrTest {
final Optional<String> testEnv = envsForCsr.getLocation();
// then
- assertThat(testEnv.isPresent()).isTrue();
- assertThat(testEnv.get()).isEqualTo(TEST_ENV);
+ assertThat(testEnv)
+ .isPresent()
+ .contains(TEST_ENV);
}
@Test
- public void shouldReportThatSystemEnvLocationVariableIsNotPresentWhenItWasNotDefined() {
+ void shouldReportThatSystemEnvLocationVariableIsNotPresentWhenItWasNotDefined() {
// when
final Optional<String> testEnv = envsForCsr.getLocation();
// then
- assertThat(testEnv.isPresent()).isFalse();
+ assertThat(testEnv).isNotPresent();
}
@Test
@@ -135,17 +139,18 @@ class EnvsForCsrTest {
final Optional<String> testEnv = envsForCsr.getState();
// then
- assertThat(testEnv.isPresent()).isTrue();
- assertThat(testEnv.get()).isEqualTo(TEST_ENV);
+ assertThat(testEnv)
+ .isPresent()
+ .contains(TEST_ENV);
}
@Test
- public void shouldReportThatSystemEnvStateVariableIsNotPresentWhenItWasNotDefined() {
+ void shouldReportThatSystemEnvStateVariableIsNotPresentWhenItWasNotDefined() {
// when
final Optional<String> testEnv = envsForCsr.getState();
// then
- assertThat(testEnv.isPresent()).isFalse();
+ assertThat(testEnv).isNotPresent();
}
@Test
@@ -157,17 +162,18 @@ class EnvsForCsrTest {
final Optional<String> testEnv = envsForCsr.getCountry();
// then
- assertThat(testEnv.isPresent()).isTrue();
- assertThat(testEnv.get()).isEqualTo(TEST_ENV);
+ assertThat(testEnv)
+ .isPresent()
+ .contains(TEST_ENV);
}
@Test
- public void shouldReportThatSystemEnvCountryVariableIsNotPresentWhenItWasNotDefined() {
+ void shouldReportThatSystemEnvCountryVariableIsNotPresentWhenItWasNotDefined() {
// when
final Optional<String> testEnv = envsForCsr.getCountry();
// then
- assertThat(testEnv.isPresent()).isFalse();
+ assertThat(testEnv).isNotPresent();
}
@Test
@@ -179,8 +185,9 @@ class EnvsForCsrTest {
final Optional<String> testEnv = envsForCsr.getSubjectAlternativesName();
// then
- assertThat(testEnv.isPresent()).isTrue();
- assertThat(testEnv.get()).isEqualTo(TEST_ENV);
+ assertThat(testEnv)
+ .isPresent()
+ .contains(TEST_ENV);
}
@Test
@@ -189,6 +196,6 @@ class EnvsForCsrTest {
final Optional<String> testEnv = envsForCsr.getSubjectAlternativesName();
// then
- assertThat(testEnv.isPresent()).isFalse();
+ assertThat(testEnv).isNotPresent();
}
}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvsForTlsTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvsForTlsTest.java
index a33d6541..7f599aa5 100644
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvsForTlsTest.java
+++ b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvsForTlsTest.java
@@ -48,17 +48,18 @@ class EnvsForTlsTest {
final Optional<String> testEnv = envsForTls.getKeystorePath();
// then
- assertThat(testEnv.isPresent()).isTrue();
- assertThat(testEnv.get()).isEqualTo(TEST_ENV);
+ assertThat(testEnv)
+ .isPresent()
+ .contains(TEST_ENV);
}
@Test
- public void shouldReportThatSystemEnvKeyStorePathVariableIsNotPresentWhenItWasNotDefined() {
+ void shouldReportThatSystemEnvKeyStorePathVariableIsNotPresentWhenItWasNotDefined() {
// when
final Optional<String> testEnv = envsForTls.getKeystorePath();
// then
- assertThat(testEnv.isPresent()).isFalse();
+ assertThat(testEnv).isNotPresent();
}
@Test
@@ -70,17 +71,18 @@ class EnvsForTlsTest {
final Optional<String> testEnv = envsForTls.getKeystorePassword();
// then
- assertThat(testEnv.isPresent()).isTrue();
- assertThat(testEnv.get()).isEqualTo(TEST_ENV);
+ assertThat(testEnv)
+ .isPresent()
+ .contains(TEST_ENV);
}
@Test
- public void shouldReportThatSystemEnvKeyStorePasswordVariableIsNotPresentWhenItWasNotDefined() {
+ void shouldReportThatSystemEnvKeyStorePasswordVariableIsNotPresentWhenItWasNotDefined() {
// when
final Optional<String> testEnv = envsForTls.getKeystorePassword();
// then
- assertThat(testEnv.isPresent()).isFalse();
+ assertThat(testEnv).isNotPresent();
}
@Test
@@ -92,17 +94,18 @@ class EnvsForTlsTest {
final Optional<String> testEnv = envsForTls.getTruststorePath();
// then
- assertThat(testEnv.isPresent()).isTrue();
- assertThat(testEnv.get()).isEqualTo(TEST_ENV);
+ assertThat(testEnv)
+ .isPresent()
+ .contains(TEST_ENV);
}
@Test
- public void shouldReportThatSystemEnvTrustStorePathVariableIsNotPresentWhenItWasNotDefined() {
+ void shouldReportThatSystemEnvTrustStorePathVariableIsNotPresentWhenItWasNotDefined() {
// when
final Optional<String> testEnv = envsForTls.getTruststorePath();
// then
- assertThat(testEnv.isPresent()).isFalse();
+ assertThat(testEnv).isNotPresent();
}
@Test
@@ -114,16 +117,17 @@ class EnvsForTlsTest {
final Optional<String> testEnv = envsForTls.getTruststorePassword();
// then
- assertThat(testEnv.isPresent()).isTrue();
- assertThat(testEnv.get()).isEqualTo(TEST_ENV);
+ assertThat(testEnv)
+ .isPresent()
+ .contains(TEST_ENV);
}
@Test
- public void shouldReportThatSystemEnvTrustStorePasswordVariableIsNotPresentWhenItWasNotDefined() {
+ void shouldReportThatSystemEnvTrustStorePasswordVariableIsNotPresentWhenItWasNotDefined() {
// when
final Optional<String> testEnv = envsForTls.getTruststorePassword();
// then
- assertThat(testEnv.isPresent()).isFalse();
+ assertThat(testEnv).isNotPresent();
}
}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/exception/TlsConfigurationExceptionTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/exception/TlsConfigurationExceptionTest.java
index e1144a6b..e9e5c3bf 100644
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/exception/TlsConfigurationExceptionTest.java
+++ b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/exception/TlsConfigurationExceptionTest.java
@@ -26,10 +26,10 @@ import org.onap.aaf.certservice.client.api.ExitStatus;
import static org.assertj.core.api.Assertions.assertThat;
-public class TlsConfigurationExceptionTest {
+class TlsConfigurationExceptionTest {
@Test
- public void containsProperExitStatus() {
+ void containsProperExitStatus() {
// Given
ExitStatus exitStatus = null;
@@ -41,7 +41,8 @@ public class TlsConfigurationExceptionTest {
}
// Then
- assertThat(exitStatus).isNotNull();
- assertThat(exitStatus).isEqualTo(ExitStatus.TLS_CONFIGURATION_EXCEPTION);
+ assertThat(exitStatus)
+ .isNotNull()
+ .isEqualTo(ExitStatus.TLS_CONFIGURATION_EXCEPTION);
}
}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactoryTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactoryTest.java
index 9c0b9d8f..e4d71b31 100644
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactoryTest.java
+++ b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactoryTest.java
@@ -27,67 +27,67 @@ import org.mockito.Mockito;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
-public class AbstractConfigurationFactoryTest {
+class AbstractConfigurationFactoryTest {
private final AbstractConfigurationFactory cut = mock(AbstractConfigurationFactory.class, Mockito.CALLS_REAL_METHODS);
@ParameterizedTest
@ValueSource(strings = {"/var/log", "/", "/var/log/", "/second_var", "/second-var"})
- public void shouldAcceptValidPath(String path) {
+ void shouldAcceptValidPath(String path) {
assertThat(cut.isPathValid(path)).isTrue();
}
@ParameterizedTest
@ValueSource(strings = {"/var/log?", "", "var_", "var", "//", "/var//log"})
- public void shouldRejectInvalidPath(String path) {
+ void shouldRejectInvalidPath(String path) {
assertThat(cut.isPathValid(path)).isFalse();
}
@ParameterizedTest
@ValueSource(strings = {"PL", "DE", "PN", "US", "IO", "CA", "KH", "CO", "DK", "EC", "CZ", "CN", "BR", "BD", "BE"})
- public void shouldAcceptValidCountryCode(String countryCode) {
+ void shouldAcceptValidCountryCode(String countryCode) {
assertThat(cut.isCountryValid(countryCode)).isTrue();
}
@ParameterizedTest
@ValueSource(strings = {"", "QQ", "AFG", "D", "&*", "!", "ONAP", "p", "pl", "us", "afg"})
- public void shouldRejectInvalidCountryCode(String countryCode) {
+ void shouldRejectInvalidCountryCode(String countryCode) {
assertThat(cut.isCountryValid(countryCode)).isFalse();
}
@ParameterizedTest
@ValueSource(strings = {"caname", "caname1", "123caName", "ca1name"})
- public void shouldAcceptValidAlphanumeric(String caName) {
+ void shouldAcceptValidAlphanumeric(String caName) {
assertThat(cut.isAlphaNumeric(caName)).isTrue();
}
@ParameterizedTest
@ValueSource(strings = {"44caname$", "#caname1", "1c_aname", "ca1-name"})
- public void shouldRejectInvalidAlphanumeric(String caName) {
+ void shouldRejectInvalidAlphanumeric(String caName) {
assertThat(cut.isAlphaNumeric(caName)).isFalse();
}
@ParameterizedTest
@ValueSource(strings = {"example.com", "www.example.com"})
- public void shouldAcceptValidCommonName(String commonName) {
+ void shouldAcceptValidCommonName(String commonName) {
assertThat(cut.isCommonNameValid(commonName)).isTrue();
}
@ParameterizedTest
@ValueSource(strings = {"https://example.com", "http://example.com", "example.com:8080", "0.0.0.0", "@#$%.com"})
- public void shouldRejectInvalidCommonName(String commonName) {
+ void shouldRejectInvalidCommonName(String commonName) {
assertThat(cut.isCommonNameValid(commonName)).isFalse();
}
@ParameterizedTest
@ValueSource(strings = {"JKS", "P12", "PEM"})
- public void shouldAcceptValidOutputType(String outputType) {
+ void shouldAcceptValidOutputType(String outputType) {
assertThat(cut.isOutputTypeValid(outputType)).isTrue();
}
@ParameterizedTest
@ValueSource(strings = {"jks", "p12", "pem", "", "pass", "!@$#pp"})
- public void shouldRejectInvalidOutputType(String outputType) {
+ void shouldRejectInvalidOutputType(String outputType) {
assertThat(cut.isOutputTypeValid(outputType)).isFalse();
}
}