aboutsummaryrefslogtreecommitdiffstats
path: root/hv-collector-xnf-simulator
diff options
context:
space:
mode:
authorkjaniak <kornel.janiak@nokia.com>2018-07-17 11:50:10 +0200
committerPiotr Jaszczyk <piotr.jaszczyk@nokia.com>2018-08-03 07:32:52 +0200
commit0d15767178ffff59009de51d3737883aa81df2a6 (patch)
treec1f8cc00ca873597a7e5014fc75e3db8b957a45d /hv-collector-xnf-simulator
parent40c5abeac588ca6c13477675960c94a97dcdeb15 (diff)
Add command line option to disable SSL/TLS
Closes ONAP-508 Change-Id: If6c3935ede7b00dea9b36747c6cd1422c1c8d330 Signed-off-by: kjaniak <kornel.janiak@nokia.com> Issue-ID: DCAEGEN2-601
Diffstat (limited to 'hv-collector-xnf-simulator')
-rw-r--r--hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/config/ArgConfigurationProvider.kt10
-rw-r--r--hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/config/ArgConfigurationProviderTest.kt38
2 files changed, 39 insertions, 9 deletions
diff --git a/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/config/ArgConfigurationProvider.kt b/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/config/ArgConfigurationProvider.kt
index 04654f8c..96e65778 100644
--- a/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/config/ArgConfigurationProvider.kt
+++ b/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/config/ArgConfigurationProvider.kt
@@ -23,12 +23,7 @@ import org.apache.commons.cli.CommandLine
import org.apache.commons.cli.DefaultParser
import org.onap.dcae.collectors.veshv.domain.SecurityConfiguration
import org.onap.dcae.collectors.veshv.utils.commandline.ArgBasedConfiguration
-import org.onap.dcae.collectors.veshv.utils.commandline.CommandLineOption.CERT_FILE
-import org.onap.dcae.collectors.veshv.utils.commandline.CommandLineOption.MESSAGES_TO_SEND_AMOUNT
-import org.onap.dcae.collectors.veshv.utils.commandline.CommandLineOption.PRIVATE_KEY_FILE
-import org.onap.dcae.collectors.veshv.utils.commandline.CommandLineOption.TRUST_CERT_FILE
-import org.onap.dcae.collectors.veshv.utils.commandline.CommandLineOption.VES_HV_HOST
-import org.onap.dcae.collectors.veshv.utils.commandline.CommandLineOption.VES_HV_PORT
+import org.onap.dcae.collectors.veshv.utils.commandline.CommandLineOption.*
/**
@@ -40,6 +35,7 @@ internal class ArgConfigurationProvider : ArgBasedConfiguration<SimulatorConfigu
VES_HV_PORT,
VES_HV_HOST,
MESSAGES_TO_SEND_AMOUNT,
+ SSL_DISABLE,
PRIVATE_KEY_FILE,
CERT_FILE,
TRUST_CERT_FILE
@@ -57,10 +53,12 @@ internal class ArgConfigurationProvider : ArgBasedConfiguration<SimulatorConfigu
}
private fun parseSecurityConfig(cmdLine: CommandLine): SecurityConfiguration {
+ val sslDisable = cmdLine.hasOption(SSL_DISABLE)
val pkFile = cmdLine.stringValue(PRIVATE_KEY_FILE, DefaultValues.PRIVATE_KEY_FILE)
val certFile = cmdLine.stringValue(CERT_FILE, DefaultValues.CERT_FILE)
val trustCertFile = cmdLine.stringValue(TRUST_CERT_FILE, DefaultValues.TRUST_CERT_FILE)
return SecurityConfiguration(
+ sslDisable = sslDisable,
privateKey = stringPathToPath(pkFile),
cert = stringPathToPath(certFile),
trustedCert = stringPathToPath(trustCertFile))
diff --git a/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/config/ArgConfigurationProviderTest.kt b/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/config/ArgConfigurationProviderTest.kt
index f2f92fff..fccd8b5a 100644
--- a/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/config/ArgConfigurationProviderTest.kt
+++ b/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/config/ArgConfigurationProviderTest.kt
@@ -31,6 +31,7 @@ import org.onap.dcae.collectors.veshv.simulators.xnf.config.ArgConfigurationProv
import org.onap.dcae.collectors.veshv.simulators.xnf.config.ArgConfigurationProvider.*
import org.onap.dcae.collectors.veshv.simulators.xnf.config.SimulatorConfiguration
import java.nio.file.Paths
+import kotlin.test.assertTrue
object ArgConfigurationProviderTest : Spek({
@@ -47,7 +48,7 @@ object ArgConfigurationProviderTest : Spek({
fun parse(vararg cmdLine: String): SimulatorConfiguration =
cut.parse(cmdLine).fold(
- {throw AssertionError("Parsing result should be present")},
+ { throw AssertionError("Parsing result should be present") },
::identity
)
@@ -57,7 +58,8 @@ object ArgConfigurationProviderTest : Spek({
given("all parameters are present in the long form") {
beforeEachTest {
- result = parse("--ves-port", "6969",
+ result = parse("--ssl-disable",
+ "--ves-port", "6969",
"--ves-host", vesHost,
"--messages", messagesAmount.toString(),
"--private-key-file", pk.toFile().absolutePath,
@@ -76,7 +78,7 @@ object ArgConfigurationProviderTest : Spek({
it("should set proper security configuration") {
assertThat(result.security).isEqualTo(
- SecurityConfiguration(pk, cert, trustCert)
+ SecurityConfiguration(sslDisable = true, privateKey = pk, cert = cert, trustedCert = trustCert)
)
}
}
@@ -122,5 +124,35 @@ object ArgConfigurationProviderTest : Spek({
}
}
}
+
+ given("disabled ssl certs together with all other parameters") {
+ beforeEachTest {
+ result = parse("--ssl-disable",
+ "--ves-port", "888",
+ "--ves-host", vesHost,
+ "--messages", messagesAmount.toString(),
+ "--private-key-file", pk.toFile().absolutePath,
+ "--cert-file", cert.toFile().absolutePath,
+ "--trust-cert-file", trustCert.toFile().absolutePath)
+ }
+
+ on("security config") {
+ val securityConfiguration = result.security
+
+ it("should set ssl disable to true"){
+ assertTrue(securityConfiguration.sslDisable)
+ }
+
+ it("should set proper security configuration") {
+ assertThat(securityConfiguration).isEqualTo(
+ SecurityConfiguration(
+ sslDisable = true,
+ privateKey = pk,
+ cert = cert,
+ trustedCert = trustCert)
+ )
+ }
+ }
+ }
}
})