diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2022-11-04 17:53:44 -0400 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2022-11-04 17:58:06 -0400 |
commit | 3d4e999e240729567663df8a6cddebc68e2983ff (patch) | |
tree | 478d06bebaa0e0b2f0cdbf732115fb7becb10667 /tests/test_client.py | |
parent | 4e7f7e8033b7ca4b2805beb33a1164881adaf80c (diff) |
Write basic test re #2125, including kwarg default value tweak
Diffstat (limited to 'tests/test_client.py')
-rw-r--r-- | tests/test_client.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/test_client.py b/tests/test_client.py index fd54140b..3eaad4fb 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -739,6 +739,40 @@ class SSHClientTest(ClientTest): call_arg = Transport.call_args[1]["disabled_algorithms"] assert call_arg == {"keys": ["ssh-dss"]} + @patch("paramiko.client.Transport") + def test_transport_factory_defaults_to_Transport(self, Transport): + sock, kex, creds, algos = Mock(), Mock(), Mock(), Mock() + SSHClient().connect( + "host", + sock=sock, + password="no", + gss_kex=kex, + gss_deleg_creds=creds, + disabled_algorithms=algos, + ) + Transport.assert_called_once_with( + sock, gss_kex=kex, gss_deleg_creds=creds, disabled_algorithms=algos + ) + + @patch("paramiko.client.Transport") + def test_transport_factory_may_be_specified(self, Transport): + factory = Mock() + sock, kex, creds, algos = Mock(), Mock(), Mock(), Mock() + SSHClient().connect( + "host", + sock=sock, + password="no", + gss_kex=kex, + gss_deleg_creds=creds, + disabled_algorithms=algos, + transport_factory=factory, + ) + factory.assert_called_once_with( + sock, gss_kex=kex, gss_deleg_creds=creds, disabled_algorithms=algos + ) + # Safety check + assert not Transport.called + class PasswordPassphraseTests(ClientTest): # TODO: most of these could reasonably be set up to use mocks/assertions |