diff options
author | 2020-09-15 08:21:21 +0200 | |
---|---|---|
committer | 2020-09-15 09:53:10 +0200 | |
commit | 8ad064f65528f89dacbf8a03c87d94214a9871f5 (patch) | |
tree | 5dc74cf6d123bd2c32a23f9746a54530c5a516cc /trustStoreMerger | |
parent | 0439aac459a3f68b57569018cfffbb0fc81ecee9 (diff) |
Fix for env names
Postfix _ENV removed from envs names since it was introduced by mistake.
Issue spotted in CSITs.
Issue-ID: DCAEGEN2-2253
Signed-off-by: kjaniak <kornel.janiak@nokia.com>
Change-Id: Ibbd99e3c655337ca6ae1fd3d4a568b01e35373dc
Diffstat (limited to 'trustStoreMerger')
5 files changed, 46 insertions, 46 deletions
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/AppConfigurationProvider.java b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/AppConfigurationProvider.java index 33ea8e4b..3adea9ab 100644 --- a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/AppConfigurationProvider.java +++ b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/AppConfigurationProvider.java @@ -20,10 +20,10 @@ package org.onap.oom.truststoremerger.configuration; -import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.KEYSTORE_DESTINATION_PATHS_ENV; -import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.KEYSTORE_SOURCE_PATHS_ENV; -import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.TRUSTSTORES_PASSWORDS_PATHS_ENV; -import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.TRUSTSTORES_PATHS_ENV; +import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.KEYSTORE_DESTINATION_PATHS; +import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.KEYSTORE_SOURCE_PATHS; +import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.TRUSTSTORES_PASSWORDS_PATHS; +import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.TRUSTSTORES_PATHS; import java.util.Collections; import java.util.List; @@ -48,15 +48,15 @@ public class AppConfigurationProvider { public AppConfiguration createConfiguration() throws ConfigurationException, CertificatesPathsValidationException { - List<String> truststoresPaths = getPaths(TRUSTSTORES_PATHS_ENV); - List<String> truststoresPasswordsPaths = getPaths(TRUSTSTORES_PASSWORDS_PATHS_ENV); - List<String> sourceKeystorePaths = getPaths(KEYSTORE_SOURCE_PATHS_ENV); - List<String> destinationKeystorePaths = getPaths(KEYSTORE_DESTINATION_PATHS_ENV); + List<String> truststoresPaths = getPaths(TRUSTSTORES_PATHS); + List<String> truststoresPasswordsPaths = getPaths(TRUSTSTORES_PASSWORDS_PATHS); + List<String> sourceKeystorePaths = getPaths(KEYSTORE_SOURCE_PATHS); + List<String> destinationKeystorePaths = getPaths(KEYSTORE_DESTINATION_PATHS); - ensureSameSize(truststoresPaths, truststoresPasswordsPaths, TRUSTSTORES_PATHS_ENV.name(), - TRUSTSTORES_PASSWORDS_PATHS_ENV.name()); - ensureSameSize(sourceKeystorePaths, destinationKeystorePaths, KEYSTORE_SOURCE_PATHS_ENV.name(), - KEYSTORE_DESTINATION_PATHS_ENV.name()); + ensureSameSize(truststoresPaths, truststoresPasswordsPaths, TRUSTSTORES_PATHS.name(), + TRUSTSTORES_PASSWORDS_PATHS.name()); + ensureSameSize(sourceKeystorePaths, destinationKeystorePaths, KEYSTORE_SOURCE_PATHS.name(), + KEYSTORE_DESTINATION_PATHS.name()); return new AppConfiguration(truststoresPaths, truststoresPasswordsPaths, sourceKeystorePaths, destinationKeystorePaths); diff --git a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/model/EnvVariable.java b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/model/EnvVariable.java index 456c58f8..3f4c73da 100644 --- a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/model/EnvVariable.java +++ b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/model/EnvVariable.java @@ -27,10 +27,10 @@ import java.util.List; import java.util.function.Predicate; public enum EnvVariable { - TRUSTSTORES_PATHS_ENV(true, doesItContainValidCertificatesPaths()), - TRUSTSTORES_PASSWORDS_PATHS_ENV(true, doesItContainValidPasswordPaths()), - KEYSTORE_SOURCE_PATHS_ENV(false, doesItContainValidPathsToCopy()), - KEYSTORE_DESTINATION_PATHS_ENV(false, doesItContainValidPathsToCopy()); + TRUSTSTORES_PATHS(true, doesItContainValidCertificatesPaths()), + TRUSTSTORES_PASSWORDS_PATHS(true, doesItContainValidPasswordPaths()), + KEYSTORE_SOURCE_PATHS(false, doesItContainValidPathsToCopy()), + KEYSTORE_DESTINATION_PATHS(false, doesItContainValidPathsToCopy()); boolean isMandatory; diff --git a/trustStoreMerger/src/test/java/org/onap/oom/truststoremerger/configuration/AppConfigurationProviderTest.java b/trustStoreMerger/src/test/java/org/onap/oom/truststoremerger/configuration/AppConfigurationProviderTest.java index a8da405d..b0f73d09 100644 --- a/trustStoreMerger/src/test/java/org/onap/oom/truststoremerger/configuration/AppConfigurationProviderTest.java +++ b/trustStoreMerger/src/test/java/org/onap/oom/truststoremerger/configuration/AppConfigurationProviderTest.java @@ -22,10 +22,10 @@ package org.onap.oom.truststoremerger.configuration; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.Mockito.when; -import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.KEYSTORE_DESTINATION_PATHS_ENV; -import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.KEYSTORE_SOURCE_PATHS_ENV; -import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.TRUSTSTORES_PASSWORDS_PATHS_ENV; -import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.TRUSTSTORES_PATHS_ENV; +import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.KEYSTORE_DESTINATION_PATHS; +import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.KEYSTORE_SOURCE_PATHS; +import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.TRUSTSTORES_PASSWORDS_PATHS; +import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.TRUSTSTORES_PATHS; import java.util.ArrayList; import java.util.List; @@ -47,8 +47,8 @@ class AppConfigurationProviderTest { private static final String BASE_TRUSTSTORE_PATH = "/opt/app/truststore_"; private static final String JKS_EXTENSION = ".jks"; private static final String PASS_EXTENSION = ".pass"; - private static final String TRUSTSTORES_PATHS = "/opt/app/certificates/truststore.jks:/opt/app/certificates/truststore.pem"; - private static final String TRUSTSTORES_PASSWORDS_PATHS = "/opt/app/certificates/truststore.pass:/trust.pass"; + private static final String SAMPLE_TRUSTSTORES_PATHS = "/opt/app/certificates/truststore.jks:/opt/app/certificates/truststore.pem"; + private static final String SAMPLE_TRUSTSTORES_PASSWORDS_PATHS = "/opt/app/certificates/truststore.pass:/trust.pass"; @Mock private DelimitedPathsSplitter pathsSplitter; @@ -64,10 +64,10 @@ class AppConfigurationProviderTest { @Test void shouldThrowExceptionWhenMandatoryEnvNotPresent() { // given - when(envReader.getEnv(TRUSTSTORES_PATHS_ENV.name())).thenReturn(Optional.empty()); + when(envReader.getEnv(TRUSTSTORES_PATHS.name())).thenReturn(Optional.empty()); // when, then assertThatExceptionOfType(ConfigurationException.class).isThrownBy(() -> provider.createConfiguration()) - .withMessageContaining(TRUSTSTORES_PATHS_ENV + " mandatory environment variable is not defined"); + .withMessageContaining(TRUSTSTORES_PATHS + " mandatory environment variable is not defined"); } @Test @@ -77,11 +77,11 @@ class AppConfigurationProviderTest { List<String> truststoresPasswords = createListOfPathsWithExtension(1, PASS_EXTENSION); mockTruststorePaths(truststores, truststoresPasswords); - // when + // when, then assertThatExceptionOfType(ConfigurationException.class) .isThrownBy(() -> provider.createConfiguration()) - .withMessageContaining("Size of " + TRUSTSTORES_PATHS_ENV - + " does not match size of " + TRUSTSTORES_PASSWORDS_PATHS_ENV + " environment variables"); + .withMessageContaining("Size of " + TRUSTSTORES_PATHS + + " does not match size of " + TRUSTSTORES_PASSWORDS_PATHS + " environment variables"); } @Test @@ -109,25 +109,25 @@ class AppConfigurationProviderTest { } private void mockTruststores(List<String> truststores) throws CertificatesPathsValidationException { - when(envReader.getEnv(TRUSTSTORES_PATHS_ENV.name())).thenReturn(Optional.of(TRUSTSTORES_PATHS)); - when(pathsSplitter.getValidatedPaths(TRUSTSTORES_PATHS_ENV, Optional.of(TRUSTSTORES_PATHS))) + when(envReader.getEnv(TRUSTSTORES_PATHS.name())).thenReturn(Optional.of(SAMPLE_TRUSTSTORES_PATHS)); + when(pathsSplitter.getValidatedPaths(TRUSTSTORES_PATHS, Optional.of(SAMPLE_TRUSTSTORES_PATHS))) .thenReturn(truststores); } private void mockTruststoresPasswords(List<String> truststoresPasswords) throws CertificatesPathsValidationException { - Optional<String> passwordsPaths = Optional.of(TRUSTSTORES_PASSWORDS_PATHS); - when(envReader.getEnv(TRUSTSTORES_PASSWORDS_PATHS_ENV.name())).thenReturn(passwordsPaths); - when(pathsSplitter.getValidatedPaths(TRUSTSTORES_PASSWORDS_PATHS_ENV, passwordsPaths)) + Optional<String> passwordsPaths = Optional.of(SAMPLE_TRUSTSTORES_PASSWORDS_PATHS); + when(envReader.getEnv(TRUSTSTORES_PASSWORDS_PATHS.name())).thenReturn(passwordsPaths); + when(pathsSplitter.getValidatedPaths(TRUSTSTORES_PASSWORDS_PATHS, passwordsPaths)) .thenReturn(truststoresPasswords); } private void mockKeystoreCopierSourcePaths(Optional<String> paths) { - when(envReader.getEnv(KEYSTORE_SOURCE_PATHS_ENV.name())).thenReturn(paths); + when(envReader.getEnv(KEYSTORE_SOURCE_PATHS.name())).thenReturn(paths); } private void mockKeystoreCopierDestinationPaths(Optional<String> paths) { - when(envReader.getEnv(KEYSTORE_DESTINATION_PATHS_ENV.name())).thenReturn(paths); + when(envReader.getEnv(KEYSTORE_DESTINATION_PATHS.name())).thenReturn(paths); } private List<String> createListOfPathsWithExtension(int numberOfPaths, String passwordExtension) { diff --git a/trustStoreMerger/src/test/java/org/onap/oom/truststoremerger/configuration/path/DelimitedPathsSplitterTest.java b/trustStoreMerger/src/test/java/org/onap/oom/truststoremerger/configuration/path/DelimitedPathsSplitterTest.java index 22b5a7fc..04e96054 100644 --- a/trustStoreMerger/src/test/java/org/onap/oom/truststoremerger/configuration/path/DelimitedPathsSplitterTest.java +++ b/trustStoreMerger/src/test/java/org/onap/oom/truststoremerger/configuration/path/DelimitedPathsSplitterTest.java @@ -21,8 +21,8 @@ package org.onap.oom.truststoremerger.configuration.path; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.TRUSTSTORES_PASSWORDS_PATHS_ENV; -import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.TRUSTSTORES_PATHS_ENV; +import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.TRUSTSTORES_PASSWORDS_PATHS; +import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.TRUSTSTORES_PATHS; import java.util.Optional; import org.junit.jupiter.api.BeforeEach; @@ -50,7 +50,7 @@ class DelimitedPathsSplitterTest { @Test void shouldReturnCorrectListWhenTruststoresValid() { // when, then - assertThat(delimitedPathsSplitter.getValidatedPaths(TRUSTSTORES_PATHS_ENV, Optional.of(VALID_TRUSTSTORES))) + assertThat(delimitedPathsSplitter.getValidatedPaths(TRUSTSTORES_PATHS, Optional.of(VALID_TRUSTSTORES))) .containsSequence("/opt/app/certificates/truststore.jks", "/opt/app/certificates/truststore.pem"); } @@ -59,7 +59,7 @@ class DelimitedPathsSplitterTest { void shouldThrowExceptionWhenTruststoresPathsEnvIsEmpty() { // when, then assertThatExceptionOfType(CertificatesPathsValidationException.class) - .isThrownBy(() -> delimitedPathsSplitter.getValidatedPaths(TRUSTSTORES_PATHS_ENV, Optional.of(""))); + .isThrownBy(() -> delimitedPathsSplitter.getValidatedPaths(TRUSTSTORES_PATHS, Optional.of(""))); } @Test @@ -67,21 +67,21 @@ class DelimitedPathsSplitterTest { // when, then assertThatExceptionOfType(CertificatesPathsValidationException.class) .isThrownBy(() -> delimitedPathsSplitter - .getValidatedPaths(TRUSTSTORES_PATHS_ENV, Optional.of(INVALID_TRUSTSTORES))); + .getValidatedPaths(TRUSTSTORES_PATHS, Optional.of(INVALID_TRUSTSTORES))); } @Test void shouldReturnCorrectListWhenTruststoresPasswordsValid() { // when, then assertThat(delimitedPathsSplitter - .getValidatedPaths(TRUSTSTORES_PASSWORDS_PATHS_ENV, Optional.of(VALID_TRUSTSTORES_PASSWORDS))) + .getValidatedPaths(TRUSTSTORES_PASSWORDS_PATHS, Optional.of(VALID_TRUSTSTORES_PASSWORDS))) .containsSequence("/opt/app/certificates/truststore.pass", ""); } @Test void shouldReturnCorrectListWhenTruststoresPasswordsContainsEmptyPathsInTheMiddle() { // when, then - assertThat(delimitedPathsSplitter.getValidatedPaths(TRUSTSTORES_PASSWORDS_PATHS_ENV, + assertThat(delimitedPathsSplitter.getValidatedPaths(TRUSTSTORES_PASSWORDS_PATHS, Optional.of(VALID_TRUSTSTORES_PASSWORDS_WITH_EMPTY_IN_THE_MIDDLE))).containsSequence( "/opt/app/certificates/truststore.pass", "", @@ -94,7 +94,7 @@ class DelimitedPathsSplitterTest { // when, then assertThatExceptionOfType(CertificatesPathsValidationException.class) .isThrownBy( - () -> delimitedPathsSplitter.getValidatedPaths(TRUSTSTORES_PASSWORDS_PATHS_ENV, Optional.of(""))); + () -> delimitedPathsSplitter.getValidatedPaths(TRUSTSTORES_PASSWORDS_PATHS, Optional.of(""))); } @Test @@ -102,6 +102,6 @@ class DelimitedPathsSplitterTest { // when, then assertThatExceptionOfType(CertificatesPathsValidationException.class) .isThrownBy(() -> delimitedPathsSplitter - .getValidatedPaths(TRUSTSTORES_PASSWORDS_PATHS_ENV, Optional.of(INVALID_TRUSTSTORES_PASSWORDS))); + .getValidatedPaths(TRUSTSTORES_PASSWORDS_PATHS, Optional.of(INVALID_TRUSTSTORES_PASSWORDS))); } } diff --git a/trustStoreMerger/src/test/java/org/onap/oom/truststoremerger/configuration/path/env/EnvReaderTest.java b/trustStoreMerger/src/test/java/org/onap/oom/truststoremerger/configuration/path/env/EnvReaderTest.java index 0a654fe8..c84c34f2 100644 --- a/trustStoreMerger/src/test/java/org/onap/oom/truststoremerger/configuration/path/env/EnvReaderTest.java +++ b/trustStoreMerger/src/test/java/org/onap/oom/truststoremerger/configuration/path/env/EnvReaderTest.java @@ -22,7 +22,7 @@ package org.onap.oom.truststoremerger.configuration.path.env; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; -import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.TRUSTSTORES_PASSWORDS_PATHS_ENV; +import static org.onap.oom.truststoremerger.configuration.model.EnvVariable.TRUSTSTORES_PASSWORDS_PATHS; import java.util.Optional; import org.junit.jupiter.api.BeforeEach; @@ -42,7 +42,7 @@ class EnvReaderTest { @Test void shouldReturnOptionalWithEnv() { // given - String envName = TRUSTSTORES_PASSWORDS_PATHS_ENV.name(); + String envName = TRUSTSTORES_PASSWORDS_PATHS.name(); when(provider.getSystemEnv(envName)).thenReturn(Optional.of(SAMPLE_PASS_PATH)); // when Optional<String> result = provider.getEnv(envName); @@ -53,7 +53,7 @@ class EnvReaderTest { @Test void shouldReturnEmptyOptional() { // given - String envName = TRUSTSTORES_PASSWORDS_PATHS_ENV.name(); + String envName = TRUSTSTORES_PASSWORDS_PATHS.name(); // when Optional<String> result = provider.getEnv(envName); // then |