diff options
Diffstat (limited to 'sources/hv-collector-configuration/src/test')
2 files changed, 65 insertions, 0 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 12396d23..beb5df61 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 @@ -20,6 +20,7 @@ package org.onap.dcae.collectors.veshv.config.impl import arrow.core.None +import arrow.core.Option import arrow.core.Some import com.nhaarman.mockitokotlin2.mock import org.assertj.core.api.Assertions.assertThat @@ -134,5 +135,57 @@ internal object ConfigurationValidatorTest : Spek({ ) } } + + describe("validating configuration with security disabled") { + val idleTimeoutSec = 10 + val firstReqDelaySec = 10 + val securityKeys: Option<SecurityKeys> = None + val routing = routing { }.build() + + val config = PartialConfiguration( + Some(PartialServerConfig( + Some(1), + Some(idleTimeoutSec), + Some(2) + )), + Some(PartialCbsConfig( + Some(firstReqDelaySec), + Some(3) + )), + Some(PartialSecurityConfig( + securityKeys + )), + Some(PartialCollectorConfig( + Some(true), + Some(4), + Some(emptyList()), + Some(routing) + )), + Some(LogLevel.INFO) + ) + + it("should create valid configuration") { + val result = cut.validate(config) + result.fold( + { + fail("Configuration should have been created successfully but was $it") + }, + { + assertThat(it.server.idleTimeout) + .isEqualTo(Duration.ofSeconds(idleTimeoutSec.toLong())) + + assertThat(it.security.keys) + .isEqualTo(securityKeys) + + assertThat(it.cbs.firstRequestDelay) + .isEqualTo(Duration.ofSeconds(firstReqDelaySec.toLong())) + + assertThat(it.collector.routing) + .isEqualTo(routing) + } + ) + } + } + } }) diff --git a/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/FileConfigurationReaderTest.kt b/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/FileConfigurationReaderTest.kt index ab99f13c..8267e304 100644 --- a/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/FileConfigurationReaderTest.kt +++ b/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/FileConfigurationReaderTest.kt @@ -103,6 +103,18 @@ internal object FileConfigurationReaderTest : Spek({ } } + it("parses disabled security configuration") { + val input = """{ + "security": { + } + }""".trimIndent() + val config = cut.loadConfig(StringReader(input)) + + assertThat(config.security.nonEmpty()).isTrue() + val security = config.security.orNull() as PartialSecurityConfig + assertThat(security.keys.nonEmpty()).isFalse() + } + it("parses invalid log level string to empty option") { val input = """{ "logLevel": something |