aboutsummaryrefslogtreecommitdiffstats
path: root/sshapi-call-node/provider/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'sshapi-call-node/provider/src/test')
-rw-r--r--sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java2
-rw-r--r--sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java228
-rw-r--r--sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java2
-rw-r--r--sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java2
4 files changed, 231 insertions, 3 deletions
diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java
index 66be7300..4a5b765a 100644
--- a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java
+++ b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* openECOMP : SDN-C
* ================================================================================
- * * Copyright (C) 2017 AT&T Intellectual Property.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2018 Samsung Electronics. All rights
* reserved.
diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java
new file mode 100644
index 00000000..3992dffe
--- /dev/null
+++ b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java
@@ -0,0 +1,228 @@
+package jtest.org.onap.ccsdk.sli.plugins.sshapicall;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.plugins.sshapicall.SshApiCallNode;
+import org.onap.ccsdk.sli.plugins.sshapicall.model.XmlParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+
+public class TestSshApiCallNode {
+
+ private static final Logger log = LoggerFactory.getLogger(TestSshApiCallNode.class);
+
+ private SshApiCallNode adapter;
+ private String TestId;
+ private boolean testMode = true;
+ private Map<String, String> params;
+ private SvcLogicContext svcContext;
+
+
+ @Before
+ public void setup() throws IllegalArgumentException {
+ testMode = true;
+ svcContext = new SvcLogicContext();
+ adapter = new SshApiCallNode();
+
+ params = new HashMap<>();
+ params.put("AgentUrl", "https://192.168.1.1");
+ params.put("User", "test");
+ params.put("Password", "test");
+ }
+
+ @After
+ public void tearDown() {
+ testMode = false;
+ adapter = null;
+ params = null;
+ svcContext = null;
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testExecCommand_noUrlFailed() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "fail");
+ adapter.execCommand(params, svcContext);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testExecCommandPty_noUrlFailed() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "fail");
+ adapter.execCommandWithPty(params, svcContext);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testExecCommandResponse_noUrlFailed() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "fail");
+ adapter.execWithStatusCheck(params, svcContext);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testExecCommand_noPortFailed() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("Url", "test");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "fail");
+ adapter.execCommand(params, svcContext);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testExecCommandPty_noPortFailed() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("Url", "test");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "fail");
+ adapter.execCommandWithPty(params, svcContext);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testExecCommandResponse_noPortFailed() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("Url", "test");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "fail");
+ adapter.execWithStatusCheck(params, svcContext);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testExecCommand_noCmdFailed() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("Url", "test");
+ params.put("Port", "10");
+ adapter.execCommand(params, svcContext);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testExecCommandPty_noCmdFailed() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("Url", "test");
+ params.put("Port", "10");
+ adapter.execCommandWithPty(params, svcContext);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testExecCommandResponse_noCmdFailed() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("Url", "test");
+ params.put("Port", "10");
+ adapter.execWithStatusCheck(params, svcContext);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testExecCommandResponse_noSSHBasicFailed() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("Url", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("AuthType", "basic");
+ params.put("Cmd", "test");
+ adapter.execWithStatusCheck(params, svcContext);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testExecCommandResponse_noSSHKeyFailed() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("Url", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("AuthType", "key");
+ params.put("Cmd", "test");
+ adapter.execWithStatusCheck(params, svcContext);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testExecCommandResponse_noSSHNoneFailed() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("Url", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("AuthType", "none");
+ params.put("Cmd", "test");
+ params.put("ResponseType", "xml");
+ adapter.execWithStatusCheck(params, svcContext);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testExecCommandResponse_noSSHFailed() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("Url", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Cmd", "test");
+ params.put("ResponseType", "json");
+ adapter.execWithStatusCheck(params, svcContext);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testExecCommandResponse_noSSHInvalidParam() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("Url", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Cmd", "test");
+ params.put("ResponseType", "txt");
+ adapter.execWithStatusCheck(params, svcContext);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testExecCommandResponse_noSSHInvalidAuthParam() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("Url", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Cmd", "test");
+ params.put("AuthType", "spring");
+ params.put("ResponseType", "json");
+ adapter.execWithStatusCheck(params, svcContext);
+ }
+}
diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java
index 599043e9..218ad6a8 100644
--- a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java
+++ b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* openECOMP : SDN-C
* ================================================================================
- * * Copyright (C) 2017 AT&T Intellectual Property.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2018 Samsung Electronics. All rights
* reserved.
diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java
index d904721f..3f8d3716 100644
--- a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java
+++ b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* openECOMP : SDN-C
* ================================================================================
- * * Copyright (C) 2017 AT&T Intellectual Property.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2018 Samsung Electronics. All rights
* reserved.