Esempio n. 1
0
 def test_get_pkey_obj_with_plain_key(self):
     fname = 'test_ed25519.key'
     cls = paramiko.Ed25519Key
     key = read_file(os.path.join(base_dir, 'tests', fname))
     pkey = IndexHandler.get_pkey_obj(key, None)
     self.assertIsInstance(pkey, cls)
     pkey = IndexHandler.get_pkey_obj(key, 'iginored')
     self.assertIsInstance(pkey, cls)
     with self.assertRaises(ValueError):
         pkey = IndexHandler.get_pkey_obj('x' + key, None)
Esempio n. 2
0
 def test_get_pkey_obj_with_plain_key(self):
     fname = 'test_ed25519.key'
     cls = paramiko.Ed25519Key
     key = read_file(make_tests_data_path(fname))
     pkey = IndexHandler.get_pkey_obj(key, None, fname)
     self.assertIsInstance(pkey, cls)
     pkey = IndexHandler.get_pkey_obj(key, 'iginored', fname)
     self.assertIsInstance(pkey, cls)
     with self.assertRaises(InvalidException) as exc:
         pkey = IndexHandler.get_pkey_obj('x' + key, None, fname)
         self.assertIn('Invalid private key', str(exc))
Esempio n. 3
0
 def test_get_pkey_obj_with_encrypted_key(self):
     fname = 'test_ed25519_password.key'
     password = '******'
     cls = paramiko.Ed25519Key
     key = read_file(os.path.join(base_dir, 'tests', fname))
     pkey = IndexHandler.get_pkey_obj(key, password)
     self.assertIsInstance(pkey, cls)
     with self.assertRaises(ValueError):
         pkey = IndexHandler.get_pkey_obj(key, 'wrongpass')
     with self.assertRaises(ValueError):
         pkey = IndexHandler.get_pkey_obj('x' + key, password)
Esempio n. 4
0
 def test_get_pkey_obj_with_encrypted_key(self):
     fname = 'test_ed25519_password.key'
     password = '******'
     cls = paramiko.Ed25519Key
     key = read_file(make_tests_data_path(fname))
     pkey = IndexHandler.get_pkey_obj(key, password, fname)
     self.assertIsInstance(pkey, cls)
     with self.assertRaises(InvalidException) as exc:
         pkey = IndexHandler.get_pkey_obj(key, 'wrongpass', fname)
         self.assertIn('Wrong password', str(exc))
     with self.assertRaises(InvalidException) as exc:
         pkey = IndexHandler.get_pkey_obj('x' + key, password, fname)
         self.assertIn('Invalid private key', str(exc))