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 remote-tracking branch 'origin/litellm_internal_staging' into litellm_hide_admin_tabs_view_only

mateo-berribf6aa9c390cc
diff --cc ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/page.test.tsx
index e5414630c5b,84a05113177..1bdad719de4
--- 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
@@@ -110,35 -108,22 +109,51 @@@ describe("ModelsAndEndpointsPage", () =
expect(screen.queryByRole("tab", { name: "Health Status" })).not.toBeInTheDocument();
});
+ it("keeps the full admin tab order for a real admin", () => {
+ renderPage();
+ expect(screen.getAllByRole("tab").map((tab) => tab.textContent)).toEqual([
+ "All Models",
+ "Add Model",
+ "Auto-Routers Beta",
+ "LLM Credentials",
+ "Pass-Through Endpoints",
+ "Health Status",
+ "Model Retry Settings",
+ "Model Group Alias",
+ "Model Access Group Budgets Beta",
+ "Price Data Reload",
+ ]);
+ });
+
+ it("hides the admin write-form tabs from a view-only admin, keeping the read views", () => {
+ mockUseAuthorized.mockReturnValue(VIEW_ONLY_ADMIN);
+ renderPage();
+ expect(screen.getByRole("tab", { name: "All Models" })).toBeInTheDocument();
+ expect(screen.getByRole("tab", { name: "Health Status" })).toBeInTheDocument();
+ expect(screen.queryByRole("tab", { name: "LLM Credentials" })).not.toBeInTheDocument();
+ expect(screen.queryByRole("tab", { name: "Pass-Through Endpoints" })).not.toBeInTheDocument();
+ expect(screen.queryByRole("tab", { name: "Model Retry Settings" })).not.toBeInTheDocument();
+ expect(screen.queryByRole("tab", { name: "Model Group Alias" })).not.toBeInTheDocument();
+ expect(screen.queryByRole("tab", { name: /Model Access Group Budgets/ })).not.toBeInTheDocument();
+ expect(screen.queryByRole("tab", { name: "Price Data Reload" })).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);
+ renderPage();
+ expect(screen.queryByRole("tab", { name: "Add Model" })).not.toBeInTheDocument();
+ expect(screen.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);
+ renderPage();
+ expect(screen.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", () => {