mirror of
https://github.com/Such-Software/adaptive-multi-protocol-gateway.git
synced 2026-10-17 07:31:32 +02:00
Add address capture to activation plan
This commit is contained in:
@@ -50,7 +50,7 @@ plan_root = "./plan"
|
||||
|
||||
|
||||
class ActivationTest(unittest.TestCase):
|
||||
def test_activation_plan_is_ready_when_output_and_daemon_policy_are_ready(self):
|
||||
def test_activation_plan_reviews_placeholder_address_before_health(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
config_path = _write_config(
|
||||
@@ -79,9 +79,42 @@ local_port = 19081
|
||||
by_stage = {step.stage: step for step in steps if step.stage != "artifact"}
|
||||
self.assertEqual("ready", by_stage["output"].status)
|
||||
self.assertEqual("manage-owned", by_stage["daemon"].action)
|
||||
self.assertEqual("planned", by_stage["health"].status)
|
||||
self.assertEqual("capture-address", by_stage["address"].action)
|
||||
self.assertEqual("review", by_stage["address"].status)
|
||||
self.assertIn("addresses capture --protocol i2p", by_stage["address"].command)
|
||||
self.assertEqual("review", by_stage["health"].status)
|
||||
self.assertTrue(any(step.stage == "artifact" for step in steps))
|
||||
|
||||
def test_configured_address_allows_planned_activation_health(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
config_path = _write_config(
|
||||
root,
|
||||
"""
|
||||
[site.protocols.i2p]
|
||||
enabled = true
|
||||
renderer = "privacy-html"
|
||||
daemon = "i2pd"
|
||||
daemon_policy = "auto"
|
||||
i2p_url = "ready.b32.i2p"
|
||||
""",
|
||||
)
|
||||
output = root / "out/i2p"
|
||||
output.mkdir(parents=True)
|
||||
(output / ".ampg-output").write_text("generated by AMPG\n", encoding="utf-8")
|
||||
config = load_config(config_path)
|
||||
|
||||
steps = activation_steps(
|
||||
config,
|
||||
platform_provider=platform_by_name("android-termux"),
|
||||
daemon_probe=_probe(installed=False, running=False),
|
||||
)
|
||||
|
||||
by_stage = {step.stage: step for step in steps if step.stage != "artifact"}
|
||||
self.assertEqual("use-address", by_stage["address"].action)
|
||||
self.assertEqual("ready", by_stage["address"].status)
|
||||
self.assertEqual("planned", by_stage["health"].status)
|
||||
|
||||
def test_missing_output_blocks_activation(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
config_path = _write_config(
|
||||
@@ -162,6 +195,7 @@ port = 1965
|
||||
output_text = stdout.getvalue()
|
||||
self.assertIn("AMPG_APPLY_ARTIFACT", output_text)
|
||||
self.assertIn("AMPG_APPLY_STEP", output_text)
|
||||
self.assertIn('command="-"', output_text)
|
||||
self.assertIn("blocked=0", output_text)
|
||||
artifact_line = next(
|
||||
line for line in output_text.splitlines() if line.startswith("AMPG_APPLY_ARTIFACT")
|
||||
|
||||
@@ -189,7 +189,7 @@ daemon_policy = "auto"
|
||||
|
||||
def test_managed_i2p_artifacts_include_daemon_loopback_and_supervisors(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
root = Path(tmp).resolve()
|
||||
config = load_config(
|
||||
_write_config(
|
||||
root,
|
||||
@@ -223,8 +223,12 @@ tunnel_name = "example-web"
|
||||
set(by_name),
|
||||
)
|
||||
self.assertIn("[example-web]", by_name["i2pd-tunnels.conf"].content)
|
||||
self.assertIn("keys =", by_name["i2pd-tunnels.conf"].content)
|
||||
self.assertIn(
|
||||
f"keys = {root / '.ampg/state/example/i2p/example-web.dat'}",
|
||||
by_name["i2pd-tunnels.conf"].content,
|
||||
)
|
||||
self.assertIn("listen 127.0.0.1:19081", by_name["nginx-loopback.conf"].content)
|
||||
self.assertIn(f"mkdir -p {root / '.ampg/state/example/i2p'}", by_name["i2pd.run"].content)
|
||||
self.assertIn("exec i2pd", by_name["i2pd.run"].content)
|
||||
self.assertIn("exec nginx", by_name["nginx-loopback.run"].content)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user