예제 #1
0
    def test_put_new_key_in_local_storage(self):
        pgp = openpgp.OpenPGPScheme(self._soledad,
                                    gpgbinary=self.gpg_binary_path)
        km = self._key_manager()

        rf = RandomRefreshPublicKey(pgp, km)
        rf._get_random_key = Mock(
            return_value=defer.succeed(OpenPGPKey(
                fingerprint=KEY_FINGERPRINT)))

        km._nicknym.fetch_key_with_fingerprint = Mock(
            return_value=defer.succeed(PUBLIC_KEY_2))

        yield rf.maybe_refresh_key()
예제 #2
0
    def test_log_error_if_fetch_by_fingerprint_returns_wrong_key(self):
        pgp = openpgp.OpenPGPScheme(self._soledad,
                                    gpgbinary=self.gpg_binary_path)
        km = self._key_manager()

        with patch.object(Logger, 'error') as mock_logger_error:
            rf = RandomRefreshPublicKey(pgp, km)
            rf._get_random_key = \
                Mock(return_value=defer.succeed(OpenPGPKey(
                    fingerprint=KEY_FINGERPRINT)))

            km._nicknym.fetch_key_with_fingerprint = \
                Mock(return_value=defer.succeed(PUBLIC_KEY_2))

            yield rf.maybe_refresh_key()

            mock_logger_error.assert_called_with(
                ERROR_UNEQUAL_FINGERPRINTS %
                (KEY_FINGERPRINT, KEY_FINGERPRINT_2))