litellm/tests/unit/proxy/management_helpers
jesus-berri c76a95fc7e
feat(proxy): let a key's logging entry reference a proxy credential (#50572)
* feat(proxy): let a key's logging entry reference a proxy credential

A virtual key's metadata.logging entry can name a proxy credential with
litellm_credential_name. At request time the credential's values, which config
credential_list resolves through the secret manager at boot, are merged under the
entry's callback_vars, with the entry's own values winning. An entry whose
credential is not defined is dropped, so it never falls back to the proxy's own
callback environment.

Only proxy admins may change the logging entries of a key when the stored or
requested list holds a reference (403), and a reference to an undefined
credential is a 400. The check runs on key generate, update, team bulk update,
regenerate and /user/new, and compares decrypted entries so re-saving metadata
read back from /key/info is not a change.

Resolves LIT-10061

* fix(proxy): drop a key logging entry whose referenced credential holds no logging values

* fix(proxy): only require newly added credential references to exist on key writes

* fix(proxy): log a dropped credential reference as an error so /key/health reports it

* fix(proxy): gate credential references on bulk-created user keys

* fix(proxy): keep failing requests on keys with non-object logging metadata

A key whose stored metadata.logging is not a list of objects failed every
request with a 500 before this branch. The credential reference rewrite
turned those values into no entries, so the request quietly succeeded
without the key's logging. Raise a TypeError for those shapes again so the
request path behaves as it did on main, while empty values and objects with
unknown fields still go through the existing skip.

* test(proxy): audit cells for credential references across surfaces, v1, dropped entries and malformed logging

The malformed logging cell expects the base behavior that 7ac4ab1356
restored, a 500 for a key whose stored metadata.logging is not a list of
objects and a 200 for an empty list

* fix(proxy): keep a 500 for teams with non-object logging metadata

On main, a team whose stored metadata.logging held non-object items failed
chat requests with a 500, because AddTeamCallback(**item) raised a TypeError.
This branch switched to AddTeamCallback.model_validate, whose before-validator
raises AttributeError on those items, and the proxy maps AttributeError to a
400 invalid_request_error. Raise a TypeError for non-mapping items before
validation so the status matches main again, as the key path already does.
2026-11-09 16:02:46 -08:00
..
__init__.py ci: move tests/proxy_unit_tests to tests/unit/proxy and run the proxy-db shards from litellm-tests (#42903) 2026-09-24 22:59:11 +00:00
team_metadata_validator_impls.py test(proxy): move management_endpoints, management_helpers and guardrails tests into tests/unit/proxy (#44003) 2026-10-01 10:52:03 -07:00
test_access_group_key_sync.py test(proxy): move management_endpoints, management_helpers and guardrails tests into tests/unit/proxy (#44003) 2026-10-01 10:52:03 -07:00
test_access_group_model_sync.py refactor(router): move router callers onto the entry points and invert the proxy imports (#48847) 2026-10-29 17:26:33 +00:00
test_access_group_team_sync.py test(proxy): move management_endpoints, management_helpers and guardrails tests into tests/unit/proxy (#44003) 2026-10-01 10:52:03 -07:00
test_audit_log_callbacks.py test(proxy): move management_endpoints, management_helpers and guardrails tests into tests/unit/proxy (#44003) 2026-10-01 10:52:03 -07:00
test_audit_logs_proxy.py fix(proxy): track and drain management audit log writes on shutdown (#43594) 2026-10-16 08:41:34 +00:00
test_auto_router_availability.py refactor(router): fence the router surface and document the router-core boundary (#48839) 2026-10-29 00:01:52 +00:00
test_auto_router_permissions.py fix(databricks): call the ai_decide AI Function route for decisions and the auto-router (#45722) 2026-10-10 23:58:16 -07:00
test_bulk_user_creation.py feat(proxy): let a key's logging entry reference a proxy credential (#50572) 2026-11-09 16:02:46 -08:00
test_bulk_user_deletion.py fix(proxy): show committed spend in the remaining budget gauges (#49199) 2026-11-09 20:05:37 +00:00
test_management_helpers_utils.py fix(proxy): stop /tag/update 500 when the body carries the tag's budget_id (#50324) 2026-11-06 08:55:44 -08:00
test_object_permission_utils.py refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986) 2026-11-06 13:31:15 -08:00
test_resource_display_names.py test(proxy): move management_endpoints, management_helpers and guardrails tests into tests/unit/proxy (#44003) 2026-10-01 10:52:03 -07:00
test_team_list_sorting.py feat(ui): sort every teams table data column (#48109) 2026-10-23 16:21:36 -07:00
test_team_member_permission_checks.py fix(proxy): align ownership and scope handling (#50600) 2026-11-08 07:03:36 +00:00
test_team_metadata_validation.py refactor(proxy): expose public names for private proxy helpers (#45170) 2026-10-07 18:59:27 -07:00
test_team_roster_sync.py feat(redis): serve the proxy's common Redis call with Rust stores (#50170) 2026-11-06 06:01:11 +00:00
test_user_list_sorting.py feat(ui): sort every users table data column (#48105) 2026-10-23 16:12:51 -07:00