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:
Leo Hemsted
2021-03-16 17:58:27 +00:00
parent 1a63c2c8be
commit 8a2fec6f18
8 changed files with 68 additions and 167 deletions

View File

@@ -176,6 +176,7 @@ def test_activate_user_redirects_to_service_dashboard_if_user_already_belongs_to
api_user_active,
mock_login,
mock_get_service,
mock_get_invited_user_by_id,
):
mocker.patch('app.user_api_client.add_user_to_service', side_effect=HTTPError(
response=Mock(
@@ -189,10 +190,10 @@ def test_activate_user_redirects_to_service_dashboard_if_user_already_belongs_to
))
# Can't use `with client.session_transaction()...` here since activate_session is not a view function
flask_session['invited_user'] = sample_invite
flask_session['invited_user_id'] = sample_invite['id']
response = activate_user(api_user_active['id'])
assert response.location == url_for('main.service_dashboard', service_id=service_one['id'])
flask_session.pop('invited_user')
flask_session.pop('invited_user_id')