|
1 | 1 | import logging |
2 | | -import socket |
3 | 2 | from typing import Any |
4 | 3 |
|
5 | 4 | import pytest |
@@ -164,45 +163,3 @@ async def on_call_tool(ctx: ServerRequestContext, params: CallToolRequestParams) |
164 | 163 | assert result.is_error is False |
165 | 164 |
|
166 | 165 | assert "Tool mystery_tool not listed" in caplog.text |
167 | | - |
168 | | - |
169 | | -@pytest.mark.anyio |
170 | | -async def test_client_does_not_dereference_network_ref(monkeypatch: pytest.MonkeyPatch): |
171 | | - """SEP-2106: validating a result must not fetch a network `$ref` in the output schema. |
172 | | -
|
173 | | - The output schema references a network URI under a property the structured content |
174 | | - never sets. A socket guard fails the test if the client opens any connection while |
175 | | - validating, proving the ref is never dereferenced. |
176 | | - """ |
177 | | - |
178 | | - def no_network(*args: object, **kwargs: object) -> None: |
179 | | - raise AssertionError("client attempted a network connection while validating a tool result") # pragma: no cover |
180 | | - |
181 | | - monkeypatch.setattr(socket.socket, "connect", no_network) |
182 | | - monkeypatch.setattr(socket, "create_connection", no_network) |
183 | | - |
184 | | - output_schema = { |
185 | | - "type": "object", |
186 | | - "properties": { |
187 | | - "ok": {"type": "boolean"}, |
188 | | - "profile": {"$ref": "https://canary.invalid/profile-schema.json"}, |
189 | | - }, |
190 | | - "required": ["ok"], |
191 | | - } |
192 | | - |
193 | | - server = _make_server( |
194 | | - tools=[ |
195 | | - Tool( |
196 | | - name="lookup", |
197 | | - description="Look something up", |
198 | | - input_schema={"type": "object"}, |
199 | | - output_schema=output_schema, |
200 | | - ) |
201 | | - ], |
202 | | - structured_content={"ok": True}, |
203 | | - ) |
204 | | - |
205 | | - async with Client(server) as client: |
206 | | - result = await client.call_tool("lookup", {}) |
207 | | - assert result.is_error is False |
208 | | - assert result.structured_content == {"ok": True} |
0 commit comments