summaryrefslogtreecommitdiffhomepage
path: root/tests/test_transport.py
diff options
context:
space:
mode:
authorRobey Pointer <robey@lag.net>2005-10-29 20:47:04 +0000
committerRobey Pointer <robey@lag.net>2005-10-29 20:47:04 +0000
commit66919286b6a9865d667e28654c42c78d43e876ca (patch)
tree24bb3431d550f3aa579340808fec12e76bd7868a /tests/test_transport.py
parent3c67e35b5f6fbc686141c31d513195705fff14d7 (diff)
[project @ Arch-1:robey@lag.net--2005-master-shake%paramiko--dev--1--patch-72]
don't attempt to start a rekey negotiation from within send_message -- always do it from the feeder thread. this prevents a situation where more than one thread may decide spontaneously to rekey, sending multiple kexinit messages, which confuses the hell out of the remote host :) also, do some locking around the clear-to-send event, to avoid a race when we first go into rekeying. add some tests for these things too
Diffstat (limited to 'tests/test_transport.py')
-rw-r--r--tests/test_transport.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_transport.py b/tests/test_transport.py
index 81254b48..c97fb160 100644
--- a/tests/test_transport.py
+++ b/tests/test_transport.py
@@ -504,3 +504,39 @@ class TransportTest (unittest.TestCase):
self.assertEquals('', chan.recv(16))
chan.close()
+
+ def test_F_renegotiate(self):
+ """
+ verify that a transport can correctly renegotiate mid-stream.
+ """
+ host_key = RSAKey.from_private_key_file('tests/test_rsa.key')
+ public_host_key = RSAKey(data=str(host_key))
+ self.ts.add_server_key(host_key)
+ event = threading.Event()
+ server = NullServer()
+ self.ts.start_server(event, server)
+ self.tc.connect(hostkey=public_host_key,
+ username='slowdive', password='pygmalion')
+ event.wait(1.0)
+ self.assert_(event.isSet())
+ self.assert_(self.ts.is_active())
+
+ self.tc.packetizer.REKEY_BYTES = 16384
+
+ chan = self.tc.open_session()
+ self.assert_(chan.exec_command('yes'))
+ schan = self.ts.accept(1.0)
+
+ self.assertEquals(self.tc.H, self.tc.session_id)
+ for i in range(20):
+ chan.send('x' * 1024)
+ chan.close()
+
+ # allow a few seconds for the rekeying to complete
+ for i in xrange(50):
+ if self.tc.H != self.tc.session_id:
+ break
+ time.sleep(0.1)
+ self.assertNotEquals(self.tc.H, self.tc.session_id)
+
+ schan.close()