diff options
Diffstat (limited to 'tests/test_auth.py')
-rw-r--r-- | tests/test_auth.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test_auth.py b/tests/test_auth.py index 45dcb3a4..6358a053 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -23,6 +23,7 @@ Some unit tests for authenticating over a Transport. import sys import threading import unittest +from time import sleep from paramiko import ( Transport, @@ -84,6 +85,9 @@ class NullServer(ServerInterface): return AUTH_SUCCESSFUL if username == "bad-server": raise Exception("Ack!") + if username == "unresponsive-server": + sleep(5) + return AUTH_SUCCESSFUL return AUTH_FAILED def check_auth_publickey(self, username, key): @@ -250,3 +254,18 @@ class AuthTest(unittest.TestCase): except: etype, evalue, etb = sys.exc_info() self.assertTrue(issubclass(etype, AuthenticationException)) + + def test_9_auth_non_responsive(self): + """ + verify that authentication times out if server takes to long to + respond (or never responds). + """ + self.tc.auth_timeout = 1 # 1 second, to speed up test + self.start_server() + self.tc.connect() + try: + remain = self.tc.auth_password("unresponsive-server", "hello") + except: + etype, evalue, etb = sys.exc_info() + self.assertTrue(issubclass(etype, AuthenticationException)) + self.assertTrue("Authentication timeout" in str(evalue)) |