webssh

Web based ssh client https://github.com/huashengdun/webssh webssh.huashengdun.org/
git clone http://git.hanabi.in/repos/webssh.git
Log | Files | Refs | README | LICENSE

commit 786b42da7e6f3b83e47bd9a357e9fbd9957e4d6d
parent e1cd3efdf0534ec4a8244dfaa0e4316dd5d16af6
Author: Sheng <webmaster0115@gmail.com>
Date:   Sun, 19 May 2019 20:27:44 +0800

Re-raise InvalidValueError for PasswordRequiredException

Diffstat:
Mtests/test_handler.py | 8+++++---
Mwebssh/handler.py | 4+++-
2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/tests/test_handler.py b/tests/test_handler.py @@ -170,8 +170,9 @@ class TestIndexHandler(unittest.TestCase): pkey = IndexHandler.get_specific_pkey(cls, 'x'+key, None) self.assertIsNone(pkey) - with self.assertRaises(paramiko.PasswordRequiredException): + with self.assertRaises(InvalidValueError) as ctx: pkey = IndexHandler.get_specific_pkey(cls, key, None) + self.assertIn('Need a password', str(ctx.exception)) def test_get_pkey_obj_with_plain_key(self): fname = 'test_ed25519.key' @@ -205,8 +206,9 @@ class TestIndexHandler(unittest.TestCase): pkey = IndexHandler.get_pkey_obj('x'+key, '', fname) self.assertIn('Invalid private key', str(ctx.exception)) - with self.assertRaises(paramiko.PasswordRequiredException): - pkey = IndexHandler.get_pkey_obj(key, '', fname) + with self.assertRaises(InvalidValueError) as ctx: + pkey = IndexHandler.get_specific_pkey(cls, key, None) + self.assertIn('Need a password', str(ctx.exception)) class TestWsockHandler(unittest.TestCase): diff --git a/webssh/handler.py b/webssh/handler.py @@ -226,7 +226,9 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler): pkey = pkeycls.from_private_key(io.StringIO(privatekey), password=password) except paramiko.PasswordRequiredException: - raise + raise InvalidValueError( + 'Need a password to decrypt the private key.' + ) except paramiko.SSHException: pass else: