From cef711e2a291ab1779052d36cf5b21ccd9ed498b Mon Sep 17 00:00:00 2001 From: Ganesh Date: Wed, 6 Oct 2021 15:51:36 +0530 Subject: saltstack adaptor test cases added Signed-off-by: Ganesh Issue-ID: CCSDK-3476 Change-Id: Ie0fe8d6848aab36ffe4c5018d5e2b6df0c4c09de --- .../adaptors/saltstack/impl/TestSshConnection.java | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/adaptors/saltstack-adaptor/saltstack-adaptor-provider/src/test/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/TestSshConnection.java b/adaptors/saltstack-adaptor/saltstack-adaptor-provider/src/test/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/TestSshConnection.java index 89b0ecf4b..b7a06ae12 100644 --- a/adaptors/saltstack-adaptor/saltstack-adaptor-provider/src/test/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/TestSshConnection.java +++ b/adaptors/saltstack-adaptor/saltstack-adaptor-provider/src/test/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/TestSshConnection.java @@ -22,7 +22,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.ccsdk.adapter.impl; +package org.onap.ccsdk.sli.adaptors.saltstack.impl; import org.junit.Before; import org.junit.Test; @@ -32,12 +32,14 @@ import org.onap.ccsdk.sli.adaptors.saltstack.impl.SshConnection; import java.io.FileOutputStream; import java.io.OutputStream; +import java.util.Properties; import static org.junit.Assert.assertEquals; public class TestSshConnection { private SshConnection sshConnection; +private Properties params; @Before @@ -47,9 +49,9 @@ private SshConnection sshConnection; String User = "test"; String Password = "test"; sshConnection = new SshConnection(HostName, Port, User, Password); + params = new Properties(); } - @Test(expected=NullPointerException.class) public void reqConnect_exitStatusFailed() { sshConnection.setExecTimeout(10); @@ -61,6 +63,12 @@ private SshConnection sshConnection; sshConnection.setExecTimeout(10); int outcome = 999; try { + params.put("org.onap.appc.adaptor.saltstack.clientType", "SSH_CERT"); + params.put("org.onap.appc.adaptor.saltstack.host", "test"); + params.put("org.onap.appc.adaptor.saltstack.port", "10"); + params.put("org.onap.appc.adaptor.saltstack.userName", "test"); + params.put("org.onap.appc.adaptor.saltstack.userPasswd", "test"); + params.put("org.onap.appc.adaptor.saltstack.sshKey", "test"); OutputStream res = new FileOutputStream("test.out"); outcome = sshConnection.execCommandWithPty("ls",res); assertEquals(1,outcome); @@ -71,6 +79,12 @@ private SshConnection sshConnection; @Test(expected=NullPointerException.class) public void reqDisconnect_exitStatusFailed() { + params.put("org.onap.appc.adaptor.saltstack.clientType", "SSH_CERT"); + params.put("org.onap.appc.adaptor.saltstack.host", "test"); + params.put("org.onap.appc.adaptor.saltstack.port", "10"); + params.put("org.onap.appc.adaptor.saltstack.userName", "test"); + params.put("org.onap.appc.adaptor.saltstack.userPasswd", "test"); + params.put("org.onap.appc.adaptor.saltstack.sshKey", "test"); sshConnection.setExecTimeout(10); sshConnection.disconnect(); } @@ -80,6 +94,12 @@ private SshConnection sshConnection; sshConnection.setExecTimeout(10); int outcome=999; try { + params.put("org.onap.appc.adaptor.saltstack.clientType", "SSH_CERT"); + params.put("org.onap.appc.adaptor.saltstack.host", "test"); + params.put("org.onap.appc.adaptor.saltstack.port", "10"); + params.put("org.onap.appc.adaptor.saltstack.userName", "test"); + params.put("org.onap.appc.adaptor.saltstack.userPasswd", "test"); + params.put("org.onap.appc.adaptor.saltstack.sshKey", "test"); OutputStream res = new FileOutputStream("test.out"); OutputStream resErr = new FileOutputStream("test.out"); outcome = sshConnection.execCommand("ls",res, resErr); -- cgit 1.2.3-korg