Skip to content

Commit

Permalink
Update failing test.
Browse files Browse the repository at this point in the history
  • Loading branch information
akatsoulas committed Jan 27, 2023
1 parent f3cc760 commit 4073814
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 deletions.
12 changes: 0 additions & 12 deletions mozilla_django_oidc/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,7 @@
from django.shortcuts import resolve_url
from django.urls import reverse
from django.utils.crypto import get_random_string
<<<<<<< HEAD
from django.utils.http import url_has_allowed_host_and_scheme
=======

try:
from django.utils.http import url_has_allowed_host_and_scheme
except ImportError:
# Django <= 2.2
from django.utils.http import is_safe_url as url_has_allowed_host_and_scheme

from urllib.parse import urlencode

>>>>>>> 4254763 (Support for PKCE)
from django.utils.module_loading import import_string
from django.views.generic import View

Expand Down
10 changes: 1 addition & 9 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,7 @@ def test_generate_code_challenge_invalid_method(self):
Tests that an exception is raised when an invalid code challenge method is provided.
"""
code_verifier = "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"

try:
generate_code_challenge(code_verifier, "INVALID")
self.fail(
"generate_code_challenge() should raise an exception when an invalid"
" code challenge method is provided."
)
except ValueError:
pass
self.assertRaises(ValueError, generate_code_challenge, code_verifier, "INVALID")


class SessionStateTestCase(TestCase):
Expand Down
8 changes: 6 additions & 2 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,9 @@ def make_request():
with patch("mozilla_django_oidc.views.auth.login") as mock_login:
mock_auth.return_value = user
response = callback_view(request)
mock_auth.assert_called_once_with(nonce=None, request=request)
mock_auth.assert_called_once_with(
code_verifier=None, nonce=None, request=request
)
mock_login.assert_called_once_with(request, user)
self.assertEqual(response.status_code, 302)
self.assertEqual(response.url, "/success")
Expand All @@ -353,7 +355,9 @@ def make_request():
with patch("mozilla_django_oidc.views.auth.login") as mock_login:
mock_auth.return_value = user
response = callback_view(request)
mock_auth.assert_called_once_with(nonce=None, request=request)
mock_auth.assert_called_once_with(
code_verifier=None, nonce=None, request=request
)
mock_login.assert_not_called()
self.assertEqual(response.status_code, 302)
self.assertEqual(response.url, "/success")
Expand Down

0 comments on commit 4073814

Please sign in to comment.