litellm/tests/test_litellm/proxy/common_utils
harish-berri 8f25942ecf
Litellm key rotation bug (#27756)
* fix(proxy): resolve cache handling issues in _lookup_deprecated_key

- Updated the in-memory cache for deprecated key lookups to store a 3-tuple (active_token_id, cache_expires_at_ts, revoke_at_ts) instead of a 2-tuple, ensuring proper unpacking and backward compatibility.
- Removed duplicate cache reads and added logic to handle legacy cache entries gracefully.
- Enhanced unit tests to cover scenarios for cache hits, DB misses, and respect for revoke_at timestamps, ensuring robust handling of the grace-period key-rotation feature.

* refactor(proxy): streamline cache handling in _lookup_deprecated_key

- Simplified the cache retrieval logic by directly unpacking the 3-tuple cache entries, removing the need for backward compatibility checks for 2-tuple entries.
- Updated unit tests to ensure that pre-warmed 3-tuple cache entries are served correctly without unnecessary database lookups.

* chore(ci): add new unit test for deprecated key grace period

- Included `test_deprecated_key_grace_period.py` in the CI workflow to enhance coverage for deprecated key handling scenarios.

* fix(proxy): remove unnecessary check for revoke_at in _lookup_deprecated_key

- Eliminated the redundant check for None on revoke_at, streamlining the logic for handling deprecated keys in the cache. This change enhances the efficiency of the key lookup process.

* test(proxy): add end-to-end tests for deprecated key lookup behavior

- Introduced a new test class `TestDeprecatedKeyLookupDbE2E` to validate the behavior of deprecated key lookups against a real Prisma-backed database.
- The test ensures that old key hashes resolve correctly and that repeated lookups utilize the in-memory cache without errors.
- Cleaned up the `_lookup_deprecated_key` function by removing an unnecessary check for `revoke_at`, enhancing the efficiency of the key lookup process.
2026-05-12 17:16:37 -07:00
..
test_cache_codec.py Update test for CacheCodec serialization to clarify validation error handling. 2026-04-24 16:13:42 +00:00
test_callback_utils.py Prompt Compression - add it to the proxy (#25729) 2026-04-20 15:08:00 -07:00
test_custom_openapi_spec.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_expired_ui_session_key_cleanup_manager.py Handle cleanup delete races and accurate counts 2026-04-25 03:01:34 +03:00
test_get_routes.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_http_parsing_utils.py Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_yj_apr17 2026-04-17 17:36:40 -07:00
test_key_rotation_e2e.py Litellm key rotation bug (#27756) 2026-05-12 17:16:37 -07:00
test_key_rotation_integration.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_key_rotation_lock.py Litellm ishaan april4 2 (#25150) 2026-04-04 23:09:42 +00:00
test_key_rotation_manager.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_load_config_utils.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_openai_endpoint_utils.py fix(vector-stores): recurse into nested litellm_params; handle JSON-string shape 2026-04-29 18:56:40 +00:00
test_path_utils.py test: add unit tests for path_utils safe_join and safe_filename 2026-04-16 03:25:42 +00:00
test_reset_budget_job.py feat: litellm shin agent oss staging 05 10 2026 (#27631) 2026-05-11 20:31:43 -07:00
test_static_asset_utils.py fix(static-assets): browser-load remote branding assets 2026-04-30 11:30:57 -07:00
test_timezone_utils.py fix(budget): fix timezone config lookup and replace hardcoded timezone map with ZoneInfo (#21754) 2026-02-21 19:35:06 -08:00
test_upsert_budget_membership.py fix: give each team member an independent budget instead of sharing the team default 2026-04-21 17:58:50 -07:00
test_user_api_key_cache.py fix import error 2026-05-01 00:29:13 +00:00