summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2022-05-20 15:08:24 -0400
committerJeff Forcier <jeff@bitprophet.org>2022-05-20 15:08:24 -0400
commit5c11bb6e874f93f3db5c0d442e3678b1eb884580 (patch)
treed2ad8a3e72ede3ca69c759c057b9db214bb41f22
parentc4d0b0e8cb316866659f8bd238ba3f44cc8bc519 (diff)
downloadparamiko-5c11bb6e874f93f3db5c0d442e3678b1eb884580.tar.gz
Add test proving #1599
-rw-r--r--tests/blank_rsa.key0
-rw-r--r--tests/test_pkey.py5
2 files changed, 5 insertions, 0 deletions
diff --git a/tests/blank_rsa.key b/tests/blank_rsa.key
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/blank_rsa.key
diff --git a/tests/test_pkey.py b/tests/test_pkey.py
index 687e776b..6acb9121 100644
--- a/tests/test_pkey.py
+++ b/tests/test_pkey.py
@@ -184,6 +184,11 @@ class KeyTest(unittest.TestCase):
with pytest.raises(SSHException, match=str(exception)):
RSAKey.from_private_key_file(_support("test_rsa.key"))
+ def test_loading_empty_keys_errors_usefully(self):
+ # #1599 - raise SSHException instead of IndexError
+ with pytest.raises(SSHException, match="no lines"):
+ RSAKey.from_private_key_file(_support("blank_rsa.key"))
+
def test_load_rsa_password(self):
key = RSAKey.from_private_key_file(
_support("test_rsa_password.key"), "television"