26
26
27
27
from pssh .clients .native import SSHClient
28
28
from ssh2 .session import Session
29
- from ssh2 .exceptions import SocketDisconnectError , BannerRecvError , SocketRecvError , \
30
- AgentConnectionError , AgentListIdentitiesError , \
31
- AgentAuthenticationError , AgentGetIdentityError , SFTPProtocolError
32
- from pssh .exceptions import AuthenticationException , ConnectionErrorException , \
33
- SessionError , SFTPIOError , SFTPError , SCPError , PKeyFileError , Timeout , \
34
- AuthenticationError
29
+ from ssh2 .exceptions import (SocketDisconnectError , BannerRecvError , SocketRecvError ,
30
+ AgentConnectionError , AgentListIdentitiesError ,
31
+ AgentAuthenticationError , AgentGetIdentityError , SFTPProtocolError ,
32
+ AuthenticationError as SSH2AuthenticationError ,
33
+ )
34
+ from pssh .exceptions import (AuthenticationException , ConnectionErrorException ,
35
+ SessionError , SFTPIOError , SFTPError , SCPError , PKeyFileError , Timeout ,
36
+ AuthenticationError ,
37
+ )
35
38
36
39
from .base_ssh2_case import SSH2TestCase
37
40
@@ -292,10 +295,16 @@ def test_identity_auth_failure(self):
292
295
allow_agent = False )
293
296
294
297
def test_password_auth_failure (self ):
295
- self .assertRaises (AuthenticationException ,
296
- SSHClient , self .host , port = self .port , num_retries = 1 ,
297
- allow_agent = False ,
298
- password = 'blah blah blah' )
298
+ try :
299
+ client = SSHClient (self .host , port = self .port , num_retries = 1 ,
300
+ allow_agent = False ,
301
+ identity_auth = False ,
302
+ password = 'blah blah blah' ,
303
+ )
304
+ except AuthenticationException as ex :
305
+ self .assertIsInstance (ex .args [3 ], SSH2AuthenticationError )
306
+ else :
307
+ raise AssertionError
299
308
300
309
def test_retry_failure (self ):
301
310
self .assertRaises (ConnectionErrorException ,
@@ -311,7 +320,9 @@ def test_auth_retry_failure(self):
311
320
password = 'fake' ,
312
321
num_retries = 3 ,
313
322
retry_delay = .1 ,
314
- allow_agent = False )
323
+ allow_agent = False ,
324
+ identity_auth = False ,
325
+ )
315
326
316
327
def test_connection_timeout (self ):
317
328
cmd = spawn (SSHClient , 'fakehost.com' , port = 12345 ,
0 commit comments