summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobey Pointer <robey@ralph.lag.net>2005-12-03 20:32:58 -0800
committerRobey Pointer <robey@ralph.lag.net>2005-12-03 20:32:58 -0800
commit93ee12a1946fa0529aa3ce5dccba34b699eff0cb (patch)
treec2a5ce86a781f92076ebfd73bb5048eb7e505e61
parentfdf927cffd1801fed114f241a1cf63fd3b54f15f (diff)
[project @ robey@ralph.lag.net-20051204043258-3d82f58e781edf13]
add unit test for compression
-rw-r--r--tests/test_transport.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/test_transport.py b/tests/test_transport.py
index c97fb160..5fcc7865 100644
--- a/tests/test_transport.py
+++ b/tests/test_transport.py
@@ -540,3 +540,34 @@ class TransportTest (unittest.TestCase):
self.assertNotEquals(self.tc.H, self.tc.session_id)
schan.close()
+
+ def test_G_compression(self):
+ """
+ verify that zlib compression is basically working.
+ """
+ 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)
+ self.ts.get_security_options().compression = ('zlib',)
+ self.tc.get_security_options().compression = ('zlib',)
+ 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())
+
+ chan = self.tc.open_session()
+ self.assert_(chan.exec_command('yes'))
+ schan = self.ts.accept(1.0)
+
+ bytes = self.tc.packetizer._Packetizer__sent_bytes
+ chan.send('x' * 1024)
+ bytes2 = self.tc.packetizer._Packetizer__sent_bytes
+ # tests show this is actually compressed to *52 bytes*! including packet overhead! nice!! :)
+ self.assert_(bytes2 - bytes < 1024)
+
+ chan.close()
+ schan.close()