aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/netconf-executor
diff options
context:
space:
mode:
authorOleg Mitsura <oleg.mitsura@amdocs.com>2019-04-10 15:37:00 -0400
committerOleg Mitsura <oleg.mitsura@amdocs.com>2019-04-10 16:28:28 -0400
commitce597c19c2df8169449bd74376a5bf1082e75bb6 (patch)
treede91450c41ca318fac10eea61c5ed0e8566eceb4 /ms/blueprintsprocessor/functions/netconf-executor
parentb5b294f670c4f1f1f503b391ef01d983143adace (diff)
netconf-executor: RpcMessageUtilsTest improvement
Issue-ID: CCSDK-1126 Change-Id: I245661bb6ca1afa6aece98c83a1758a7a6f93621 Signed-off-by: Oleg Mitsura <oleg.mitsura@amdocs.com>
Diffstat (limited to 'ms/blueprintsprocessor/functions/netconf-executor')
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt2
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt36
2 files changed, 33 insertions, 5 deletions
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt
index 1ffc9a68c..bb5cdb0b5 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt
@@ -396,7 +396,7 @@ class NetconfMessageUtils {
fun checkReply(reply: String?): Boolean {
return if (reply != null) {
- !reply.contains("rpc-error>") || reply.contains("warning") || reply.contains("ok/>")
+ !reply.contains("rpc-error>") || reply.contains("ok/>")
} else false
}
}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt
index a4ef4410a..ffbf7306c 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt
@@ -17,8 +17,11 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.utils
import org.junit.Assert
import org.junit.Assert.assertTrue
+import org.junit.Ignore
import org.junit.Test
import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.NetconfException
+import kotlin.test.assertFailsWith
+import kotlin.test.assertFalse
import kotlin.test.fail
class RpcMessageUtilsTest {
@@ -214,6 +217,15 @@ class RpcMessageUtilsTest {
}
@Test
+ fun deleteConfigThrowsNetconfExceptionOnRunningDataStore() {
+ assertFailsWith(exceptionClass = NetconfException::class) {
+ val netconfTargetConfig = NetconfDatastore.RUNNING.datastore
+ val msgId = "35"
+ NetconfMessageUtils.deleteConfig(msgId, netconfTargetConfig)
+ }
+ }
+
+ @Test
fun discardChanges() {
val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"
@@ -277,11 +289,21 @@ class RpcMessageUtilsTest {
}
@Test
- fun checkReply(){
+ fun `checkReply should return true on ok msg`() {
assertTrue(NetconfMessageUtils.checkReply("ok"))
}
@Test
+ fun `checkReply on rpc-error should return false`() {
+ assertFalse { NetconfMessageUtils.checkReply("something something rpc-error>") }
+ }
+
+ @Test
+ fun `checkReply on null input should return false`() {
+ assertFalse { NetconfMessageUtils.checkReply(null) }
+ }
+
+ @Test
fun formatRPCRequest(){
val checkString = ("#199" +
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"> <capabilities> <capability>hi</capability> <capability>hello</capability> </capabilities></hello>" +
@@ -296,11 +318,17 @@ class RpcMessageUtilsTest {
val result = NetconfMessageUtils.formatRPCRequest(request,messageId,capabilities).replace("[\n\r\t]".toRegex(), "")
Assert.assertEquals(checkString, result)
-
-
}
+ @Test
+ fun `validateRPCXML on empty input returns false`() {
+ assertFalse { NetconfMessageUtils.validateRPCXML("") }
+ }
-
+ @Test
+ fun `validateRPCXML on bad input returns false`() {
+ println("Don't fear \"[Fatal Error] :1:1: Content is not allowed in prolog.\" TODO: adjust logging for NetconfMessageUtils")
+ assertFalse { NetconfMessageUtils.validateRPCXML("really bad XML ~~~input") }
+ }
} \ No newline at end of file