@@ -1053,7 +1053,7 @@ async def test_get_team_object_permission_with_already_loaded_permission():
1053
1053
from the team object without making an additional DB call.
1054
1054
"""
1055
1055
from litellm .proxy ._types import LiteLLM_ObjectPermissionTable , LiteLLM_TeamTable
1056
-
1056
+
1057
1057
# Create mock object permission
1058
1058
mock_object_permission = LiteLLM_ObjectPermissionTable (
1059
1059
object_permission_id = "perm-123" ,
@@ -1077,28 +1077,34 @@ async def test_get_team_object_permission_with_already_loaded_permission():
1077
1077
)
1078
1078
1079
1079
# Mock get_team_object to return our team with loaded permission
1080
+ # Also need to mock prisma_client from proxy_server
1081
+ mock_prisma = MagicMock ()
1080
1082
with patch (
1081
- "litellm.proxy._experimental.mcp_server.auth.user_api_key_auth_mcp.get_team_object"
1082
- ) as mock_get_team :
1083
+ "litellm.proxy.proxy_server.prisma_client" ,
1084
+ mock_prisma ,
1085
+ ):
1083
1086
with patch (
1084
- "litellm.proxy._experimental.mcp_server.auth.user_api_key_auth_mcp.get_object_permission"
1085
- ) as mock_get_perm :
1086
- mock_get_team .return_value = mock_team_obj
1087
-
1088
- # Call the method
1089
- result = await MCPRequestHandler ._get_team_object_permission (
1090
- mock_user_auth
1091
- )
1092
-
1093
- # Assert we got the object permission
1094
- assert result == mock_object_permission
1095
- assert result .mcp_servers == ["server1" , "server2" ]
1096
-
1097
- # Verify get_team_object was called
1098
- mock_get_team .assert_called_once ()
1099
-
1100
- # Verify get_object_permission was NOT called (since it was already loaded)
1101
- mock_get_perm .assert_not_called ()
1087
+ "litellm.proxy.auth.auth_checks.get_team_object"
1088
+ ) as mock_get_team :
1089
+ with patch (
1090
+ "litellm.proxy.auth.auth_checks.get_object_permission"
1091
+ ) as mock_get_perm :
1092
+ mock_get_team .return_value = mock_team_obj
1093
+
1094
+ # Call the method
1095
+ result = await MCPRequestHandler ._get_team_object_permission (
1096
+ mock_user_auth
1097
+ )
1098
+
1099
+ # Assert we got the object permission
1100
+ assert result == mock_object_permission
1101
+ assert result .mcp_servers == ["server1" , "server2" ]
1102
+
1103
+ # Verify get_team_object was called
1104
+ mock_get_team .assert_called_once ()
1105
+
1106
+ # Verify get_object_permission was NOT called (since it was already loaded)
1107
+ mock_get_perm .assert_not_called ()
1102
1108
1103
1109
1104
1110
@pytest .mark .asyncio
@@ -1108,7 +1114,7 @@ async def test_get_team_object_permission_fetches_from_db_when_not_loaded():
1108
1114
is not loaded but object_permission_id exists.
1109
1115
"""
1110
1116
from litellm .proxy ._types import LiteLLM_ObjectPermissionTable , LiteLLM_TeamTable
1111
-
1117
+
1112
1118
# Create mock object permission (to be returned from DB)
1113
1119
mock_object_permission = LiteLLM_ObjectPermissionTable (
1114
1120
object_permission_id = "perm-456" ,
@@ -1132,35 +1138,41 @@ async def test_get_team_object_permission_fetches_from_db_when_not_loaded():
1132
1138
)
1133
1139
1134
1140
# Mock the methods
1141
+ # Also need to mock prisma_client from proxy_server
1142
+ mock_prisma = MagicMock ()
1135
1143
with patch (
1136
- "litellm.proxy._experimental.mcp_server.auth.user_api_key_auth_mcp.get_team_object"
1137
- ) as mock_get_team :
1144
+ "litellm.proxy.proxy_server.prisma_client" ,
1145
+ mock_prisma ,
1146
+ ):
1138
1147
with patch (
1139
- "litellm.proxy._experimental.mcp_server.auth.user_api_key_auth_mcp.get_object_permission"
1140
- ) as mock_get_perm :
1141
- mock_get_team .return_value = mock_team_obj
1142
- mock_get_perm .return_value = mock_object_permission
1143
-
1144
- # Call the method
1145
- result = await MCPRequestHandler ._get_team_object_permission (
1146
- mock_user_auth
1147
- )
1148
-
1149
- # Assert we got the object permission
1150
- assert result == mock_object_permission
1151
- assert result .mcp_servers == ["server3" , "server4" ]
1152
-
1153
- # Verify get_team_object was called
1154
- mock_get_team .assert_called_once ()
1155
-
1156
- # Verify get_object_permission WAS called (since it wasn't loaded)
1157
- mock_get_perm .assert_called_once_with (
1158
- object_permission_id = "perm-456" ,
1159
- prisma_client = mock .ANY ,
1160
- user_api_key_cache = mock .ANY ,
1161
- parent_otel_span = mock_user_auth .parent_otel_span ,
1162
- proxy_logging_obj = mock .ANY ,
1163
- )
1148
+ "litellm.proxy.auth.auth_checks.get_team_object"
1149
+ ) as mock_get_team :
1150
+ with patch (
1151
+ "litellm.proxy.auth.auth_checks.get_object_permission"
1152
+ ) as mock_get_perm :
1153
+ mock_get_team .return_value = mock_team_obj
1154
+ mock_get_perm .return_value = mock_object_permission
1155
+
1156
+ # Call the method
1157
+ result = await MCPRequestHandler ._get_team_object_permission (
1158
+ mock_user_auth
1159
+ )
1160
+
1161
+ # Assert we got the object permission
1162
+ assert result == mock_object_permission
1163
+ assert result .mcp_servers == ["server3" , "server4" ]
1164
+
1165
+ # Verify get_team_object was called
1166
+ mock_get_team .assert_called_once ()
1167
+
1168
+ # Verify get_object_permission WAS called (since it wasn't loaded)
1169
+ mock_get_perm .assert_called_once_with (
1170
+ object_permission_id = "perm-456" ,
1171
+ prisma_client = mock .ANY ,
1172
+ user_api_key_cache = mock .ANY ,
1173
+ parent_otel_span = mock_user_auth .parent_otel_span ,
1174
+ proxy_logging_obj = mock .ANY ,
1175
+ )
1164
1176
1165
1177
1166
1178
@pytest .mark .asyncio
@@ -1170,7 +1182,7 @@ async def test_get_allowed_mcp_servers_for_team_uses_helper():
1170
1182
helper which handles both loaded and unloaded object_permission cases.
1171
1183
"""
1172
1184
from litellm .proxy ._types import LiteLLM_ObjectPermissionTable
1173
-
1185
+
1174
1186
# Create mock object permission with servers and access groups
1175
1187
mock_object_permission = LiteLLM_ObjectPermissionTable (
1176
1188
object_permission_id = "perm-789" ,
0 commit comments