* initial commit

* fixed indent

* removed unused dependencies

* some minor code changes and unit tests

* fixed file names
This commit is contained in:
majajoksovic
2020-09-01 17:23:00 +02:00
committed by GitHub
parent 2dc6089b10
commit 8d2c467e2b
5 changed files with 201 additions and 5 deletions
@@ -0,0 +1,38 @@
package com.baeldung.ssh;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import com.baeldung.ssh.apachesshd.SshdDemo;
public class ApacheMinaSshdLiveTest {
@Test
public void givenValidCredentials_whenConnectionIsEstablished_thenServerReturnsResponse() throws Exception {
String username = "demo";
String password = "password";
String host = "test.rebex.net";
int port = 22;
long defaultTimeoutSeconds = 10l;
String command = "ls\n";
String responseString = SshdDemo.listFolderStructure(username, password, host, port, defaultTimeoutSeconds, command);
assertNotNull(responseString);
}
@Test(expected = Exception.class)
public void givenInvalidCredentials_whenConnectionAttemptIsMade_thenServerReturnsErrorResponse() throws Exception {
String username = "invalidUsername";
String password = "password";
String host = "test.rebex.net";
int port = 22;
long defaultTimeoutSeconds = 10l;
String command = "ls\n";
String responseString = SshdDemo.listFolderStructure(username, password, host, port, defaultTimeoutSeconds, command);
assertNull(responseString);
}
}
@@ -0,0 +1,35 @@
package com.baeldung.ssh;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import com.baeldung.ssh.jsch.JschDemo;
public class JSchLiveTest {
@Test
public void givenValidCredentials_whenConnectionIsEstablished_thenServerReturnsResponse() throws Exception {
String username = "demo";
String password = "password";
String host = "test.rebex.net";
int port = 22;
String command = "ls";
String responseString = JschDemo.listFolderStructure(username, password, host, port, command);
assertNotNull(responseString);
}
@Test(expected = Exception.class)
public void givenInvalidCredentials_whenConnectionAttemptIsMade_thenServerReturnsErrorResponse() throws Exception {
String username = "invalidUsername";
String password = "password";
String host = "test.rebex.net";
int port = 22;
String command = "ls";
String responseString = JschDemo.listFolderStructure(username, password, host, port, command);
assertNull(responseString);
}
}