summaryrefslogtreecommitdiffhomepage
path: root/tests/test_client.py
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2014-09-10 12:58:02 -0700
committerJeff Forcier <jeff@bitprophet.org>2014-09-10 12:58:02 -0700
commitbade24d2d5b76c3f38bf0310ea8072184ab95b2a (patch)
tree160c9e52fc9911696247c1fe9e4bfec3c15ab662 /tests/test_client.py
parent0063e64046c732e8c50fc5f54234942feaa313d9 (diff)
parente71f4e59878a636268475f642ed4e98a1b3e375d (diff)
Merge branch 'master' into 216-int
Conflicts: paramiko/transport.py paramiko/util.py tests/test_client.py
Diffstat (limited to 'tests/test_client.py')
-rw-r--r--tests/test_client.py31
1 files changed, 29 insertions, 2 deletions
diff --git a/tests/test_client.py b/tests/test_client.py
index b3635272..28d1cb46 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -29,6 +29,7 @@ import unittest
import weakref
import warnings
import os
+import time
from tests.util import test_path
import paramiko
from paramiko.common import PY2, b
@@ -93,7 +94,7 @@ class SSHClientTest (unittest.TestCase):
if hasattr(self, attr):
getattr(self, attr).close()
- def _run(self, allowed_keys=None):
+ def _run(self, allowed_keys=None, delay=0):
if allowed_keys is None:
allowed_keys = FINGERPRINTS.keys()
self.socks, addr = self.sockl.accept()
@@ -101,6 +102,8 @@ class SSHClientTest (unittest.TestCase):
host_key = paramiko.RSAKey.from_private_key_file(test_path('test_rsa.key'))
self.ts.add_server_key(host_key)
server = NullServer(allowed_keys=allowed_keys)
+ if delay:
+ time.sleep(delay)
self.ts.start_server(self.event, server)
def _test_connection(self, **kwargs):
@@ -264,6 +267,8 @@ class SSHClientTest (unittest.TestCase):
"""
# Unclear why this is borked on Py3, but it is, and does not seem worth
# pursuing at the moment.
+ # XXX: It's the release of the references to e.g packetizer that fails
+ # in py3...
if not PY2:
return
threading.Thread(target=self._run).start()
@@ -296,7 +301,7 @@ class SSHClientTest (unittest.TestCase):
self.assertTrue(p() is None)
- def test_6_client_can_be_used_as_context_manager(self):
+ def test_client_can_be_used_as_context_manager(self):
"""
verify that an SSHClient can be used a context manager
"""
@@ -317,3 +322,25 @@ class SSHClientTest (unittest.TestCase):
self.assertTrue(self.tc._transport is not None)
self.assertTrue(self.tc._transport is None)
+
+ def test_7_banner_timeout(self):
+ """
+ verify that the SSHClient has a configurable banner timeout.
+ """
+ # Start the thread with a 1 second wait.
+ threading.Thread(target=self._run, kwargs={'delay': 1}).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 half second banner timeout.
+ self.assertRaises(
+ paramiko.SSHException,
+ self.tc.connect,
+ self.addr,
+ self.port,
+ username='slowdive',
+ password='pygmalion',
+ banner_timeout=0.5
+ )