mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-08 16:18:05 +03:00
- minor improvements
This commit is contained in:
@@ -26,9 +26,14 @@ import org.junit.Test;
|
|||||||
import net.schmizz.sshj.DefaultConfig;
|
import net.schmizz.sshj.DefaultConfig;
|
||||||
import net.schmizz.sshj.SSHClient;
|
import net.schmizz.sshj.SSHClient;
|
||||||
import net.schmizz.sshj.transport.verification.OpenSSHKnownHosts;
|
import net.schmizz.sshj.transport.verification.OpenSSHKnownHosts;
|
||||||
|
import net.schmizz.sshj.userauth.UserAuthException;
|
||||||
|
|
||||||
public class IntegrationTest {
|
public class IntegrationTest {
|
||||||
|
|
||||||
|
private static final int DOCKER_PORT = 2222;
|
||||||
|
private static final String USERNAME = "sshj";
|
||||||
|
private final static String SERVER_IP = System.getProperty("serverIP", "127.0.0.1");
|
||||||
|
|
||||||
@Test @Ignore // Should only be enabled for testing against VM
|
@Test @Ignore // Should only be enabled for testing against VM
|
||||||
public void shouldConnectVM() throws IOException {
|
public void shouldConnectVM() throws IOException {
|
||||||
SSHClient sshClient = new SSHClient(new DefaultConfig());
|
SSHClient sshClient = new SSHClient(new DefaultConfig());
|
||||||
@@ -38,12 +43,21 @@ public class IntegrationTest {
|
|||||||
assertThat("Is connected", sshClient.isAuthenticated());
|
assertThat("Is connected", sshClient.isAuthenticated());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // Should only be enabled for testing against VM
|
@Test
|
||||||
public void shouldConnect() throws IOException {
|
public void shouldConnect() throws IOException {
|
||||||
SSHClient sshClient = new SSHClient(new DefaultConfig());
|
SSHClient sshClient = new SSHClient(new DefaultConfig());
|
||||||
sshClient.addHostKeyVerifier("d3:6a:a9:52:05:ab:b5:48:dd:73:60:18:0c:3a:f0:a3"); // test-containers/ssh_host_ecdsa_key's fingerprint
|
sshClient.addHostKeyVerifier("d3:6a:a9:52:05:ab:b5:48:dd:73:60:18:0c:3a:f0:a3"); // test-containers/ssh_host_ecdsa_key's fingerprint
|
||||||
sshClient.connect("127.0.0.1", 2222);
|
sshClient.connect(SERVER_IP, DOCKER_PORT);
|
||||||
sshClient.authPublickey("sshj", "src/test/resources/id_rsa");
|
sshClient.authPublickey(USERNAME, "src/test/resources/id_rsa");
|
||||||
assertThat("Is connected", sshClient.isAuthenticated());
|
assertThat("Is connected", sshClient.isAuthenticated());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected = UserAuthException.class)
|
||||||
|
public void shouldFailWithWrongKey() throws IOException {
|
||||||
|
SSHClient sshClient = new SSHClient(new DefaultConfig());
|
||||||
|
sshClient.addHostKeyVerifier("d3:6a:a9:52:05:ab:b5:48:dd:73:60:18:0c:3a:f0:a3"); // test-containers/ssh_host_ecdsa_key's fingerprint
|
||||||
|
sshClient.connect(SERVER_IP, DOCKER_PORT);
|
||||||
|
sshClient.authPublickey(USERNAME, "src/test/resources/id_dsa");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
FROM sickp/alpine-sshd:7.5
|
FROM sickp/alpine-sshd:7.5
|
||||||
|
|
||||||
ADD id_rsa.pub /home/sshj/.ssh/authorized_keys
|
ADD id_rsa.pub /home/sshj/.ssh/authorized_keys
|
||||||
|
|
||||||
ADD test-container/ssh_host_ecdsa_key /etc/ssh/ssh_host_ecdsa_key
|
ADD test-container/ssh_host_ecdsa_key /etc/ssh/ssh_host_ecdsa_key
|
||||||
|
|||||||
Reference in New Issue
Block a user