Exemple #1
0
    def setUp(self):
        super(ValidSubKeyButRevokedSuperKeyTest, self).setUp()

        self.key_id = utilities.safe_load(self.config, "pgpprocessor",
                                          "sub_keyid", 0)
        self.messages = utilities.multi_sign(message="hi",
                                             gpg=self.gpg_expired_then_valid,
                                             iterations=self.iterations,
                                             keyid=self.key_id)

        self.unwrapper = pgpprocessor.Unwrapper(self.messages[-1],
                                                self.gpg_expired)
    def load_data(self, key):
        """Load hosting or consuming data from the shelf.

        To do this correctly, we need to convert the list values to sets.
        However, that can be done only after unwrapping the signed data.

        pre::

            key in ("hosting", "consuming")

        post::

            getattr(self, key) # exists

        """
        debug_log("loading data.")

        if not key in ("hosting", "consuming"):
            debug_log("bad key {0}".format(key))
            return

        message = ""

        try:
            data = self.shelf[key]
        except KeyError as error:
            logging.exception(error)
            data = dict()
        else:
            for message in pgpprocessor.Unwrapper(data, gpg=self.gpg):
                # iterations end when unwrapping complete.
                pass

            try:
                # Per Python's documentation, this is safe enough:
                # http://docs.python.org/2/library/ast.html#ast.literal_eval
                data = ast.literal_eval(str(message))
            except (ValueError, SyntaxError) as error:
                logging.exception(error)
                data = dict()

        debug_log("found {0}: {1}".format(key, data))

        return data
Exemple #3
0
    def setUp(self):
        super(UnwrapperTest, self).setUp()

        self.unwrapper = pgpprocessor.Unwrapper(self.messages[-1], self.gpg)
Exemple #4
0
 def test_create_with_gpg_as_None(self):
     """Ensure gpg is created when passed as None"""
     test_processor = pgpprocessor.Unwrapper("hi", gpg=None)
     self.assertIsInstance(test_processor.gpg, gnupg.GPG)