BIG BIG BIG BIG BIG UPDATES

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
gabdevele
2026-05-04 23:59:48 +02:00
co-authored by Copilot
Unverified
parent 46f7cd6a5f
commit 93ba8e9ac2
88 changed files with 7591 additions and 447 deletions
@@ -0,0 +1,75 @@
import asyncio
from pathlib import Path
from models.proxy import ProxyDocument
from models.service import ServiceEndpointDocument
from services.mitmproxy.manager import MitmdumpManager
def make_proxy(**updates):
data = {
"proxy_port": 8080,
"name": "svc",
"code": "",
"service": ServiceEndpointDocument(port=9000),
}
data.update(updates)
return ProxyDocument(**data)
def test_reverse_mode_is_built_from_service():
manager = MitmdumpManager()
proxy = make_proxy(protocol="tcp")
command = manager.build_command(
"mitmdump",
proxy,
9100,
Path("/tmp/addon.py"),
Path("/tmp/conf/config.yaml"),
)
assert "reverse:tcp://127.0.0.1:9100@8080" in command
assert "--listen-port" not in command
def test_raw_mode_spec_overrides_generated_mode():
manager = MitmdumpManager()
proxy = make_proxy(mode="regular", mode_spec="wireguard:/tmp/wg.conf@51820")
command = manager.build_command(
"mitmdump",
proxy,
None,
Path("/tmp/addon.py"),
Path("/tmp/conf/config.yaml"),
)
assert "wireguard:/tmp/wg.conf@51820" in command
assert "--listen-port" not in command
def test_regular_mode_uses_proxy_port_as_listen_port():
manager = MitmdumpManager()
proxy = make_proxy(mode="regular")
command = manager.build_command(
"mitmdump",
proxy,
None,
Path("/tmp/addon.py"),
Path("/tmp/conf/config.yaml"),
)
assert "regular" in command
assert command[-2:] == ["--listen-port", "8080"]
def test_running_document_without_pid_is_treated_as_stopped():
manager = MitmdumpManager()
proxy = make_proxy(status="running", pid=None)
async def run():
return await manager.status(proxy)
assert asyncio.run(run()) == "stopped"