From 9c3a7133f11929c5f398d16f1b386504843141b4 Mon Sep 17 00:00:00 2001 From: Yuneng Jiang Date: Sat, 19 Sep 2026 14:25:52 -0700 Subject: [PATCH] test: cover the config-owned refusal on the email reset route --- .../send_emails/test_endpoints.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_litellm/enterprise/enterprise_callbacks/send_emails/test_endpoints.py b/tests/test_litellm/enterprise/enterprise_callbacks/send_emails/test_endpoints.py index c2ae153556d..7b32d9e8c44 100644 --- a/tests/test_litellm/enterprise/enterprise_callbacks/send_emails/test_endpoints.py +++ b/tests/test_litellm/enterprise/enterprise_callbacks/send_emails/test_endpoints.py @@ -331,3 +331,19 @@ async def test_save_email_settings_still_writes_when_the_config_file_is_silent() assert len(upserts) == 1 written = json.loads(upserts[0]["data"]["create"]["param_value"]) assert written["email_settings"] == {EmailEvent.new_user_invitation.value: False} + + +@pytest.mark.asyncio +async def test_reset_event_settings_surfaces_the_config_owned_refusal(mock_user_api_key_auth): + upserts = [] + client = _prisma_recording_upserts(upserts) + proxy_config = _proxy_config_owning({"email_settings": {EmailEvent.new_user_invitation.value: True}}) + + with mock.patch("litellm.proxy.proxy_server.prisma_client", client): # test-quality-ok: the endpoint reads these proxy_server module globals at call time; there is no injection seam + with mock.patch("litellm.proxy.proxy_server.proxy_config", proxy_config): # test-quality-ok: the endpoint reads these proxy_server module globals at call time; there is no injection seam + with pytest.raises(HTTPException) as refused: + await reset_event_settings(user_api_key_dict=mock_user_api_key_auth) + + assert refused.value.status_code == 400 + assert refused.value.detail["keys"] == ["email_settings"] + assert upserts == []