diff --git a/benefits/core/migrations/0030_enrollmentevent_extra_claims.py b/benefits/core/migrations/0030_enrollmentevent_extra_claims.py new file mode 100644 index 000000000..4f3a54308 --- /dev/null +++ b/benefits/core/migrations/0030_enrollmentevent_extra_claims.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.2 on 2024-10-29 22:11 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("core", "0029_add_extra_claims"), + ] + + operations = [ + migrations.AddField( + model_name="enrollmentevent", + name="extra_claims", + field=models.TextField(blank=True, null=True), + ), + ] diff --git a/benefits/core/models.py b/benefits/core/models.py index f6e5678e9..3b8b93079 100644 --- a/benefits/core/models.py +++ b/benefits/core/models.py @@ -483,6 +483,7 @@ class EnrollmentEvent(models.Model): verified_by = models.TextField() enrollment_datetime = models.DateTimeField(default=timezone.now) expiration_datetime = models.DateTimeField(blank=True, null=True) + extra_claims = models.TextField(blank=True, null=True) def __str__(self): dt = timezone.localtime(self.enrollment_datetime) diff --git a/benefits/enrollment/views.py b/benefits/enrollment/views.py index 580ea9845..b847aa2bc 100644 --- a/benefits/enrollment/views.py +++ b/benefits/enrollment/views.py @@ -83,6 +83,7 @@ def index(request): enrollment_method=models.EnrollmentMethods.DIGITAL, verified_by=flow.eligibility_verifier, expiration_datetime=expiry, + extra_claims=extra_claims, ) event.save() extra_claims = session.oauth_extra_claims( diff --git a/tests/pytest/conftest.py b/tests/pytest/conftest.py index a1ac35ab7..fbee1add6 100644 --- a/tests/pytest/conftest.py +++ b/tests/pytest/conftest.py @@ -274,3 +274,8 @@ def mocked_session_reset(mocker): @pytest.fixture def mocked_session_update(mocker): return mocker.patch("benefits.core.session.update") + + +@pytest.fixture +def mocked_session_oauth_extra_claims(mocker): + return mocker.patch("benefits.core.session.oauth_extra_claims") diff --git a/tests/pytest/enrollment/test_views.py b/tests/pytest/enrollment/test_views.py index 81b027aa0..bc620f12b 100644 --- a/tests/pytest/enrollment/test_views.py +++ b/tests/pytest/enrollment/test_views.py @@ -305,7 +305,9 @@ def test_index_eligible_post_valid_form_success_claims( mocked_analytics_module, model_TransitAgency, model_EnrollmentFlow_with_scope_and_claim, + mocked_session_oauth_extra_claims, ): + mocked_session_oauth_extra_claims.return_value = ["claim_1", "claim_2"] mocker.patch("benefits.enrollment.views.enroll", return_value=(Status.SUCCESS, None)) spy = mocker.spy(benefits.enrollment.views.models.EnrollmentEvent.objects, "create") @@ -318,6 +320,7 @@ def test_index_eligible_post_valid_form_success_claims( enrollment_method=models.EnrollmentMethods.DIGITAL, verified_by=model_EnrollmentFlow_with_scope_and_claim.claims_provider.client_name, expiration_datetime=None, + extra_claims="claim_1, claim_2", ) assert response.status_code == 200 @@ -335,7 +338,9 @@ def test_index_eligible_post_valid_form_success_eligibility_api( mocked_analytics_module, model_TransitAgency, model_EnrollmentFlow_with_eligibility_api, + mocked_session_oauth_extra_claims, ): + mocked_session_oauth_extra_claims.return_value = ["claim_1", "claim_2"] mocker.patch("benefits.enrollment.views.enroll", return_value=(Status.SUCCESS, None)) spy = mocker.spy(benefits.enrollment.views.models.EnrollmentEvent.objects, "create") @@ -348,6 +353,7 @@ def test_index_eligible_post_valid_form_success_eligibility_api( enrollment_method=models.EnrollmentMethods.DIGITAL, verified_by=model_EnrollmentFlow_with_eligibility_api.eligibility_api_url, expiration_datetime=None, + extra_claims="claim_1, claim_2", ) assert response.status_code == 200