litellm/tests/test_litellm/proxy
Cole McIntosh 6578133bb7
Fix user-team association issues in LiteLLM proxy (#12082)
* Fix user-team association issues in LiteLLM proxy

- Update list_team function to properly filter teams using user's teams array instead of only checking members_with_roles field
- Add Field descriptions and docstring to TeamMemberAddRequest and related models for better Swagger/OpenAPI documentation
- Maintain backward compatibility with fallback to members_with_roles if user lookup fails

This ensures users created with teams parameter appear correctly in team views and improves API documentation.

* Fix duplicate member checking in team_member_add endpoint

- Enhanced team_member_add_duplication_check to check both user_id and user_email
- Added additional duplicate prevention logic after user creation/lookup
- Fixed issue where users added by email could be duplicated in teams
- Added logging for debugging duplicate detection

This addresses the bug where adding the same user by email multiple times would create duplicate entries in the team's members_with_roles array.

* Improve duplicate member prevention in team_member_add

- Enhanced early duplicate check to handle both user_id and user_email
- Added late-stage duplicate prevention after user lookup/creation
- Fixed issue where users could be added multiple times by email
- Cleaned up debug logging

Note: There's still an edge case where the duplicate prevention may not work
correctly in all scenarios. This needs further investigation and testing.

* Refactor team_member_add endpoint for improved member management

- Split team_member_add functionality into smaller, dedicated functions for permission validation, member processing, and team member list updates.
- Enhanced permission checks to ensure only authorized users can add members.
- Streamlined member addition logic to reduce redundancy and improve readability.
- Maintained existing functionality while improving code structure and maintainability.

* Add tests for team_member_add helper functions

- Add test for _validate_team_member_add_permissions with admin user
- Add test for _validate_team_member_add_permissions with non-admin user
- Add test for _process_team_members with single member
- Add test for _process_team_members with multiple members
- Add test for _update_team_members_list with new member
- Add test for _update_team_members_list duplicate prevention

These tests ensure the refactored helper functions work correctly
after fixing the PLR0915 linting error.
2025-06-27 21:29:49 -07:00
..
_experimental/mcp_server/auth [Feat] MCP - Allow connecting to MCP with authentication headers + Allow clients to specify MCP headers (#11890) (#11891) 2025-06-19 20:07:08 -07:00
anthropic_endpoints test fixes 2025-06-25 18:42:06 -07:00
auth JWT Auth - correctly return user email + UI Model Update - Allow editing model access group for existing model (#11783) 2025-06-16 22:11:04 -07:00
client
common_utils Update enduser spend and budget reset date based on budget duration (#8460) 2025-06-08 08:39:14 -07:00
db build(VLLM-Passthrough-with-loadbalancing-support-(enables-using-model-list-for-VLLM-/classify-endpoint)): Closes #11205 2025-05-31 09:00:04 -07:00
experimental/mcp_server
guardrails build(VLLM-Passthrough-with-loadbalancing-support-(enables-using-model-list-for-VLLM-/classify-endpoint)): Closes #11205 2025-05-31 09:00:04 -07:00
health_endpoints
hooks GA Multi-instance rate limiting v2 Requirements + New - specify token rate limit type - output / input / total (#11646) 2025-06-11 22:05:13 -07:00
image_endpoints Feat: add add azure endpoint for image endpoints (#11482) 2025-06-06 10:38:37 -07:00
management_endpoints Fix user-team association issues in LiteLLM proxy (#12082) 2025-06-27 21:29:49 -07:00
management_helpers Squashed commit of the following: 2025-06-20 23:11:53 -07:00
middleware
openai_files_endpoint fix(proxy): Add managed_files hook to test_mock_create_audio_file 2025-06-26 10:42:25 -06:00
pass_through_endpoints [Feat] UI QA: Pass through endpoints (#11939) 2025-06-20 18:35:38 -07:00
spend_tracking Fix boto3 tracer wrapping for observability (#11869) 2025-06-18 15:47:55 -07:00
test_configs
types_utils
ui_crud_endpoints Refactor settings response models in proxy_setting_endpoints.py 2025-06-04 15:08:05 -06:00
test_caching_routes.py [Bug Fix] Ensure /redis/info works on GCP Redis (#11732) 2025-06-14 15:35:09 -07:00
test_common_request_processing.py [Feat] DD Trace - Add instrumentation for streaming chunks (#11338) 2025-06-02 16:48:39 -07:00
test_custom_proxy.py Custom Root Path Improvements: don't require reserving /litellm route (#11460) 2025-06-05 16:36:47 -07:00
test_health_check_functions.py Implement health check backend API and storage functionality - fix ci/cd (#11852) 2025-06-18 06:57:08 -07:00
test_litellm_pre_call_utils.py Minor Fixes (#11868) 2025-06-18 14:12:59 -07:00
test_proxy_cli.py add ciphers in command and pass to hypercorn for proxy (#11916) 2025-06-20 14:45:48 -07:00
test_proxy_server.py Managed Files + Batches - filter deployments to only those where file was written + save all model file id mappings in DB (prev just 1st one) (#12048) 2025-06-25 21:27:06 -07:00
test_proxy_types.py Litellm dev 06 06 2025 p1 (#11496) 2025-06-07 09:12:16 -07:00
test_proxy_utils.py UI / SSO - Update proxy admin id role in DB + Handle SSO redirects with custom root path (#11384) 2025-06-03 21:16:55 -07:00
test_route_llm_request.py Update mistral 'supports_response_schema' field + Fix ollama embedding (#12024) 2025-06-25 07:20:13 -07:00
test_spend_log_cleanup.py [Feat] Make batch size for maximum retention in spend logs a controllable parameter (#11459) 2025-06-05 17:11:51 -07:00
test_team_member_update.py