litellm/tests/proxy_behavior/management
Yuneng Jiang 30bcdb4ef8
test(proxy_behavior): pin /key/update authz matrix + mutation re-read (21 scenarios)
Slice 10 of the management-endpoints behavior-pinning effort. 8 actors ×
3 target shapes (self-owned, OWNER-scoped in org_a/team_alpha,
CROSS_ORG_USER-scoped in org_b/team_beta) = 21 applicable scenarios.

Each test:
  1. Master-key-seeds a fresh scratch key with the target's (user_id,
     team_id) scope (so the read-world stays untouched).
  2. Has the actor under test POST /key/update flipping ``models`` to
     a known marker list.
  3. Asserts the status code AND the DB row's ``models`` field — present
     when 200, unchanged otherwise — so a handler that silently mutates
     on a denied response surfaces red.

Observed gating (pinned, not endorsed):

  * PROXY_ADMIN bypasses every check.
  * ORG_ADMIN is blocked by an early role gate, always 401.
  * Every other (INTERNAL_USER-rolesed) actor hits one of three failure
    modes — 403 "user can only create keys for themselves", 403
    "only proxy admins, team admins, or org admins", or 401
    "team_member_permission_error" — depending on whether they own the
    target and whether they're a team admin / member of its team.

Plan: https://www.notion.so/36643b8acdab8128a581ced0f6a4744d
2026-05-19 21:48:47 -07:00
..
__init__.py test(proxy_behavior): scaffold session-scoped async ASGI client + liveness smoke 2026-05-19 21:21:00 -07:00
actors.py test(proxy_behavior): pin /key/generate authz matrix (18 scenarios) 2026-05-19 21:40:45 -07:00
conftest.py test(proxy_behavior): per-test scratch namespace + targeted delete_many teardown 2026-05-19 21:35:05 -07:00
test_key_generate.py test(proxy_behavior): pin /key/generate authz matrix (18 scenarios) 2026-05-19 21:40:45 -07:00
test_key_info.py test(proxy_behavior): pin /key/info authz matrix (24 scenarios) 2026-05-19 21:43:38 -07:00
test_key_list.py test(proxy_behavior): pin /key/list default-visibility matrix (8 scenarios) 2026-05-19 21:45:29 -07:00
test_key_update.py test(proxy_behavior): pin /key/update authz matrix + mutation re-read (21 scenarios) 2026-05-19 21:48:47 -07:00
test_no_management_imports.py style(proxy_behavior): apply black to G3 grep test 2026-05-19 21:36:15 -07:00
test_scratch_teardown.py test(proxy_behavior): per-test scratch namespace + targeted delete_many teardown 2026-05-19 21:35:05 -07:00
test_smoke.py test(proxy_behavior): per-test scratch namespace + targeted delete_many teardown 2026-05-19 21:35:05 -07:00
test_world_seed.py test(proxy_behavior): seed 8-actor read-world for the authz matrix 2026-05-19 21:31:38 -07:00