Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pyjwt >= 2 in tests #461

Merged
merged 1 commit into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion oauthenticator/tests/test_azuread.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import pytest

from ..azuread import AzureAdOAuthenticator
from ..azuread import PYJWT_2
from .mocks import setup_oauth_mock


Expand Down Expand Up @@ -40,7 +41,9 @@ def user_model(tenant_id, client_id, name):
"aio": "Df2UVXL1ix!lMCWMSOJBcFatzcGfvFGhjKv8q5g0x732dR5MB5BisvGQO7YWByjd8iQDLq!eGbIDakyp5mnOrcdqHeYSnltepQmRp6AIZ8jY",
},
os.urandom(5),
).decode("ascii")
)
if not PYJWT_2:
id_token = id_token.decode("ascii")

return {
"access_token": "abc123",
Expand Down
7 changes: 6 additions & 1 deletion oauthenticator/tests/test_mediawiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pytest import fixture
from tornado import web

from ..azuread import PYJWT_2
from ..mediawiki import AUTH_REQUEST_COOKIE_NAME
from ..mediawiki import MWOAuthenticator
from .mocks import mock_handler
Expand All @@ -20,7 +21,7 @@ def mediawiki():
def post_token(request, context):
authorization_header = request.headers['Authorization'].decode('utf8')
request_nonce = re.search(r'oauth_nonce="(.*?)"', authorization_header).group(1)
return jwt.encode(
content = jwt.encode(
{
'username': 'wash',
'aud': 'client_id',
Expand All @@ -30,6 +31,10 @@ def post_token(request, context):
},
'client_secret',
)
if PYJWT_2:
content = content.encode()

return content

with requests_mock.Mocker() as mock:
mock.post(
Expand Down