Пример #1
0
 def test_key_auth(self):
     self.assertEqual(self.session.connect(), 0)
     self.assertRaises(KeyImportError, import_pubkey_file, self.user_key)
     key = import_pubkey_file(self.user_pub_key)
     self.assertIsInstance(key, SSHKey)
     self.assertEqual(self.session.userauth_try_publickey(key), 0)
     # Private key as public key import error
     self.assertRaises(KeyImportError, import_privkey_file,
                       self.user_pub_key)
     pkey = import_privkey_file(self.user_key)
     self.assertEqual(self.session.userauth_publickey(pkey), 0)
Пример #2
0
 def test_should_not_segfault(self):
     session = Session()
     self.assertEqual(session.get_error(), '')
     self.assertRaises(InvalidAPIUse, session.userauth_none)
     self.assertRaises(InvalidAPIUse, session.userauth_publickey, self.pkey)
     key = import_pubkey_file(self.user_pub_key)
     self.assertRaises(InvalidAPIUse, session.userauth_try_publickey, key)
     self.assertRaises(InvalidAPIUse, session.userauth_publickey_auto, '')
     self.assertRaises(InvalidAPIUse, session.channel_new)
     self.assertRaises(InvalidAPIUse, session.get_disconnect_message)
     self.assertRaises(InvalidAPIUse, session.get_issue_banner)
     self.assertRaises(InvalidAPIUse, session.get_openssh_version)
     self.assertIsNone(session.dump_knownhost())
     self.assertIsNone(session.get_clientbanner())
     self.assertIsNone(session.get_serverbanner())
     self.assertIsNone(session.get_kex_algo())
     self.assertIsNone(session.get_cipher_in())
     self.assertIsNone(session.get_cipher_out())
     self.assertIsNone(session.get_hmac_in())
     self.assertIsNone(session.get_hmac_out())
     self.assertIsNotNone(session.get_error_code())
     session.connector_new()