mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-26 04:28:39 +02:00
Implement VIP table and fix 401 login bug
This commit is contained in:
parent
7077519837
commit
510da21934
11 changed files with 175 additions and 1 deletions
|
@ -3,6 +3,8 @@ from unittest.mock import MagicMock, patch
|
|||
from django.http import HttpResponse
|
||||
from django.test import Client, TestCase, RequestFactory
|
||||
from django.urls import reverse
|
||||
|
||||
from djangooidc.exceptions import NoStateDefined
|
||||
from ..views import login_callback
|
||||
|
||||
from .common import less_console_noise
|
||||
|
@ -17,6 +19,9 @@ class ViewsTest(TestCase):
|
|||
def say_hi(*args):
|
||||
return HttpResponse("Hi")
|
||||
|
||||
def create_acr(*args):
|
||||
return "any string"
|
||||
|
||||
def user_info(*args):
|
||||
return {
|
||||
"sub": "TEST",
|
||||
|
@ -34,6 +39,7 @@ class ViewsTest(TestCase):
|
|||
callback_url = reverse("openid_login_callback")
|
||||
# mock
|
||||
mock_client.create_authn_request.side_effect = self.say_hi
|
||||
mock_client.get_default_acr_value.side_effect = self.create_acr
|
||||
# test
|
||||
response = self.client.get(reverse("login"), {"next": callback_url})
|
||||
# assert
|
||||
|
@ -53,6 +59,19 @@ class ViewsTest(TestCase):
|
|||
self.assertTemplateUsed(response, "500.html")
|
||||
self.assertIn("Server error", response.content.decode("utf-8"))
|
||||
|
||||
def test_callback_with_no_session_state(self, mock_client):
|
||||
"""If the local session is None (ie the server restarted while user was logged out),
|
||||
we do not throw an exception. Rather, we attempt to login again."""
|
||||
# mock
|
||||
mock_client.get_default_acr_value.side_effect = self.create_acr
|
||||
mock_client.callback.side_effect = NoStateDefined()
|
||||
# test
|
||||
with less_console_noise():
|
||||
response = self.client.get(reverse("openid_login_callback"))
|
||||
# assert
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(response.url, "/")
|
||||
|
||||
def test_login_callback_reads_next(self, mock_client):
|
||||
# setup
|
||||
session = self.client.session
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue