From 7370cdc688aa581b6f9300492a6e99c5cf48ae24 Mon Sep 17 00:00:00 2001 From: Joshua Mesilane Date: Tue, 7 Apr 2026 16:28:49 +1000 Subject: [PATCH] Update openapi and fix the test script --- repeater/web/openapi.yaml | 6 +++--- tests/test_engine.py | 33 ++++++++++++++++----------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/repeater/web/openapi.yaml b/repeater/web/openapi.yaml index e6dce1b..a353b0f 100644 --- a/repeater/web/openapi.yaml +++ b/repeater/web/openapi.yaml @@ -1235,10 +1235,10 @@ paths: # ============================================================================ # Network Policy # ============================================================================ - /global_flood_policy: + /unscoped_flood_policy: get: tags: [Network Policy] - summary: Get global flood policy + summary: Get unscoped flood policy description: Retrieve current network flood policy configuration security: - BearerAuth: [] @@ -1252,7 +1252,7 @@ paths: type: object post: tags: [Network Policy] - summary: Update global flood policy + summary: Update unscoped flood policy description: Modify network flood policy settings security: - BearerAuth: [] diff --git a/tests/test_engine.py b/tests/test_engine.py index 6b309c5..060b88a 100644 --- a/tests/test_engine.py +++ b/tests/test_engine.py @@ -46,7 +46,7 @@ def _make_config(**overrides) -> dict: "node_name": "test-node", }, "mesh": { - "global_flood_allow": True, + "unscoped_flood_allow": True, "loop_detect": "off", }, "delays": { @@ -228,11 +228,10 @@ class TestFloodForward: assert result is None assert "do not retransmit" in pkt.drop_reason.lower() - def test_global_flood_deny_plain_flood(self, handler): - handler.config["mesh"]["global_flood_allow"] = False + def test_unscoped_flood_deny_plain_flood(self, handler): + handler.config["mesh"]["unscoped_flood_allow"] = False pkt = _make_flood_packet() - # When global_flood_allow=False, flood_forward calls _check_transport_codes - # which will fail because there are no transport codes on a plain flood + # When unscoped_flood_allow=False, flood_forward should fail on a packet type without a transport code defined result = handler.flood_forward(pkt) assert result is None @@ -656,26 +655,26 @@ class TestHashStabilityThroughForwarding: # =================================================================== -# 9. Global flood policy +# 9. unscoped flood policy # =================================================================== -class TestGlobalFloodPolicy: - """global_flood_allow=False blocks plain flood, transport checked.""" +class TestUnscopedFloodPolicy: + """unscoped_flood_allow=False blocks plain flood, transport checked.""" def test_flood_blocked_by_policy(self, handler): - handler.config["mesh"]["global_flood_allow"] = False + handler.config["mesh"]["unscoped_flood_allow"] = False pkt = _make_flood_packet() result = handler.flood_forward(pkt) assert result is None def test_direct_unaffected_by_flood_policy(self, handler): - handler.config["mesh"]["global_flood_allow"] = False + handler.config["mesh"]["unscoped_flood_allow"] = False pkt = _make_direct_packet() result = handler.direct_forward(pkt) assert result is not None # direct is not blocked by flood policy def test_transport_flood_checked_when_policy_off(self, handler): - handler.config["mesh"]["global_flood_allow"] = False + handler.config["mesh"]["unscoped_flood_allow"] = False pkt = _make_transport_flood_packet() # Will call _check_transport_codes which will fail (no storage keys) result = handler.flood_forward(pkt) @@ -812,7 +811,7 @@ class TestGetDropReason: assert "Path too long" in reason def test_flood_policy_reason(self, handler): - handler.config["mesh"]["global_flood_allow"] = False + handler.config["mesh"]["unscoped_flood_allow"] = False pkt = _make_flood_packet() reason = handler._get_drop_reason(pkt) assert "flood" in reason.lower() @@ -1202,7 +1201,7 @@ BAD_PACKETS = [ "no path"), ("bad_flood_policy_off", - "Plain flood when global_flood_allow=False (needs config override)", + "Plain flood when unscoped_flood_allow=False (needs config override)", lambda: _make_flood_packet(payload=b"\x01\x02"), "transport codes"), @@ -1323,9 +1322,9 @@ class TestBadPacketArray: BAD_PACKETS, ids=_bad_ids, ) def test_process_packet_drops(self, handler, name, desc, builder, expected_reason): - # Two entries need global_flood_allow=False + # Two entries need unscoped_flood_allow=False if "policy_off" in name: - handler.config["mesh"]["global_flood_allow"] = False + handler.config["mesh"]["unscoped_flood_allow"] = False pkt = builder() result = handler.process_packet(pkt, snr=5.0) @@ -1337,7 +1336,7 @@ class TestBadPacketArray: ) def test_drop_reason_set(self, handler, name, desc, builder, expected_reason): if "policy_off" in name: - handler.config["mesh"]["global_flood_allow"] = False + handler.config["mesh"]["unscoped_flood_allow"] = False pkt = builder() handler.process_packet(pkt, snr=5.0) @@ -1353,7 +1352,7 @@ class TestBadPacketArray: def test_bad_packet_not_marked_seen(self, handler, name, desc, builder, expected_reason): """Dropped packets must NOT pollute the seen cache.""" if "policy_off" in name: - handler.config["mesh"]["global_flood_allow"] = False + handler.config["mesh"]["unscoped_flood_allow"] = False pkt = builder() handler.process_packet(pkt, snr=5.0)