diff --git a/.travis.yml b/.travis.yml index 8300ef05..48f62ca0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,15 @@ language: java dist: trusty -sudo: false +sudo: required +services: + - docker + +before_install: +- docker build -t sshj/test-sshd . +- docker run -d -p 127.0.0.1:2222:22 sshj/test-sshd +- docker ps -a + before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock diff --git a/src/test/java/com/hierynomus/sshj/IntegrationTest.java b/src/test/java/com/hierynomus/sshj/IntegrationTest.java index 8ee1e709..0972c0ec 100644 --- a/src/test/java/com/hierynomus/sshj/IntegrationTest.java +++ b/src/test/java/com/hierynomus/sshj/IntegrationTest.java @@ -18,6 +18,10 @@ package com.hierynomus.sshj; import net.schmizz.sshj.DefaultConfig; import net.schmizz.sshj.SSHClient; import net.schmizz.sshj.transport.verification.OpenSSHKnownHosts; +import net.schmizz.sshj.transport.verification.PromiscuousVerifier; +import net.schmizz.sshj.userauth.keyprovider.KeyProvider; +import net.schmizz.sshj.userauth.keyprovider.KeyProviderUtil; + import org.junit.Ignore; import org.junit.Test; @@ -28,12 +32,12 @@ import static org.hamcrest.MatcherAssert.assertThat; public class IntegrationTest { - @Test @Ignore // Should only be enabled for testing against VM + @Test // Should only be enabled for testing against VM public void shouldConnect() throws IOException { SSHClient sshClient = new SSHClient(new DefaultConfig()); - sshClient.addHostKeyVerifier(new OpenSSHKnownHosts(new File("/Users/ajvanerp/.ssh/known_hosts"))); - sshClient.connect("172.16.37.147"); - sshClient.authPublickey("jeroen"); + sshClient.addHostKeyVerifier(new PromiscuousVerifier()); + sshClient.connect("192.168.99.100", 2222); + sshClient.authPublickey("sickp", "src/test/resources/id_rsa.ppk"); assertThat("Is connected", sshClient.isAuthenticated()); } } diff --git a/src/test/resources/Dockerfile b/src/test/resources/Dockerfile new file mode 100644 index 00000000..0c0867ec --- /dev/null +++ b/src/test/resources/Dockerfile @@ -0,0 +1,8 @@ +FROM sickp/alpine-sshd:7.5 +ADD https://raw.githubusercontent.com/Igerly/sshj/master/src/test/resources/id_rsa.pub /home/sickp/.ssh/authorized_keys +RUN \ + echo "root:sunshine" | chpasswd && \ + adduser -D -s /bin/ash sickp && \ + passwd -u sickp && \ + chown -R sickp:sickp /home/sickp +