def test_get_private_key(self):
     km = self._key_manager()
     yield km._openpgp.put_raw_key(PRIVATE_KEY, ADDRESS)
     # get the key
     key = yield km.get_key(ADDRESS, private=True, fetch_remote=False)
     self.assertTrue(key is not None)
     self.assertTrue(ADDRESS in key.uids)
     self.assertEqual(key.fingerprint.lower(), KEY_FINGERPRINT.lower())
     self.assertTrue(key.private)
示例#2
0
 def test_get_inactive_private_key(self):
     km = self._key_manager()
     yield km._openpgp.put_raw_key(PRIVATE_KEY, ADDRESS)
     yield km._openpgp.put_raw_key(DIFFERENT_PRIVATE_KEY, ADDRESS)
     # get the key
     inactive_keys = yield km._get_inactive_private_keys()
     active_key = yield km.get_key(ADDRESS,
                                   private=True,
                                   fetch_remote=False)
     self.assertEqual(1, len(inactive_keys))
     self.assertEqual(inactive_keys[0].fingerprint.lower(),
                      KEY_FINGERPRINT.lower())
     self.assertEqual(active_key.fingerprint.lower(),
                      DIFFERENT_KEY_FPR.lower())
     self.assertTrue(inactive_keys[0].private)
     self.assertTrue(active_key.private)
     self.assertFalse(inactive_keys[0].is_active())
     self.assertTrue(active_key.is_active())