Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion litellm/proxy/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4262,7 +4262,7 @@ class DefaultInternalUserParams(LiteLLMPydanticObjectBase):
LitellmUserRoles.PROXY_ADMIN_VIEW_ONLY,
]
] = Field(
default=LitellmUserRoles.INTERNAL_USER,
default=LitellmUserRoles.INTERNAL_USER_VIEW_ONLY,
description="Default role assigned to new users created",
Comment thread
ryan-crabbe marked this conversation as resolved.
)
Comment thread
ryan-crabbe marked this conversation as resolved.
max_budget: Optional[float] = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,37 @@ def test_get_internal_user_settings(self, mock_proxy_config, mock_auth):
assert "user_role" in data["field_schema"]["properties"]
assert "description" in data["field_schema"]["properties"]["user_role"]

def test_get_internal_user_settings_fresh_db_defaults_to_viewer(
self, mock_auth, monkeypatch
):
"""
On a fresh DB with no saved settings, the GET endpoint should return
INTERNAL_USER_VIEW_ONLY as the default role — matching the runtime
fallback in SSO/SCIM/JWT provisioning paths.
"""
# Simulate fresh DB: no default_internal_user_params in config
empty_config = {
"litellm_settings": {},
"general_settings": {},
"environment_variables": {},
}

from litellm.proxy.proxy_server import proxy_config

async def mock_get_config():
return empty_config

monkeypatch.setattr(proxy_config, "get_config", mock_get_config)
Comment thread
ryan-crabbe marked this conversation as resolved.

response = client.get("/get/internal_user_settings")
assert response.status_code == 200

values = response.json()["values"]
assert values["user_role"] == LitellmUserRoles.INTERNAL_USER_VIEW_ONLY, (
f"Fresh DB should default to INTERNAL_USER_VIEW_ONLY, got {values['user_role']}. "
"The Pydantic default must match the runtime fallback."
)

def test_update_internal_user_settings(
self, mock_proxy_config, mock_auth, monkeypatch
):
Expand Down
Loading