Fix tests in CI

This commit is contained in:
Seamus Johnston 2022-09-30 08:08:19 -05:00
parent 8ea7b98a37
commit b5ea6c8e39
No known key found for this signature in database
GPG key ID: 2F21225985069105
4 changed files with 19 additions and 12 deletions

View file

@ -1,4 +1,4 @@
from unittest.mock import patch, Mock
from unittest.mock import patch
from django.http import HttpResponse
from django.test import Client, TestCase
@ -6,6 +6,7 @@ from django.urls import reverse
from .common import dont_print_garbage
@patch("djangooidc.views.CLIENT", autospec=True)
class ViewsTest(TestCase):
def setUp(self):
@ -16,11 +17,11 @@ class ViewsTest(TestCase):
def user_info(*args):
return {
"sub": "51234512345123",
"sub": "TEST",
"email": "test@example.com",
"first_name": "Testy",
"last_name": "Tester",
"phone": "814564000"
"phone": "814564000",
}
def test_error_page(self, mock_client):
@ -81,8 +82,8 @@ class ViewsTest(TestCase):
def test_logout_redirect_url(self, mock_client):
# setup
session = self.client.session
session["id_token_raw"] = "83450234852349"
session["state"] = "7534298229506"
session["id_token_raw"] = "TEST" # nosec B105
session["state"] = "TEST" # nosec B105
session.save()
# mock
mock_client.callback.side_effect = self.user_info
@ -95,8 +96,10 @@ class ViewsTest(TestCase):
# test
response = self.client.get(reverse("logout"))
# assert
expected = "http://example.com/log_me_out?id_token_hint=83450234852349&state" \
"=7534298229506&post_logout_redirect_uri=http%3A%2F%2Fexample.com%2Fback"
expected = (
"http://example.com/log_me_out?id_token_hint=TEST&state"
"=TEST&post_logout_redirect_uri=http%3A%2F%2Fexample.com%2Fback"
)
actual = response.url
self.assertEqual(response.status_code, 302)
self.assertEqual(actual, expected)
@ -118,4 +121,4 @@ class ViewsTest(TestCase):
response = self.client.get(reverse("openid_logout_callback"))
# assert
self.assertEqual(response.status_code, 302)
self.assertEqual(response.url, reverse("logout"))
self.assertEqual(response.url, reverse("logout"))