litellm/tests/test_litellm/proxy/management_endpoints
Yuneng Jiang 069469c7c0
chore(proxy): backport /key/regenerate ownership-rebind + premium-gate guards (#27793)
Backport of #27793 onto litellm_1.84.0rc2.

A non-admin caller could rebind their own key's user_id via /key/regenerate.
_execute_virtual_key_regeneration had org/team guards but no user_id guard,
and prepare_key_update_data did not strip the field — it survived
model_dump(exclude_unset=True) into the Prisma update. On the next request,
_return_user_api_key_auth_obj resolved the rebound user_id against
litellm_usertable and returned PROXY_ADMIN whenever the target row's
user_role was admin.

/key/update had the equivalent guard inline at _validate_update_key_data;
extract it to a shared helper _validate_caller_can_change_key_ownership and
call from both /key/update and _execute_virtual_key_regeneration.

Also tighten the premium gate that allowed the master-key rotation branch to
skip the enterprise check. The previous predicate was a field-presence test,
not an identity check. Verify the caller actually holds the master key via
_is_master_key before allowing the non-premium path.

Block explicit-null user_id and empty-string user_id as removal attempts;
both 403-reject for non-admin callers.
2026-05-12 23:18:36 -07:00
..
policy_endpoints style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
scim [Infra] Promote internal staging to main (#27245) 2026-05-05 16:15:03 -07:00
search_endpoints style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
usage_endpoints [Infra] Promote internal staging to main (#27245) 2026-05-05 16:15:03 -07:00
test_access_group_endpoints.py [Infra] Promote internal staging to main (#27245) 2026-05-05 16:15:03 -07:00
test_access_group_management.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_activity_tenant_scoping.py [Infra] Promote internal staging to main (#27245) 2026-05-05 16:15:03 -07:00
test_budget_endpoints.py [Release - 02/10/2026] v1.81.10-nightly 2026-02-10 16:26:30 -08:00
test_cache_settings_endpoints.py [Infra] Promote internal staging to main (#27245) 2026-05-05 16:15:03 -07:00
test_callback_management_endpoints.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_common_daily_activity.py Revert "fix(proxy): restore per-entity breakdown in aggregated daily activity endpoint" 2026-03-21 21:37:29 -07:00
test_common_utils.py [Infra] Promote internal staging to main (#27245) 2026-05-05 16:15:03 -07:00
test_compliance_endpoints.py Add compliance checker endpoints + UI panel (#21432) 2026-02-17 18:22:26 -08:00
test_config_override_endpoints.py [Infra] Promote internal staging to main (#27245) 2026-05-05 16:15:03 -07:00
test_cost_tracking_settings.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_customer_budget.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_customer_endpoints.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_delete_callbacks_endpoint.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_delete_verification_tokens_failed.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_entraid_app_roles.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_internal_user_endpoints.py [Infra] Promote internal staging to main (#27245) 2026-05-05 16:15:03 -07:00
test_key_management_endpoints.py chore(proxy): backport /key/regenerate ownership-rebind + premium-gate guards (#27793) 2026-05-12 23:18:36 -07:00
test_mcp_management_endpoints.py [Infra] Promote internal staging to main (#27245) 2026-05-05 16:15:03 -07:00
test_model_management_endpoints.py fix(model_management): refresh in-memory router after POST /model/update (#26427) 2026-04-25 14:10:23 -07:00
test_org_admin_team_access.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_organization_endpoints.py [Infra] Promote internal staging to main (#27245) 2026-05-05 16:15:03 -07:00
test_policy_endpoints.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_project_org_authz.py [Infra] Promote internal staging to main (#27245) 2026-05-05 16:15:03 -07:00
test_router_settings_endpoints.py [Infra] Promote internal staging to main (#27245) 2026-05-05 16:15:03 -07:00
test_tag_management_endpoints.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_team_callback_endpoints.py [Infra] Promote internal staging to main (#27245) 2026-05-05 16:15:03 -07:00
test_team_default_params.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_team_endpoints.py [Infra] Promote internal staging to main (#27245) 2026-05-05 16:15:03 -07:00
test_tool_management_endpoints.py Fix tool management tests using wrong field name call_policy 2026-03-04 11:20:17 -03:00
test_ui_sso.py [Infra] Promote internal staging to main (#27245) 2026-05-05 16:15:03 -07:00
test_workflow_management_endpoints.py feat(proxy): durable agent workflow run tracking via /v1/workflows/runs (#26793) 2026-04-29 17:12:18 -07:00