mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-15 15:28:50 -04:00
stop putting invite user objects in the session
the invited_user objects can be arbitrarily large, and when we put them in the session we risk going over the session cookie's 4kb size limit. since https://github.com/alphagov/notifications-admin/pull/3827 was merged, we store the user id in the session. Now that's been live for a day or two we can safely stop putting the rich object in the session. Needed to change a bunch of tests for this to make sure appropriate mocks were set. Also some tests were accidentally re-using fake_uuid. Still pop the object when cleaning up sessions. We'll need to remove that in a future PR.
This commit is contained in:
@@ -137,13 +137,6 @@ def test_invited_user_from_session_uses_id_even_if_obj_in_session(
|
||||
mock_get_invited_user_by_id.assert_called_once_with(USER_ONE_ID)
|
||||
|
||||
|
||||
def test_invited_user_from_session_uses_obj_if_id_not_present(client, mocker, sample_invite):
|
||||
session_dict = {'invited_user': sample_invite}
|
||||
mocker.patch.dict('app.models.user.session', values=session_dict, clear=True)
|
||||
|
||||
assert InvitedUser.from_session().id == USER_ONE_ID
|
||||
|
||||
|
||||
def test_invited_user_from_session_returns_none_if_nothing_present(client, mocker):
|
||||
mocker.patch.dict('app.models.user.session', values={}, clear=True)
|
||||
assert InvitedUser.from_session() is None
|
||||
@@ -176,13 +169,6 @@ def test_invited_org_user_from_session_uses_id_even_if_obj_in_session(
|
||||
mock_get_invited_org_user_by_id.assert_called_once_with(fake_id)
|
||||
|
||||
|
||||
def test_invited_org_user_from_session_uses_obj_if_id_not_present(client, mocker, sample_org_invite):
|
||||
session_dict = {'invited_org_user': sample_org_invite}
|
||||
mocker.patch.dict('app.models.user.session', values=session_dict, clear=True)
|
||||
|
||||
assert InvitedOrgUser.from_session().id == sample_org_invite['id']
|
||||
|
||||
|
||||
def test_invited_org_user_from_session_returns_none_if_nothing_present(client, mocker):
|
||||
mocker.patch.dict('app.models.user.session', values={}, clear=True)
|
||||
assert InvitedOrgUser.from_session() is None
|
||||
|
||||
Reference in New Issue
Block a user