aboutsummaryrefslogtreecommitdiffstats
path: root/sources/hv-collector-configuration/src/test
diff options
context:
space:
mode:
authorFilip Krzywka <filip.krzywka@nokia.com>2019-04-02 13:01:07 +0200
committerFilip Krzywka <filip.krzywka@nokia.com>2019-04-02 13:01:07 +0200
commit6a00e38550fd1745c3377da2099bf5a615f69053 (patch)
tree10df0b9286448e695bbf063aefceacb084d02d46 /sources/hv-collector-configuration/src/test
parent5ddee4d3b85c1b180acb506099c44678edcc57d5 (diff)
Allow reuse of security passwords
- moved logic of creating passwords into Validator Change-Id: Ieabab24734250bfacea96eff2b7102465ff8ed57 Issue-ID: DCAEGEN2-1380 Signed-off-by: Filip Krzywka <filip.krzywka@nokia.com>
Diffstat (limited to 'sources/hv-collector-configuration/src/test')
-rw-r--r--sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/ConfigurationValidatorTest.kt23
1 files changed, 16 insertions, 7 deletions
diff --git a/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/ConfigurationValidatorTest.kt b/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/ConfigurationValidatorTest.kt
index 55d06cdd..682bec5a 100644
--- a/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/ConfigurationValidatorTest.kt
+++ b/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/ConfigurationValidatorTest.kt
@@ -22,14 +22,19 @@ package org.onap.dcae.collectors.veshv.config.impl
import arrow.core.None
import arrow.core.Option
import arrow.core.Some
+import arrow.core.getOrElse
import com.nhaarman.mockitokotlin2.mock
+import com.nhaarman.mockitokotlin2.verify
+import com.nhaarman.mockitokotlin2.whenever
import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Assertions.fail
+import org.assertj.core.api.ObjectAssert
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.config.api.model.Routing
import org.onap.dcae.collectors.veshv.config.impl.ConfigurationValidator.Companion.DEFAULT_LOG_LEVEL
+import org.onap.dcae.collectors.veshv.ssl.boundary.SecurityKeysPaths
import org.onap.dcae.collectors.veshv.utils.logging.LogLevel
import org.onap.dcaegen2.services.sdk.security.ssl.SecurityKeys
import java.time.Duration
@@ -85,7 +90,9 @@ internal object ConfigurationValidatorTest : Spek({
describe("validating complete configuration") {
val idleTimeoutSec = Duration.ofSeconds(10L)
val firstReqDelaySec = Duration.ofSeconds(10L)
- val securityKeys = Some(mock<SecurityKeys>())
+ val securityKeys = mock<SecurityKeysPaths>()
+ val immutableSecurityKeys = mock<SecurityKeys>()
+ whenever(securityKeys.asImmutableSecurityKeys()).thenReturn(immutableSecurityKeys)
val config = PartialConfiguration(
Some(PartialServerConfig(
@@ -98,7 +105,7 @@ internal object ConfigurationValidatorTest : Spek({
Some(Duration.ofSeconds(3))
)),
Some(PartialSecurityConfig(
- securityKeys
+ Some(securityKeys)
)),
Some(PartialCollectorConfig(
someFromEmptyRouting
@@ -116,8 +123,10 @@ internal object ConfigurationValidatorTest : Spek({
assertThat(it.server.idleTimeout)
.isEqualTo(idleTimeoutSec)
- assertThat(it.security.keys)
- .isEqualTo(securityKeys)
+ verify(securityKeys).asImmutableSecurityKeys()
+ assertThat(it.security.keys
+ .getOrElse { fail("Should be immutableSecurityKeys") })
+ .isEqualTo(immutableSecurityKeys)
assertThat(it.cbs.firstRequestDelay)
.isEqualTo(firstReqDelaySec)
@@ -132,7 +141,7 @@ internal object ConfigurationValidatorTest : Spek({
describe("validating configuration with security disabled") {
val idleTimeoutSec = Duration.ofSeconds(10)
val firstReqDelaySec = Duration.ofSeconds(10)
- val securityKeys: Option<SecurityKeys> = None
+ val missingSecurityKeys: Option<SecurityKeysPaths> = None
val config = PartialConfiguration(
Some(PartialServerConfig(
@@ -145,7 +154,7 @@ internal object ConfigurationValidatorTest : Spek({
Some(Duration.ofSeconds(3))
)),
Some(PartialSecurityConfig(
- securityKeys
+ missingSecurityKeys
)),
Some(PartialCollectorConfig(
someFromEmptyRouting
@@ -164,7 +173,7 @@ internal object ConfigurationValidatorTest : Spek({
.isEqualTo(idleTimeoutSec)
assertThat(it.security.keys)
- .isEqualTo(securityKeys)
+ .isEqualTo(missingSecurityKeys)
assertThat(it.cbs.firstRequestDelay)
.isEqualTo(firstReqDelaySec)