mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-21 00:21:49 +00:00
test(mcp): give the new cache and tombstone patches TQ008 reasons and match the keyword eviction call
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
e6349d00f3
commit
ce48a3fbcc
4 changed files with 20 additions and 10 deletions
|
|
@ -331,9 +331,7 @@ class TestMCPPerUserTokenCache:
|
|||
with patch("litellm.proxy.proxy_server.user_api_key_cache", mock_dual_cache):
|
||||
await cache.delete("alice", "slack-test")
|
||||
|
||||
mock_dual_cache.async_delete_cache.assert_called_once_with(
|
||||
"mcp:per_user_token:alice:slack-test"
|
||||
)
|
||||
mock_dual_cache.async_delete_cache.assert_called_once_with(key="mcp:per_user_token:alice:slack-test")
|
||||
mock_dual_cache.async_set_cache.assert_not_called()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
|
|
@ -692,9 +692,15 @@ async def test_invalidate_byok_cred_cache_evicts_locally_and_broadcasts_the_same
|
|||
publish = AsyncMock()
|
||||
|
||||
with (
|
||||
patch("litellm.proxy._experimental.mcp_server.db.get_user_credential", new=db_lookup),
|
||||
patch("litellm.proxy.proxy_server.prisma_client", MagicMock()),
|
||||
patch.object(server_module, "publish_auth_cache_invalidation", new=publish),
|
||||
patch( # test-quality-ok: the DB row lookup is the only seam below the credential resolver; no Prisma fake exists
|
||||
"litellm.proxy._experimental.mcp_server.db.get_user_credential", new=db_lookup
|
||||
),
|
||||
patch( # test-quality-ok: the resolver reads the module-level prisma_client singleton; the suite's only seam
|
||||
"litellm.proxy.proxy_server.prisma_client", MagicMock()
|
||||
),
|
||||
patch.object( # test-quality-ok: the redis publisher is module-level; asserting the broadcast without a redis
|
||||
server_module, "publish_auth_cache_invalidation", new=publish
|
||||
),
|
||||
):
|
||||
assert await server_module._get_byok_credential(server, user_auth) == "sk-before-revoke"
|
||||
assert await server_module._get_byok_credential(server, user_auth) == "sk-before-revoke"
|
||||
|
|
|
|||
|
|
@ -3078,7 +3078,9 @@ async def test_admin_terminated_session_id_stays_refused_while_replayed_and_is_f
|
|||
"method": "POST",
|
||||
"headers": [(b"content-type", b"application/json"), (b"mcp-session-id", session_id.encode())],
|
||||
}
|
||||
with patch.object(mcp_server.time, "monotonic", return_value=now):
|
||||
with patch.object( # test-quality-ok: the stale-session handler reads the clock directly; no injectable now
|
||||
mcp_server.time, "monotonic", return_value=now
|
||||
):
|
||||
handled = await mcp_server._handle_stale_mcp_session(
|
||||
scope, AsyncMock(), AsyncMock(), session_manager_stateful
|
||||
)
|
||||
|
|
@ -3099,7 +3101,9 @@ async def test_admin_terminated_session_id_stays_refused_while_replayed_and_is_f
|
|||
mcp_server._stateful_session_auth_context_last_seen, {}, clear=True
|
||||
),
|
||||
):
|
||||
with patch.object(mcp_server.time, "monotonic", return_value=1000.0):
|
||||
with patch.object( # test-quality-ok: termination stamps the tombstone from the clock directly; no injectable now
|
||||
mcp_server.time, "monotonic", return_value=1000.0
|
||||
):
|
||||
closed = await mcp_server.terminate_mcp_gateway_sessions(user_id="alice")
|
||||
assert closed.terminated_sessions == 2
|
||||
|
||||
|
|
|
|||
|
|
@ -409,8 +409,10 @@ async def test_per_user_token_delete_evicts_locally_and_broadcasts_to_peer_worke
|
|||
local_cache.in_memory_cache.set_cache(key, "encrypted-token")
|
||||
|
||||
with (
|
||||
patch.object(proxy_server, "user_api_key_cache", local_cache),
|
||||
patch(
|
||||
patch.object( # test-quality-ok: the token cache reads the module-level user_api_key_cache singleton; the suite's only seam
|
||||
proxy_server, "user_api_key_cache", local_cache
|
||||
),
|
||||
patch( # test-quality-ok: the redis publisher is module-level; asserting the broadcast without a redis
|
||||
"litellm.proxy.common_utils.auth_cache_invalidation_pubsub.publish_auth_cache_invalidation",
|
||||
new=publish,
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue