Repository navigation
test(e2e): fill management P0 coverage gaps and reconcile registry markers - #32409
mubashir1osmani wants to merge 1 commit into
Conversation
…rkers Adds the missing Management/UI P0 e2e tests the coverage registry enumerates but nothing covered: budget-create persistence read back through /budget/info, proxy-admin-only enforcement on /budget/new and /team/new, and team-admin-required enforcement on /team/member_add and /team/member_delete. Each authz test also asserts the write did not land, so a removed check fails the test rather than passing on the status code alone Reconciles the covers markers already on the suite to real registry ids so the collector counts them instead of flagging orphans: management.team.new.persists to mgmt.team.new.persists, mgmt.user.new.persists to mgmt.user.new.happy_path, mgmt.organization.new.persists to mgmt.organization.new.happy_path, and the route-scoped llm-only-key denial to other.auth.virtual_key.route_permission_enforced, which is the contract it actually proves. The key-generate test additionally claims mgmt.key.info.persists and the member add/delete test claims mgmt.team.member_delete.persists, both of which they already assert This raises Management/UI P0 coverage from 4/19 to 13/19. The remaining gaps are the three key.*.admin_only cells (internal users self-serve keys, so "admin_only" is the wrong framing and needs a registry decision), the SSO-driven key.generate.happy_path, and the model.* cells handled on the model-management fold branch
Greptile SummaryThis PR fills P0 coverage gaps in the management-route e2e suite by adding tests for budget persistence, proxy-admin-only enforcement on
Confidence Score: 4/5Safe to merge — all changes are confined to the e2e test directory, no production code is touched. The new tests are well-structured: each authz test verifies both the denied status code and that the write did not land, which is a stronger contract than a status-code check alone. The BudgetNewBody.budget_id field is declared required in the test model but optional on the server, so the auto-ID generation path can never be exercised. The immediate read-back in test_new_persists_to_budget_info works today because budgets bypass the proxy's auth cache, but there is no comment explaining that invariant, leaving a latent fragility if the caching model changes. No files require special attention; both observations are in the test layer only.
|
| Filename | Overview |
|---|---|
| tests/e2e/models.py | Adds six budget management model classes (BudgetNewBody, BudgetInfoBody, BudgetData, BudgetInfoResponse, BudgetDeleteBody) that mirror the server's _types.py shapes; field names and types are correct (BudgetDeleteRequest.id confirmed). |
| tests/e2e/management/management_client.py | Adds create_budget, delete_budget, budget_row, budget_new_status, team_member_add_status, and team_member_delete_status methods; follows the existing patterns exactly (unwrap for reads, discarded result for cleanups, transport.send for raw-status probes). |
| tests/e2e/management/test_management_e2e.py | Adds TestBudgetRoutes and four new TestTeamRoutes tests covering budget persistence, budget/team admin-only enforcement (401), and team-admin-required member write enforcement (403); marker reconciliation on existing tests is correct and does not weaken coverage. |
Reviews (1): Last reviewed commit: "test(e2e): fill management P0 coverage g..." | Re-trigger Greptile
| class BudgetNewBody(BaseModel): | ||
| budget_id: str | ||
| max_budget: float | None = None | ||
| soft_budget: float | None = None | ||
| budget_duration: str | None = None |
There was a problem hiding this comment.
The test model declares
budget_id as a required str, but the server's BudgetNewRequest has budget_id: Optional[str] — the proxy auto-generates an ID when none is provided. Because the test model enforces the field, test_new_persists_to_budget_info can never exercise the auto-ID path. Since every call in the suite already passes an explicit ID this causes no test failures, but the schema divergence will silently prevent any future test that wants to omit budget_id from compiling correctly.
| class BudgetNewBody(BaseModel): | |
| budget_id: str | |
| max_budget: float | None = None | |
| soft_budget: float | None = None | |
| budget_duration: str | None = None | |
| class BudgetNewBody(BaseModel): | |
| budget_id: str | None = None | |
| max_budget: float | None = None | |
| soft_budget: float | None = None | |
| budget_duration: str | None = None |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| def test_new_persists_to_budget_info(self, client: ManagementClient, resources: ResourceManager) -> None: | ||
| budget_id = f"e2e-mgmt-budget-{unique_marker()}" | ||
| _create_budget( | ||
| client, | ||
| resources, | ||
| BudgetNewBody(budget_id=budget_id, max_budget=42.5, soft_budget=21.25, budget_duration="30d"), | ||
| ) | ||
|
|
||
| row = client.budget_row(budget_id) | ||
| assert row is not None, f"/budget/info does not list {budget_id} after /budget/new" | ||
| assert row.max_budget == 42.5, f"/budget/info reports max_budget {row.max_budget}, configured 42.5" | ||
| assert row.soft_budget == 21.25, f"/budget/info reports soft_budget {row.soft_budget}, configured 21.25" | ||
| assert row.budget_duration == "30d", ( | ||
| f"/budget/info reports budget_duration {row.budget_duration!r}, configured '30d'" | ||
| ) | ||
| assert row.budget_reset_at is not None, ( | ||
| "a budget with a 30d duration must persist a computed budget_reset_at, got None" | ||
| ) |
There was a problem hiding this comment.
No polling before budget read-back
test_new_persists_to_budget_info calls client.budget_row immediately after _create_budget returns. Every other persistence test in this file that touches an entity the proxy might buffer (keys, teams) uses _poll to absorb propagation delays, but budgets skip this step. If the proxy ever starts caching budget writes before committing to the DB, or if replication lag is introduced, this test will flake with a spurious None result on the first read. Adding an explicit comment explaining why immediate read-back is safe here (direct DB write, no cache layer) would make the intentional design clear to future maintainers.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Closing this as stale since it has had no activity in over 30 days. Feel free to reopen if it is still needed. |
Relevant issues
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Captured against a live proxy on localhost:4000 at commit
bfc485b21b, hitting the real control plane with no mocks. Each behavior below is exactly what the corresponding new test asserts1) mgmt.budget.new.persists - create a budget, then read it back through a separate route (/budget/info) to prove it survived the DB roundtrip with a computed reset window
2) mgmt.budget.new.admin_only and mgmt.team.new.admin_only - a key bound to a non-admin internal_user is refused 401 on the proxy-admin-only writes
3) mgmt.team.member_add.member_forbidden and mgmt.team.member_delete.member_forbidden - a plain team member (role user, not team admin) is refused 403 on the member writes
The full management suite (12 tests) runs green against this same proxy
Type
✅ Test
Changes
The e2e coverage registry that landed in #32304 enumerates the Management/UI behaviors we want covered, but only 4 of its 19 P0 cells had a covering test. This fills the gap for the key/team/user/budget routes and leaves the model-management cells to the model-management fold branch
New tests in
tests/e2e/management/: budget-create persistence read back through /budget/info (asserting max, soft, duration, and a computed budget_reset_at all survive), proxy-admin-only enforcement on /budget/new and /team/new, and team-admin-required enforcement on /team/member_add and /team/member_delete. The two authz families assert different real contracts, so they are modelled separately: admin_only is the role check that answers 401 "Only proxy admin can be used ...", while member_forbidden is the team-admin check that answers 403 "not proxy admin OR team admin". Every authz test also reads back the resource afterwards and asserts the write did not land, so removing the check fails the test rather than passing on the status code aloneI also reconciled the covers markers already on the suite to real registry ids so the collector counts them instead of flagging them as orphans:
management.team.new.persiststomgmt.team.new.persists,mgmt.user.new.persiststomgmt.user.new.happy_path,mgmt.organization.new.persiststomgmt.organization.new.happy_path, and the route-scoped llm-only-key denial toother.auth.virtual_key.route_permission_enforced, which is the contract it actually proves (allowed_routes whitelisting), not a role check. The key-generate test additionally claimsmgmt.key.info.persistsand the member add/delete test claimsmgmt.team.member_delete.persists, both already asserted in those testsThis moves Management/UI P0 coverage from 4/19 to 13/19. The remaining six P0 gaps are deliberate: the three
key.*.admin_onlycells are mis-framed because internal users self-serve their own keys (/key/generate|update|deleteare ininternal_user_routes), so "admin_only" there needs a registry decision rather than a misleading test;key.generate.happy_pathis the SSO-driven UI path; and the twomodel.*cells belong to the model-management fold branch