From: Jakub Dudycz Date: Wed, 10 Apr 2019 13:02:01 +0000 (+0200) Subject: Move cmd ssl logic to xnf-simulator X-Git-Tag: 1.1.0~5 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=be68ea73313277ae749cdc47f15e9993d1c5a6ce;p=dcaegen2%2Fcollectors%2Fhv-ves.git Move cmd ssl logic to xnf-simulator Change-Id: I562acbb0b7522e6cefea2a2dc1a9e292c1227b41 Signed-off-by: Jakub Dudycz Issue-ID: DCAEGEN2-565 --- diff --git a/sources/hv-collector-ssl/pom.xml b/sources/hv-collector-ssl/pom.xml index 0ba609e5..2aaf2295 100644 --- a/sources/hv-collector-ssl/pom.xml +++ b/sources/hv-collector-ssl/pom.xml @@ -54,16 +54,6 @@ - - ${project.parent.groupId} - hv-collector-commandline - ${project.parent.version} - - - ${project.parent.groupId} - hv-collector-domain - ${project.parent.version} - ${project.parent.groupId} hv-collector-test-utils @@ -94,6 +84,4 @@ test - - diff --git a/sources/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/config/ArgXnfSimulatorConfiguration.kt b/sources/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/config/ArgXnfSimulatorConfiguration.kt index 7fa23f7f..d9cbbaa8 100644 --- a/sources/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/config/ArgXnfSimulatorConfiguration.kt +++ b/sources/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/config/ArgXnfSimulatorConfiguration.kt @@ -36,7 +36,6 @@ import org.onap.dcae.collectors.veshv.commandline.CommandLineOption.VES_HV_PORT import org.onap.dcae.collectors.veshv.commandline.intValue import org.onap.dcae.collectors.veshv.commandline.stringValue import org.onap.dcae.collectors.veshv.domain.WireFrameMessage -import org.onap.dcae.collectors.veshv.ssl.boundary.createSecurityConfigurationProvider import org.onap.dcae.collectors.veshv.utils.arrow.OptionUtils.binding import org.onap.dcae.collectors.veshv.utils.arrow.doOnFailure import org.onap.dcae.collectors.veshv.utils.logging.Logger diff --git a/sources/hv-collector-ssl/src/main/kotlin/org/onap/dcae/collectors/veshv/ssl/boundary/utils.kt b/sources/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/config/SslUtils.kt similarity index 94% rename from sources/hv-collector-ssl/src/main/kotlin/org/onap/dcae/collectors/veshv/ssl/boundary/utils.kt rename to sources/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/config/SslUtils.kt index 5981d9d4..7678fdbb 100644 --- a/sources/hv-collector-ssl/src/main/kotlin/org/onap/dcae/collectors/veshv/ssl/boundary/utils.kt +++ b/sources/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/config/SslUtils.kt @@ -17,7 +17,8 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package org.onap.dcae.collectors.veshv.ssl.boundary +package org.onap.dcae.collectors.veshv.simulators.xnf.impl.config + import arrow.core.None import arrow.core.Some @@ -26,6 +27,7 @@ import org.apache.commons.cli.CommandLine import org.onap.dcae.collectors.veshv.commandline.CommandLineOption import org.onap.dcae.collectors.veshv.commandline.hasOption import org.onap.dcae.collectors.veshv.commandline.stringValue +import org.onap.dcae.collectors.veshv.ssl.boundary.SecurityConfiguration import org.onap.dcaegen2.services.sdk.security.ssl.ImmutableSecurityKeys import org.onap.dcaegen2.services.sdk.security.ssl.ImmutableSecurityKeysStore import org.onap.dcaegen2.services.sdk.security.ssl.Passwords @@ -41,9 +43,6 @@ const val KEY_STORE_PASSWORD_FILE = "/etc/ves-hv/server.pass" const val TRUST_STORE_FILE = "/etc/ves-hv/trust.p12" const val TRUST_STORE_PASSWORD_FILE = "/etc/ves-hv/trust.pass" -fun createSecurityConfiguration(cmdLine: CommandLine): Try = - createSecurityConfigurationProvider(cmdLine).map { it() } - fun createSecurityConfigurationProvider(cmdLine: CommandLine): Try<() -> SecurityConfiguration> = if (shouldDisableSsl(cmdLine)) Try { { disabledSecurityConfiguration() } } diff --git a/sources/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/main.kt b/sources/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/main.kt index 4fcb1809..04a0c14a 100644 --- a/sources/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/main.kt +++ b/sources/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/main.kt @@ -20,7 +20,6 @@ package org.onap.dcae.collectors.veshv.simulators.xnf import io.vavr.collection.HashSet -import org.onap.dcae.collectors.veshv.commandline.handleWrongArgumentError import org.onap.dcae.collectors.veshv.commandline.handleWrongArgumentErrorCurried import org.onap.dcae.collectors.veshv.healthcheck.api.HealthDescription import org.onap.dcae.collectors.veshv.healthcheck.api.HealthState diff --git a/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/OngoingSimulationsTest.kt b/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/OngoingSimulationsTest.kt similarity index 91% rename from sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/OngoingSimulationsTest.kt rename to sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/OngoingSimulationsTest.kt index 325d3bb5..cb604626 100644 --- a/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/OngoingSimulationsTest.kt +++ b/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/OngoingSimulationsTest.kt @@ -17,7 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package org.onap.dcae.collectors.veshv.main +package org.onap.dcae.collectors.veshv.simulators.xnf.impl import org.assertj.core.api.Assertions.assertThat import org.jetbrains.spek.api.Spek @@ -25,11 +25,6 @@ import org.jetbrains.spek.api.dsl.describe import org.jetbrains.spek.api.dsl.given import org.jetbrains.spek.api.dsl.it import org.jetbrains.spek.api.dsl.on -import org.onap.dcae.collectors.veshv.simulators.xnf.impl.OngoingSimulations -import org.onap.dcae.collectors.veshv.simulators.xnf.impl.StatusFailure -import org.onap.dcae.collectors.veshv.simulators.xnf.impl.StatusNotFound -import org.onap.dcae.collectors.veshv.simulators.xnf.impl.StatusOngoing -import org.onap.dcae.collectors.veshv.simulators.xnf.impl.StatusSuccess import org.onap.dcae.collectors.veshv.tests.utils.waitUntilSucceeds import reactor.core.publisher.Mono import reactor.core.scheduler.Schedulers diff --git a/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/XnfSimulatorTest.kt b/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/XnfSimulatorTest.kt similarity index 97% rename from sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/XnfSimulatorTest.kt rename to sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/XnfSimulatorTest.kt index ea0628c1..11ce0b3f 100644 --- a/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/XnfSimulatorTest.kt +++ b/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/XnfSimulatorTest.kt @@ -17,7 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package org.onap.dcae.collectors.veshv.main +package org.onap.dcae.collectors.veshv.simulators.xnf.impl import arrow.core.Left import arrow.core.None @@ -30,7 +30,6 @@ import com.nhaarman.mockitokotlin2.whenever import org.jetbrains.spek.api.Spek import org.jetbrains.spek.api.dsl.describe import org.jetbrains.spek.api.dsl.it -import org.onap.dcae.collectors.veshv.simulators.xnf.impl.XnfSimulator import org.onap.dcae.collectors.veshv.simulators.xnf.impl.adapters.HvVesClient import org.onap.dcae.collectors.veshv.simulators.xnf.impl.factory.ClientFactory import org.onap.dcae.collectors.veshv.tests.utils.Assertions.assertThat diff --git a/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/HvVesClientTest.kt b/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/adapters/HvVesClientTest.kt similarity index 96% rename from sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/HvVesClientTest.kt rename to sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/adapters/HvVesClientTest.kt index 14061532..5e6cb981 100644 --- a/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/HvVesClientTest.kt +++ b/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/adapters/HvVesClientTest.kt @@ -17,7 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package org.onap.dcae.collectors.veshv.main +package org.onap.dcae.collectors.veshv.simulators.xnf.impl.adapters import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.eq diff --git a/sources/hv-collector-ssl/src/test/kotlin/org/onap/dcae/collectors/veshv/ssl/boundary/UtilsKtTest.kt b/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/config/SslUtilsTest.kt similarity index 85% rename from sources/hv-collector-ssl/src/test/kotlin/org/onap/dcae/collectors/veshv/ssl/boundary/UtilsKtTest.kt rename to sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/config/SslUtilsTest.kt index c7c414f8..631ec7bf 100644 --- a/sources/hv-collector-ssl/src/test/kotlin/org/onap/dcae/collectors/veshv/ssl/boundary/UtilsKtTest.kt +++ b/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/config/SslUtilsTest.kt @@ -17,10 +17,9 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package org.onap.dcae.collectors.veshv.ssl.boundary +package org.onap.dcae.collectors.veshv.simulators.xnf.impl.config import com.nhaarman.mockitokotlin2.doReturn -import com.nhaarman.mockitokotlin2.eq import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.verify import com.nhaarman.mockitokotlin2.whenever @@ -36,7 +35,7 @@ import org.onap.dcae.collectors.veshv.commandline.stringValue import java.nio.file.Paths -internal object UtilsKtTest : Spek({ +internal object SslUtilsTest : Spek({ describe("creating securty configuration provider") { @@ -50,27 +49,28 @@ internal object UtilsKtTest : Spek({ .doReturn(passwordFile) it("should create configuration with some keys") { - val configuration = createSecurityConfiguration(commandLine) + val configuration = createSecurityConfigurationProvider(commandLine) verify(commandLine).hasOption(CommandLineOption.SSL_DISABLE) assertThat(configuration.isSuccess()).isTrue() - configuration.map { assertThat(it.keys.isDefined()).isTrue() } + configuration.map { assertThat(it().keys.isDefined()).isTrue() } } } + on("command line with ssl disabled") { val commandLine: CommandLine = mock() whenever(commandLine.hasOption(CommandLineOption.SSL_DISABLE)).doReturn(true) it("should create configuration without keys") { - val configuration = createSecurityConfiguration(commandLine) + val configuration = createSecurityConfigurationProvider(commandLine) verify(commandLine).hasOption(CommandLineOption.SSL_DISABLE) assertThat(configuration.isSuccess()).isTrue() - configuration.map { assertThat(it.keys.isEmpty()).isTrue() } + configuration.map { assertThat(it().keys.isEmpty()).isTrue() } } } } }) private fun resourcePathAsString(resource: String) = - Paths.get(UtilsKtTest::class.java.getResource(resource).toURI()).toString() + Paths.get(SslUtilsTest::class.java.getResource(resource).toURI()).toString() diff --git a/sources/hv-collector-ssl/src/test/resources/ssl/ca.crt b/sources/hv-collector-xnf-simulator/src/test/resources/ssl/ca.crt similarity index 100% rename from sources/hv-collector-ssl/src/test/resources/ssl/ca.crt rename to sources/hv-collector-xnf-simulator/src/test/resources/ssl/ca.crt diff --git a/sources/hv-collector-ssl/src/test/resources/ssl/password b/sources/hv-collector-xnf-simulator/src/test/resources/ssl/password similarity index 100% rename from sources/hv-collector-ssl/src/test/resources/ssl/password rename to sources/hv-collector-xnf-simulator/src/test/resources/ssl/password diff --git a/sources/hv-collector-ssl/src/test/resources/ssl/server.crt b/sources/hv-collector-xnf-simulator/src/test/resources/ssl/server.crt similarity index 100% rename from sources/hv-collector-ssl/src/test/resources/ssl/server.crt rename to sources/hv-collector-xnf-simulator/src/test/resources/ssl/server.crt diff --git a/sources/hv-collector-ssl/src/test/resources/ssl/server.key b/sources/hv-collector-xnf-simulator/src/test/resources/ssl/server.key similarity index 100% rename from sources/hv-collector-ssl/src/test/resources/ssl/server.key rename to sources/hv-collector-xnf-simulator/src/test/resources/ssl/server.key diff --git a/sources/hv-collector-ssl/src/test/resources/ssl/server.ks.pkcs12 b/sources/hv-collector-xnf-simulator/src/test/resources/ssl/server.ks.pkcs12 similarity index 100% rename from sources/hv-collector-ssl/src/test/resources/ssl/server.ks.pkcs12 rename to sources/hv-collector-xnf-simulator/src/test/resources/ssl/server.ks.pkcs12 diff --git a/sources/hv-collector-ssl/src/test/resources/ssl/trust.pkcs12 b/sources/hv-collector-xnf-simulator/src/test/resources/ssl/trust.pkcs12 similarity index 100% rename from sources/hv-collector-ssl/src/test/resources/ssl/trust.pkcs12 rename to sources/hv-collector-xnf-simulator/src/test/resources/ssl/trust.pkcs12