From 271efc06be4ae3887e668fcc65ce1406402c965f Mon Sep 17 00:00:00 2001 From: Kegan Maher Date: Tue, 26 Mar 2024 21:52:20 +0000 Subject: [PATCH 1/2] fix(settings): add enrollment context processor --- benefits/settings.py | 1 + 1 file changed, 1 insertion(+) diff --git a/benefits/settings.py b/benefits/settings.py index 7e19d3e74..c1ad706c0 100644 --- a/benefits/settings.py +++ b/benefits/settings.py @@ -139,6 +139,7 @@ def RUNTIME_ENVIRONMENT(): "benefits.core.context_processors.active_agencies", "benefits.core.context_processors.analytics", "benefits.core.context_processors.authentication", + "benefits.core.context_processors.enrollment", "benefits.core.context_processors.origin", ] From 73957a4fb8d84d31d05fdbea5fb958c34761ec38 Mon Sep 17 00:00:00 2001 From: Kegan Maher Date: Tue, 26 Mar 2024 21:54:17 +0000 Subject: [PATCH 2/2] fix(session): reset also clears enrollment expiry --- benefits/core/session.py | 1 + tests/pytest/core/test_session.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/benefits/core/session.py b/benefits/core/session.py index 93d8d3311..6d791bfb0 100644 --- a/benefits/core/session.py +++ b/benefits/core/session.py @@ -180,6 +180,7 @@ def reset(request): request.session[_AGENCY] = None request.session[_ELIGIBILITY] = None request.session[_ORIGIN] = reverse("core:index") + request.session[_ENROLLMENT_EXP] = None request.session[_ENROLLMENT_TOKEN] = None request.session[_ENROLLMENT_TOKEN_EXP] = None request.session[_OAUTH_TOKEN] = None diff --git a/tests/pytest/core/test_session.py b/tests/pytest/core/test_session.py index 68e99554b..17384ea3d 100644 --- a/tests/pytest/core/test_session.py +++ b/tests/pytest/core/test_session.py @@ -260,11 +260,14 @@ def test_reset_eligibility(app_request): @pytest.mark.django_db def test_reset_enrollment(app_request): + app_request.session[session._ENROLLMENT_EXP] = "1234567890" app_request.session[session._ENROLLMENT_TOKEN] = "enrollmenttoken123" app_request.session[session._ENROLLMENT_TOKEN_EXP] = "1234567890" session.reset(app_request) + assert session.enrollment_expiry(app_request) is None + assert session.enrollment_reenrollment(app_request) is None assert session.enrollment_token(app_request) is None assert session.enrollment_token_expiry(app_request) is None assert not session.enrollment_token_valid(app_request)