summaryrefslogtreecommitdiffhomepage
path: root/tests/test_client.py
diff options
context:
space:
mode:
authorTim Savage <tim.savage@westpacdatabank.com.au>2016-12-23 10:19:35 +1100
committerTim Savage <tim.savage@westpacdatabank.com.au>2016-12-23 10:19:35 +1100
commitea01666ad545f4229ed9c45eb83760d352065c6d (patch)
treed4d1f671c5a12116ddfb57e0afc126a412847aeb /tests/test_client.py
parent0a90a25cded021434630a9deede365dd84021788 (diff)
Added a test to check that the auth_timeout argument is passed through and applied.
Diffstat (limited to 'tests/test_client.py')
-rw-r--r--tests/test_client.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_client.py b/tests/test_client.py
index 32d9ac60..2949d242 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -60,6 +60,9 @@ class NullServer (paramiko.ServerInterface):
def check_auth_password(self, username, password):
if (username == 'slowdive') and (password == 'pygmalion'):
return paramiko.AUTH_SUCCESSFUL
+ if (username == 'slowdive') and (password == 'unresponsive-server'):
+ time.sleep(5)
+ return paramiko.AUTH_SUCCESSFUL
return paramiko.AUTH_FAILED
def check_auth_publickey(self, username, key):
@@ -380,6 +383,24 @@ class SSHClientTest (unittest.TestCase):
)
self._test_connection(**kwargs)
+ def test_9_auth_timeout(self):
+ """
+ verify that the SSHClient has a configurable auth timeout
+ """
+ threading.Thread(target=self._run).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 auth timeout
+ kwargs = dict(self.connect_kwargs, password='unresponsive-server', auth_timeout=0.5)
+ self.assertRaises(
+ paramiko.AuthenticationException,
+ self.tc.connect,
+ **kwargs
+ )
+
def test_update_environment(self):
"""
Verify that environment variables can be set by the client.