fix: correct "bugs" to "issues" in routing table and README references across multiple documentation files

This commit is contained in:
2026-06-14 07:48:10 +00:00
parent f79a427f32
commit f2b910ea75
162 changed files with 7011 additions and 1134 deletions
+53
View File
@@ -1,12 +1,27 @@
# retoor <retoor@molodetz.nl>
import ipaddress
import httpx
import pytest
from devplacepy import net_guard
from devplacepy.curl_transport import CurlTransport
from devplacepy.net_guard import BlockedAddressError
from tests.conftest import run_async
class _RecordingInner(httpx.AsyncBaseTransport):
def __init__(self):
self.called = False
self.closed = False
async def handle_async_request(self, request):
self.called = True
return httpx.Response(200, content=b"ok", request=request)
async def aclose(self):
self.closed = True
def test_loopback_is_blocked():
assert net_guard.is_blocked_address(ipaddress.ip_address("127.0.0.1"))
@@ -67,3 +82,41 @@ def test_guard_allow_private_skips_resolution():
net_guard.guard_public_url("http://127.0.0.1:9000/x", allow_private=True)
)
assert host == "127.0.0.1"
def test_guarded_client_wraps_stealth_transport():
client = net_guard.guarded_async_client(timeout=5.0)
transport = client._transport
assert isinstance(transport, net_guard._GuardedTransport)
assert isinstance(transport._inner, CurlTransport)
run_async(client.aclose())
def test_guarded_transport_blocks_before_delegating():
inner = _RecordingInner()
transport = net_guard._GuardedTransport(inner)
request = httpx.Request("GET", "http://127.0.0.1/admin")
with pytest.raises(BlockedAddressError):
run_async(transport.handle_async_request(request))
assert inner.called is False
def test_guarded_transport_delegates_when_allowed(monkeypatch):
async def _allow(url, **kwargs):
return "example.com"
monkeypatch.setattr(net_guard, "guard_public_url", _allow)
inner = _RecordingInner()
transport = net_guard._GuardedTransport(inner)
response = run_async(
transport.handle_async_request(httpx.Request("GET", "https://example.com/x"))
)
assert inner.called is True
assert response.status_code == 200
def test_guarded_transport_aclose_closes_inner():
inner = _RecordingInner()
transport = net_guard._GuardedTransport(inner)
run_async(transport.aclose())
assert inner.closed is True