summaryrefslogtreecommitdiffhomepage
path: root/tests/test_transport.py
diff options
context:
space:
mode:
authorRobey Pointer <robey@lag.net>2007-12-30 21:29:50 -0800
committerRobey Pointer <robey@lag.net>2007-12-30 21:29:50 -0800
commitba1fd0d61bc5c103004d496473681b2a4dce0f3b (patch)
tree21afc0f9e68df6d45a520304dc4b3080eeef10a5 /tests/test_transport.py
parent06d3471b463ffe798d42e7d24e294bbc616d8358 (diff)
[project @ robey@lag.net-20071231052950-8h599bnez3sgbf2e]
patch from david guerizec for direct-tcpip forwarding support, and a unit test added by yours truly.
Diffstat (limited to 'tests/test_transport.py')
-rw-r--r--tests/test_transport.py39
1 files changed, 36 insertions, 3 deletions
diff --git a/tests/test_transport.py b/tests/test_transport.py
index d9ac1780..187fee90 100644
--- a/tests/test_transport.py
+++ b/tests/test_transport.py
@@ -119,6 +119,10 @@ class NullServer (ServerInterface):
self._listen.close()
self._listen = None
+ def check_channel_direct_tcpip_request(self, chanid, origin, destination):
+ self._tcpip_dest = destination
+ return OPEN_SUCCEEDED
+
class TransportTest (unittest.TestCase):
@@ -625,7 +629,7 @@ class TransportTest (unittest.TestCase):
cs = socket.socket()
cs.connect(('', port))
ss, _ = self.server._listen.accept()
- sch = self.ts.open_forwarded_tcpip_channel(ss.getpeername(), ss.getsockname())
+ sch = self.ts.open_forwarded_tcpip_channel(ss.getsockname(), ss.getpeername())
cch = self.tc.accept()
sch.send('hello')
@@ -639,7 +643,36 @@ class TransportTest (unittest.TestCase):
self.tc.cancel_port_forward('', port)
self.assertTrue(self.server._listen is None)
- def test_K_stderr_select(self):
+ def test_K_port_forwarding(self):
+ """
+ verify that a client can forward new connections from a locally-
+ forwarded port.
+ """
+ self.setup_test_server()
+ chan = self.tc.open_session()
+ chan.exec_command('yes')
+ schan = self.ts.accept(1.0)
+
+ # open a port on the "server" that the client will ask to forward to.
+ greeting_server = socket.socket()
+ greeting_server.listen(1)
+ greeting_port = greeting_server.getsockname()[1]
+
+ cs = self.tc.open_channel('direct-tcpip', ('', greeting_port), ('', 9000))
+ sch = self.ts.accept(1.0)
+ cch = socket.socket()
+ cch.connect(self.server._tcpip_dest)
+
+ ss, _ = greeting_server.accept()
+ ss.send('Hello!\n')
+ ss.close()
+ sch.send(cch.recv(8192))
+ sch.close()
+
+ self.assertEquals('Hello!\n', cs.recv(7))
+ cs.close()
+
+ def test_L_stderr_select(self):
"""
verify that select() on a channel works even if only stderr is
receiving data.
@@ -678,7 +711,7 @@ class TransportTest (unittest.TestCase):
schan.close()
chan.close()
- def test_L_send_ready(self):
+ def test_M_send_ready(self):
"""
verify that send_ready() indicates when a send would not block.
"""