Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Merge pull request #38872 from BerriAI/litellm_fix_viewer_add_model_tab

Mateo Wangbad55da9bfe1
diff --cc ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/page.test.tsx
index a504d75bb63,8bf3f6db8dd..1199b66621f
--- a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/page.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/page.test.tsx
@@@ -94,11 -103,27 +103,27 @@@ describe("ModelsAndEndpointsPage", () =
it("hides admin-only tabs for a non-admin user", () => {
mockUseAuthorized.mockReturnValue(NON_ADMIN);
- const { queryByRole } = renderPage();
- expect(queryByRole("tab", { name: "LLM Credentials" })).not.toBeInTheDocument();
- expect(queryByRole("tab", { name: "Health Status" })).not.toBeInTheDocument();
+ renderPage();
+ expect(screen.queryByRole("tab", { name: "LLM Credentials" })).not.toBeInTheDocument();
+ expect(screen.queryByRole("tab", { name: "Health Status" })).not.toBeInTheDocument();
});
+ // POST /model/new 403s a proxy_admin_viewer, so the form's tab must not render for one.
+ it("hides the Add Model tab for a view-only admin session", () => {
+ mockUseAuthorized.mockReturnValue(VIEW_ONLY_ADMIN);
+ const { getByRole, queryByRole } = renderPage();
+ expect(queryByRole("tab", { name: "Add Model" })).not.toBeInTheDocument();
+ expect(getByRole("tab", { name: "All Models" })).toBeInTheDocument();
+ });
+
+ // Read parity: the Auto-Routers list stays reachable for a view-only admin; only the
+ // create affordance inside it is withheld, which AutoRoutersTabPanel decides.
+ it("keeps the Auto-Routers tab for a view-only admin session", () => {
+ mockUseAuthorized.mockReturnValue(VIEW_ONLY_ADMIN);
+ const { getByRole } = renderPage();
+ expect(getByRole("tab", { name: /Auto-Routers/ })).toBeInTheDocument();
+ });
+
// Auto-routers are excluded from the All Models table, so this tab is their home: the only
// place in the product to list, create, edit or delete one.
describe("Auto-Routers tab", () => {