# HG changeset patch # User Jeff Forcier <jeff@bitprophet.org> # Date 1653073704 14400 # Fri May 20 15:08:24 2022 -0400 # Node ID 91d6f61f5a442bac68719b9c355bcf3629c47a23 # Parent da3278219748a3d163c58b697712d2b6402d7fa6 Add test proving #1599 diff --git a/tests/blank_rsa.key b/tests/blank_rsa.key new file mode 100644 diff --git a/tests/test_pkey.py b/tests/test_pkey.py --- a/tests/test_pkey.py +++ b/tests/test_pkey.py @@ -184,6 +184,11 @@ 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"