MCPcopy
hub / github.com/urllib3/urllib3 / test_proxy_rejection

Method test_proxy_rejection

test/contrib/test_socks.py:386–406  ·  view source on GitHub ↗
(self, monkeypatch: pytest.MonkeyPatch)

Source from the content-addressed store, hash-verified

384 pm.request("GET", "http://example.com", retries=False)
385
386 def test_proxy_rejection(self, monkeypatch: pytest.MonkeyPatch) -> None:
387 _set_up_fake_getaddrinfo(monkeypatch)
388 evt = threading.Event()
389
390 def request_handler(listener: socket.socket) -> None:
391 sock = listener.accept()[0]
392
393 handler = handle_socks5_negotiation(sock, negotiate=False)
394 addr, port = next(handler)
395 with pytest.raises(StopIteration):
396 handler.send(False)
397
398 evt.wait()
399 sock.close()
400
401 self._start_server(request_handler)
402 proxy_url = f"socks5h://{self.host}:{self.port}"
403 with socks.SOCKSProxyManager(proxy_url) as pm:
404 with pytest.raises(NewConnectionError):
405 pm.request("GET", "http://example.com", retries=False)
406 evt.set()
407
408 def test_socks_with_password(self) -> None:
409 def request_handler(listener: socket.socket) -> None:

Callers

nothing calls this directly

Calls 3

_set_up_fake_getaddrinfoFunction · 0.85
_start_serverMethod · 0.45
requestMethod · 0.45

Tested by

no test coverage detected