You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2020/04/04 20:45:04 UTC
[libcloud] 02/21: Add a test case for it.
This is an automated email from the ASF dual-hosted git repository.
tomaz pushed a commit to branch 2.8.x
in repository https://gitbox.apache.org/repos/asf/libcloud.git
commit fcf8613f4568c990d495cc56a9d3500666765009
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Tue Mar 31 22:54:14 2020 +0200
Add a test case for it.
---
libcloud/test/compute/test_ssh_client.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/libcloud/test/compute/test_ssh_client.py b/libcloud/test/compute/test_ssh_client.py
index 2704d1c..dc59df5 100644
--- a/libcloud/test/compute/test_ssh_client.py
+++ b/libcloud/test/compute/test_ssh_client.py
@@ -163,6 +163,26 @@ class ParamikoSSHClientTests(LibcloudTestCase):
assertRaisesRegex(self, paramiko.ssh_exception.SSHException,
expected_msg, mock.connect)
+ @patch('paramiko.SSHClient', Mock)
+ def test_password_protected_key_no_password_provided(self):
+ path = os.path.join(os.path.dirname(__file__),
+ 'fixtures', 'misc',
+ 'test_rsa_2048b_pass_foobar.key')
+
+ # Supplied as key_material
+ with open(path, 'r') as fp:
+ private_key = fp.read()
+
+ conn_params = {'hostname': 'dummy.host.org',
+ 'username': 'ubuntu',
+ 'key_material': private_key}
+
+ mock = ParamikoSSHClient(**conn_params)
+
+ expected_msg = 'private key file is encrypted'
+ assertRaisesRegex(self, paramiko.ssh_exception.PasswordRequiredException,
+ expected_msg, mock.connect)
+
def test_key_material_valid_pem_keys_invalid_header_auto_conversion(self):
# Test a scenario where valid PEM keys with invalid headers which is
# not recognized by paramiko are automatically converted in a format