Skip to content

Commit

Permalink
test: update to allow jwk decoding
Browse files Browse the repository at this point in the history
As updated in jpadilla/pyjwt#886

Signed-off-by: Mike Fiedler <[email protected]>
  • Loading branch information
miketheman committed Aug 7, 2024
1 parent ac97960 commit 1bff60a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tests/unit/oidc/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,15 +972,14 @@ def test_decodes_token_jwk_roundtrip(self):

assert decoded == {"foo": "bar"}

def test_decodes_token_typeerror_on_pyjwk(self):
def test_decodes_token_pyjwk(self):
privkey_jwk = PyJWK.from_json(algorithms.RSAAlgorithm.to_jwk(self._privkey))
pubkey_jwk = PyJWK.from_json(algorithms.RSAAlgorithm.to_jwk(self._pubkey))

token = jwt.encode({"foo": "bar"}, privkey_jwk.key, algorithm="RS256")
decoded = jwt.decode(token, pubkey_jwk, algorithms=["RS256"])

# Passing a `PyJWK` directly into `jwt.decode` does not work.
with pytest.raises(TypeError, match=r"Expecting a PEM-formatted key\."):
jwt.decode(token, pubkey_jwk, algorithms=["RS256"])
assert decoded == {"foo": "bar"}

def test_decode_strict_aud(self):
token = jwt.encode(
Expand Down

0 comments on commit 1bff60a

Please sign in to comment.