mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
test(mcp): pin PROXY_BASE_URL off in MCP OAuth tests
get_request_base_url resolves PROXY_BASE_URL ahead of request.base_url, and import litellm loads a .env from any parent directory of the checkout, so a developer with that var set (git worktrees under <repo>/.claude/worktrees/ inherit the main checkout's .env this way) had the mocked request origins silently ignored and these tests failed on unmodified code.
This commit is contained in:
parent
24123269cc
commit
87679b2e5b
2 changed files with 20 additions and 0 deletions
|
|
@ -20,3 +20,15 @@ def _hermetic_server_root_path():
|
|||
finally:
|
||||
if saved is not None:
|
||||
os.environ["SERVER_ROOT_PATH"] = saved
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _hermetic_proxy_base_url(monkeypatch):
|
||||
"""Isolate MCP discovery tests from a developer's ``PROXY_BASE_URL``.
|
||||
|
||||
``get_request_base_url`` resolves that env var ahead of the request's own base URL, and
|
||||
``import litellm`` loads a ``.env`` from any parent directory of the checkout, so a set value
|
||||
silently overrides the origins these tests drive through the request. Clearing it here pins
|
||||
the request-derived origin; a test that exercises the env override sets the value itself.
|
||||
"""
|
||||
monkeypatch.delenv("PROXY_BASE_URL", raising=False)
|
||||
|
|
|
|||
|
|
@ -1556,6 +1556,14 @@ class TestTeamScopedMCPServerAccess:
|
|||
|
||||
|
||||
class TestTemporaryMCPSessionEndpoints:
|
||||
@pytest.fixture(autouse=True)
|
||||
def unset_proxy_base_url(self, monkeypatch):
|
||||
"""``get_request_base_url`` resolves ``PROXY_BASE_URL`` ahead of ``request.base_url``, so a
|
||||
developer with that env var set (a ``.env`` in any parent directory of the checkout is
|
||||
enough, since ``import litellm`` runs dotenv) would otherwise silently bypass the mocked
|
||||
``request.base_url`` these tests assert on."""
|
||||
monkeypatch.delenv("PROXY_BASE_URL", raising=False)
|
||||
|
||||
def test_inherit_credentials_from_existing_server(self):
|
||||
payload = NewMCPServerRequest(
|
||||
server_id="server-123",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue