mirror of https://github.com/huashengdun/webssh
Re-raise InvalidValueError for PasswordRequiredException
parent
e1cd3efdf0
commit
786b42da7e
|
@ -170,8 +170,9 @@ class TestIndexHandler(unittest.TestCase):
|
||||||
pkey = IndexHandler.get_specific_pkey(cls, 'x'+key, None)
|
pkey = IndexHandler.get_specific_pkey(cls, 'x'+key, None)
|
||||||
self.assertIsNone(pkey)
|
self.assertIsNone(pkey)
|
||||||
|
|
||||||
with self.assertRaises(paramiko.PasswordRequiredException):
|
with self.assertRaises(InvalidValueError) as ctx:
|
||||||
pkey = IndexHandler.get_specific_pkey(cls, key, None)
|
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):
|
def test_get_pkey_obj_with_plain_key(self):
|
||||||
fname = 'test_ed25519.key'
|
fname = 'test_ed25519.key'
|
||||||
|
@ -205,8 +206,9 @@ class TestIndexHandler(unittest.TestCase):
|
||||||
pkey = IndexHandler.get_pkey_obj('x'+key, '', fname)
|
pkey = IndexHandler.get_pkey_obj('x'+key, '', fname)
|
||||||
self.assertIn('Invalid private key', str(ctx.exception))
|
self.assertIn('Invalid private key', str(ctx.exception))
|
||||||
|
|
||||||
with self.assertRaises(paramiko.PasswordRequiredException):
|
with self.assertRaises(InvalidValueError) as ctx:
|
||||||
pkey = IndexHandler.get_pkey_obj(key, '', fname)
|
pkey = IndexHandler.get_specific_pkey(cls, key, None)
|
||||||
|
self.assertIn('Need a password', str(ctx.exception))
|
||||||
|
|
||||||
|
|
||||||
class TestWsockHandler(unittest.TestCase):
|
class TestWsockHandler(unittest.TestCase):
|
||||||
|
|
|
@ -226,7 +226,9 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
|
||||||
pkey = pkeycls.from_private_key(io.StringIO(privatekey),
|
pkey = pkeycls.from_private_key(io.StringIO(privatekey),
|
||||||
password=password)
|
password=password)
|
||||||
except paramiko.PasswordRequiredException:
|
except paramiko.PasswordRequiredException:
|
||||||
raise
|
raise InvalidValueError(
|
||||||
|
'Need a password to decrypt the private key.'
|
||||||
|
)
|
||||||
except paramiko.SSHException:
|
except paramiko.SSHException:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue