diff --git a/build.gradle b/build.gradle index d089fca6..dc9be4a6 100644 --- a/build.gradle +++ b/build.gradle @@ -57,6 +57,8 @@ dependencies { testCompile "org.mockito:mockito-core:1.9.5" testCompile "org.apache.sshd:sshd-core:1.0.0" testRuntime "ch.qos.logback:logback-classic:1.1.2" + testCompile 'org.glassfish.grizzly:grizzly-http-server:2.3.17' + } jar { diff --git a/src/test/java/com/hierynomus/sshj/connection/channel/forwarded/RemotePortForwarderTest.java b/src/test/java/com/hierynomus/sshj/connection/channel/forwarded/RemotePortForwarderTest.java new file mode 100644 index 00000000..579f06a9 --- /dev/null +++ b/src/test/java/com/hierynomus/sshj/connection/channel/forwarded/RemotePortForwarderTest.java @@ -0,0 +1,44 @@ +package com.hierynomus.sshj.connection.channel.forwarded; + +import com.hierynomus.sshj.test.HttpServer; +import com.hierynomus.sshj.test.SshFixture; +import com.hierynomus.sshj.test.util.FileUtil; +import net.schmizz.sshj.SSHClient; +import net.schmizz.sshj.connection.channel.forwarded.RemotePortForwarder; +import net.schmizz.sshj.connection.channel.forwarded.SocketForwardingConnectListener; +import org.apache.sshd.server.forward.AcceptAllForwardingFilter; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import java.io.File; +import java.io.IOException; +import java.net.InetSocketAddress; + +import static org.junit.Assert.*; + +public class RemotePortForwarderTest { + + @Rule + public SshFixture fixture = new SshFixture(); + + @Rule + public HttpServer httpServer = new HttpServer(); + + @Test + public void shouldDynamicallyForwardPort() throws IOException { + fixture.getServer().setTcpipForwardingFilter(new AcceptAllForwardingFilter()); + File file = httpServer.getDocRoot().newFile("index.html"); + FileUtil.writeToFile(file, "