Live reads go through an operator proxy pool (round-robin over the newest 100 entries, cooling on connect failures, no direct fallback); stored clearances are replayed only on the exit that earned them. Identity, clearance, solver and Turnstile rungs escalate automatically. fetch_pages reads up to 12 URLs four at a time with per-item isolation. report/reports/reports_update keep a durable queue of unreadable pages for the operator. Ships a pinned multi-stage image (non-root 10001, data in /data), an ordered CI with static gates, tests on 3.12 and 3.13 at 85% coverage, an offline image smoke, and sha/latest publishing gated on main.
90 lines
2.0 KiB
Python
90 lines
2.0 KiB
Python
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
|
|
from servers import Server, Site, ca_and_tls, http_proxy, https_proxy, socks5 # noqa: E402
|
|
|
|
import proxy # noqa: E402
|
|
import transport # noqa: E402
|
|
|
|
|
|
@pytest.fixture
|
|
def site():
|
|
server = Site()
|
|
yield server
|
|
server.close()
|
|
|
|
|
|
@pytest.fixture
|
|
def ca(tmp_path, monkeypatch):
|
|
path, context = ca_and_tls()
|
|
monkeypatch.setenv("MCP_PROXY_CA", path)
|
|
monkeypatch.setenv("MCP_HTTP_MAX_RETRIES", "2")
|
|
monkeypatch.setattr(transport, "_bundle", None)
|
|
return context
|
|
|
|
|
|
@pytest.fixture
|
|
def proxies(ca):
|
|
made = {
|
|
"http": Server(http_proxy()),
|
|
"https": Server(https_proxy(ca)),
|
|
"socks5": Server(socks5()),
|
|
"creds": Server(http_proxy(("user", "pa ss"))),
|
|
}
|
|
yield made
|
|
for server in made.values():
|
|
server.close()
|
|
|
|
|
|
@pytest.fixture
|
|
def dead():
|
|
server = Server(http_proxy())
|
|
server.close()
|
|
return server
|
|
|
|
|
|
@pytest.fixture
|
|
def pool(monkeypatch):
|
|
def configure(*urls: str, route: str = "proxy") -> proxy.Pool:
|
|
made = proxy.Pool(_route=route)
|
|
if urls:
|
|
made.load_literal("[" + ",".join(f'"{url}"' for url in urls) + "]")
|
|
monkeypatch.setattr(transport, "POOL", made)
|
|
transport._pauses._until.clear()
|
|
return made
|
|
|
|
return configure
|
|
|
|
|
|
@pytest.fixture
|
|
def reports_file(tmp_path, monkeypatch):
|
|
path = tmp_path / "reports.jsonl"
|
|
monkeypatch.setenv("MCP_REPORT_FILE", str(path))
|
|
|
|
import reports
|
|
|
|
monkeypatch.setattr(reports, "_PATH", path)
|
|
return path
|
|
|
|
|
|
@pytest.fixture
|
|
def clearance_file(tmp_path, monkeypatch):
|
|
path = tmp_path / "clearance.json"
|
|
|
|
import clearance
|
|
|
|
monkeypatch.setattr(clearance, "_FILE", path)
|
|
return path
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _quiet(monkeypatch):
|
|
monkeypatch.setenv("WSL_UTF8", "1")
|
|
monkeypatch.delenv("MCP_SOLVER", raising=False)
|
|
yield
|