2626
2727from pssh .clients .native import SSHClient
2828from 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+ )
3538
3639from .base_ssh2_case import SSH2TestCase
3740
@@ -292,10 +295,16 @@ def test_identity_auth_failure(self):
292295 allow_agent = False )
293296
294297 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
299308
300309 def test_retry_failure (self ):
301310 self .assertRaises (ConnectionErrorException ,
@@ -311,7 +320,9 @@ def test_auth_retry_failure(self):
311320 password = 'fake' ,
312321 num_retries = 3 ,
313322 retry_delay = .1 ,
314- allow_agent = False )
323+ allow_agent = False ,
324+ identity_auth = False ,
325+ )
315326
316327 def test_connection_timeout (self ):
317328 cmd = spawn (SSHClient , 'fakehost.com' , port = 12345 ,
0 commit comments