fix: tie proxy readiness to actual socket bind; report real port; sync stop
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+17
-1
@@ -1,6 +1,9 @@
|
||||
from types import SimpleNamespace
|
||||
|
||||
from auto_reverse.proxy import flow_from_mitm
|
||||
import pytest
|
||||
|
||||
from auto_reverse.proxy import ProxyServer, flow_from_mitm
|
||||
from auto_reverse.store import FlowStore, ScopeFilter
|
||||
|
||||
|
||||
def _fake_mitm_flow():
|
||||
@@ -32,3 +35,16 @@ def test_flow_from_mitm_handles_missing_response():
|
||||
flow.response = None
|
||||
captured = flow_from_mitm(flow)
|
||||
assert captured is None
|
||||
|
||||
|
||||
def test_proxy_server_binds_and_reports_real_port(tmp_path):
|
||||
store = FlowStore(ScopeFilter(target_hosts={"ex.com"}))
|
||||
server = ProxyServer(store, archive_path=tmp_path / "archive.log", port=0)
|
||||
try:
|
||||
server.start()
|
||||
except Exception as exc:
|
||||
pytest.skip(f"proxy bind unavailable: {exc}")
|
||||
try:
|
||||
assert server.port != 0 # real OS-assigned port after binding
|
||||
finally:
|
||||
server.stop()
|
||||
|
||||
Reference in New Issue
Block a user