diff options
Diffstat (limited to 'sources/hv-collector-xnf-simulator/src/test/kotlin')
-rw-r--r-- | sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/OngoingSimulationsTest.kt (renamed from sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/OngoingSimulationsTest.kt) | 7 | ||||
-rw-r--r-- | sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/XnfSimulatorTest.kt (renamed from sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/XnfSimulatorTest.kt) | 3 | ||||
-rw-r--r-- | sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/adapters/HvVesClientTest.kt (renamed from sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/HvVesClientTest.kt) | 2 | ||||
-rw-r--r-- | sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/config/SslUtilsTest.kt | 76 |
4 files changed, 79 insertions, 9 deletions
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 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 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 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-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/config/SslUtilsTest.kt b/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/config/SslUtilsTest.kt new file mode 100644 index 00000000..631ec7bf --- /dev/null +++ b/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/config/SslUtilsTest.kt @@ -0,0 +1,76 @@ +/* + * ============LICENSE_START======================================================= + * dcaegen2-collectors-veshv + * ================================================================================ + * Copyright (C) 2019 NOKIA + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.dcae.collectors.veshv.simulators.xnf.impl.config + +import com.nhaarman.mockitokotlin2.doReturn +import com.nhaarman.mockitokotlin2.mock +import com.nhaarman.mockitokotlin2.verify +import com.nhaarman.mockitokotlin2.whenever +import org.apache.commons.cli.CommandLine +import org.assertj.core.api.Assertions.assertThat +import org.jetbrains.spek.api.Spek +import org.jetbrains.spek.api.dsl.describe +import org.jetbrains.spek.api.dsl.it +import org.jetbrains.spek.api.dsl.on +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 java.nio.file.Paths + + +internal object SslUtilsTest : Spek({ + + describe("creating securty configuration provider") { + + on("command line without ssl disable") { + val passwordFile = resourcePathAsString("/ssl/password") + val commandLine: CommandLine = mock() + whenever(commandLine.hasOption(CommandLineOption.SSL_DISABLE)).doReturn(false) + whenever(commandLine.stringValue(CommandLineOption.TRUST_STORE_PASSWORD_FILE, TRUST_STORE_PASSWORD_FILE)) + .doReturn(passwordFile) + whenever(commandLine.stringValue(CommandLineOption.KEY_STORE_PASSWORD_FILE, KEY_STORE_PASSWORD_FILE)) + .doReturn(passwordFile) + + it("should create configuration with some keys") { + val configuration = createSecurityConfigurationProvider(commandLine) + + verify(commandLine).hasOption(CommandLineOption.SSL_DISABLE) + assertThat(configuration.isSuccess()).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 = createSecurityConfigurationProvider(commandLine) + + verify(commandLine).hasOption(CommandLineOption.SSL_DISABLE) + assertThat(configuration.isSuccess()).isTrue() + configuration.map { assertThat(it().keys.isEmpty()).isTrue() } + } + } + } +}) + +private fun resourcePathAsString(resource: String) = + Paths.get(SslUtilsTest::class.java.getResource(resource).toURI()).toString() |