Move cmd ssl logic to xnf-simulator 72/84872/7
authorJakub Dudycz <jakub.dudycz@nokia.com>
Wed, 10 Apr 2019 13:02:01 +0000 (15:02 +0200)
committerJakub Dudycz <jakub.dudycz@nokia.com>
Fri, 12 Apr 2019 09:18:52 +0000 (11:18 +0200)
Change-Id: I562acbb0b7522e6cefea2a2dc1a9e292c1227b41
Signed-off-by: Jakub Dudycz <jakub.dudycz@nokia.com>
Issue-ID: DCAEGEN2-565

14 files changed:
sources/hv-collector-ssl/pom.xml
sources/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/config/ArgXnfSimulatorConfiguration.kt
sources/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/config/SslUtils.kt [moved from sources/hv-collector-ssl/src/main/kotlin/org/onap/dcae/collectors/veshv/ssl/boundary/utils.kt with 94% similarity]
sources/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/main.kt
sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/OngoingSimulationsTest.kt [moved from sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/OngoingSimulationsTest.kt with 91% similarity]
sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/XnfSimulatorTest.kt [moved from sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/XnfSimulatorTest.kt with 97% similarity]
sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/adapters/HvVesClientTest.kt [moved from sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/HvVesClientTest.kt with 96% similarity]
sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/config/SslUtilsTest.kt [moved from sources/hv-collector-ssl/src/test/kotlin/org/onap/dcae/collectors/veshv/ssl/boundary/UtilsKtTest.kt with 85% similarity]
sources/hv-collector-xnf-simulator/src/test/resources/ssl/ca.crt [moved from sources/hv-collector-ssl/src/test/resources/ssl/ca.crt with 100% similarity]
sources/hv-collector-xnf-simulator/src/test/resources/ssl/password [moved from sources/hv-collector-ssl/src/test/resources/ssl/password with 100% similarity]
sources/hv-collector-xnf-simulator/src/test/resources/ssl/server.crt [moved from sources/hv-collector-ssl/src/test/resources/ssl/server.crt with 100% similarity]
sources/hv-collector-xnf-simulator/src/test/resources/ssl/server.key [moved from sources/hv-collector-ssl/src/test/resources/ssl/server.key with 100% similarity]
sources/hv-collector-xnf-simulator/src/test/resources/ssl/server.ks.pkcs12 [moved from sources/hv-collector-ssl/src/test/resources/ssl/server.ks.pkcs12 with 100% similarity]
sources/hv-collector-xnf-simulator/src/test/resources/ssl/trust.pkcs12 [moved from sources/hv-collector-ssl/src/test/resources/ssl/trust.pkcs12 with 100% similarity]

index 0ba609e..2aaf229 100644 (file)
     </build>
 
     <dependencies>
-        <dependency>
-            <groupId>${project.parent.groupId}</groupId>
-            <artifactId>hv-collector-commandline</artifactId>
-            <version>${project.parent.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>${project.parent.groupId}</groupId>
-            <artifactId>hv-collector-domain</artifactId>
-            <version>${project.parent.version}</version>
-        </dependency>
         <dependency>
             <groupId>${project.parent.groupId}</groupId>
             <artifactId>hv-collector-test-utils</artifactId>
@@ -94,6 +84,4 @@
             <scope>test</scope>
         </dependency>
     </dependencies>
-
-
 </project>
index 7fa23f7..d9cbbaa 100644 (file)
@@ -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
@@ -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<SecurityConfiguration> =
-        createSecurityConfigurationProvider(cmdLine).map { it() }
-
 fun createSecurityConfigurationProvider(cmdLine: CommandLine): Try<() -> SecurityConfiguration> =
         if (shouldDisableSsl(cmdLine))
             Try { { disabledSecurityConfiguration() } }
index 4fcb180..04a0c14 100644 (file)
@@ -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
@@ -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
@@ -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
  * 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()