def test_invalid():
    encryption_key = SYMKey(use="enc",
                            key='DukeofHazardpass',
                            kid="some-key-id")

    decrypter = JWE(plain, alg="A128KW", enc="A128CBC-HS256")
    with pytest.raises(BadSyntax):
        decrypter.decrypt('a.b.c.d.e', keys=[encryption_key])
def test_nothing():
    encryption_key = SYMKey(use="enc",
                            key='DukeofHazardpass',
                            kid="some-key-id")

    decrypter = JWE(plain, alg="A128KW", enc="A128CBC-HS256")
    with pytest.raises(ValueError):
        decrypter.decrypt(keys=[encryption_key])
    def from_jwe(self, msg, keys):
        """
        Decrypt an encrypted JWT and load the JSON object that was the body
        of the JWT into this object.

        :param msg: An encrypted JWT
        :param keys: Possibly usable keys.
        :type keys: list or KeyJar instance
        :return: The decrypted message. If decryption failed an exception
            will be raised.
        """

        jwe = JWE()
        _res = jwe.decrypt(msg, keys)
        return self.from_json(_res.decode())