summaryrefslogtreecommitdiffhomepage
path: root/tests/test_client.py
diff options
context:
space:
mode:
authorCory Benfield <lukasaoz@gmail.com>2014-08-14 20:43:55 +0100
committerCory Benfield <lukasaoz@gmail.com>2014-08-14 21:06:51 +0100
commit3b9eaefebb1b2e55b6392d5c55ac07594cc057e3 (patch)
tree2e305038f94d1aab1a89b6e390858d9247907808 /tests/test_client.py
parent2ee8ec8cde1b8f893cfbaf0b1482bd922f3b850f (diff)
Test banner timeout.
Diffstat (limited to 'tests/test_client.py')
-rw-r--r--tests/test_client.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/test_client.py b/tests/test_client.py
index 7e5c80b4..1867fb78 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -27,6 +27,7 @@ import unittest
import weakref
import warnings
import os
+import time
from tests.util import test_path
import paramiko
from paramiko.common import PY2
@@ -72,12 +73,14 @@ class SSHClientTest (unittest.TestCase):
if hasattr(self, attr):
getattr(self, attr).close()
- def _run(self):
+ def _run(self, delay=0):
self.socks, addr = self.sockl.accept()
self.ts = paramiko.Transport(self.socks)
host_key = paramiko.RSAKey.from_private_key_file(test_path('test_rsa.key'))
self.ts.add_server_key(host_key)
server = NullServer()
+ if delay:
+ time.sleep(delay)
self.ts.start_server(self.event, server)
def test_1_client(self):
@@ -252,3 +255,25 @@ class SSHClientTest (unittest.TestCase):
gc.collect()
self.assertTrue(p() is None)
+
+ def test_7_banner_timeout(self):
+ """
+ verify that the SSHClient has a configurable banner timeout.
+ """
+ # Start the thread with a 5 second wait.
+ threading.Thread(target=self._run, args=(5,)).start()
+ host_key = paramiko.RSAKey.from_private_key_file(test_path('test_rsa.key'))
+ public_host_key = paramiko.RSAKey(data=host_key.asbytes())
+
+ self.tc = paramiko.SSHClient()
+ self.tc.get_host_keys().add('[%s]:%d' % (self.addr, self.port), 'ssh-rsa', public_host_key)
+ # Connect with a three second banner timeout.
+ self.assertRaises(
+ paramiko.SSHException,
+ self.tc.connect,
+ self.addr,
+ self.port,
+ username='slowdive',
+ password='pygmalion',
+ banner_timeout=3
+ )