-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
fix(tests): Add missing mocks for MCP IP filtering and updated APIs #20652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,23 @@ | |
| from unittest.mock import AsyncMock, MagicMock, patch | ||
|
|
||
|
|
||
| # Fixture to mock IP address check for all MCP tests | ||
| # This prevents tests from failing due to IP-based access control | ||
| @pytest.fixture(autouse=True) | ||
| def mock_mcp_client_ip(): | ||
| """Mock IPAddressUtils.get_mcp_client_ip to return None for all tests. | ||
|
|
||
| This bypasses IP-based access control in tests, since the MCP server's | ||
| available_on_public_internet defaults to False and mock requests don't | ||
| have proper client IP context. | ||
| """ | ||
| with patch( | ||
| "litellm.proxy._experimental.mcp_server.discoverable_endpoints.IPAddressUtils.get_mcp_client_ip", | ||
| return_value=None, | ||
| ): | ||
| yield | ||
|
Comment on lines
+8
to
+20
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Autouse patch targets wrong symbol This fixture patches Consider patching the source symbol ( |
||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_authorize_endpoint_includes_response_type(): | ||
| """Test that authorize endpoint includes response_type=code parameter (fixes #15684)""" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lost behavior coverage
MockGuardrail.apply_guardrail()now always returnsNoneand the tests only assert the handler returnsdataunchanged, which removes coverage for the handler’s behavior when a guardrail returns a modification payload. IfMCPGuardrailTranslationHandler.process_input_messages()still supports applying updates from guardrail output, it’d be good to keep at least one test asserting those updates are handled (adapted to the new tool-based shape).