providers/oauth2: fix tests validating JWT incorrectly

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-12-22 23:00:57 +01:00
parent 0149c89003
commit 6dc2003e34
1 changed files with 3 additions and 1 deletions

View File

@ -2,7 +2,7 @@
from django.test import TestCase
from jwt import decode
from authentik.providers.oauth2.models import OAuth2Provider, RefreshToken
from authentik.providers.oauth2.models import JWTAlgorithms, OAuth2Provider, RefreshToken
class OAuthTestCase(TestCase):
@ -20,6 +20,8 @@ class OAuthTestCase(TestCase):
def validate_jwt(self, token: RefreshToken, provider: OAuth2Provider):
"""Validate that all required fields are set"""
key, alg = provider.get_jwt_key()
if alg != JWTAlgorithms.HS256:
key = provider.signing_key.public_key
jwt = decode(
token.access_token,
key,