From f4d6091b6c49d2081ed56b1f44457d2a9be42879 Mon Sep 17 00:00:00 2001 From: Joshua Valluru <326636767+joshua-berri@users.noreply.github.com> Date: Mon, 28 Sep 2026 21:56:46 -0700 Subject: [PATCH] test(scim): preserve rotation grace period transaction writes --- .../test_key_management_endpoints.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py b/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py index fad0f290462..d011cd8cbee 100644 --- a/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py +++ b/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py @@ -21239,3 +21239,22 @@ async def test_route_write_rechecks_binding_and_preserves_supported_updates(boun response = await write assert response["data"]["allowed_routes"] == routes tx.litellm_budgettable.update.assert_not_awaited() + + +@pytest.mark.asyncio +@pytest.mark.parametrize("transactional", [False, True]) +async def test_rotation_grace_period_is_written_to_the_selected_database(transactional): + from litellm.proxy.management_endpoints.key_management_endpoints import _insert_deprecated_key + + client = _make_regenerate_mock_prisma() + transaction = AsyncMock() + before = datetime.now(timezone.utc) + await _insert_deprecated_key(client, "old-token", "new-token", "1h", tx=transaction if transactional else None) + selected = transaction if transactional else client.db + unused = client.db if transactional else transaction + saved = selected.litellm_deprecatedverificationtoken.upsert.call_args.kwargs + assert saved["where"] == {"token": "old-token"} + assert saved["data"]["create"]["active_token_id"] == "new-token" + assert saved["data"]["update"]["active_token_id"] == "new-token" + assert before + timedelta(hours=1) <= saved["data"]["create"]["revoke_at"] <= datetime.now(timezone.utc) + timedelta(hours=1) + unused.litellm_deprecatedverificationtoken.upsert.assert_not_awaited()