Keep B2 client fixes and move VPS implementation to its standalone repository

This commit is contained in:
DCCONSTRUCTIONS
2026-09-29 12:41:21 +03:00
parent 03d44d0fb1
commit 6dd652f71e
85 changed files with 2201 additions and 9299 deletions
+34 -7
View File
@@ -210,7 +210,7 @@ def test_catalog_and_history_never_expose_password(ready, monkeypatch):
public = json.dumps([values, journal.listing(equipment, row["id"])], ensure_ascii=False)
assert "123456" not in public and '"password"' not in public and "identity_key" not in public
assert "••••••*SERV*8.4.1" in public
assert value["description"]["queue_seconds"] == 3
assert value["description"]["queue_seconds"] == 30
def test_tracker_acceptance_is_persisted_but_does_not_finish_intent(ready, monkeypatch):
@@ -375,24 +375,51 @@ def test_runtime_api_rejects_foreign_origin_and_arbitrary_command(ready):
def test_preview_matches_actual_qualified_vps_payload(ready):
import importlib.util
from pathlib import Path
from k1link.fleet.equipment_actions import plan
equipment, _, row = ready
path = Path(__file__).resolve().parents[1] / "apps/vps-host/ndc_vps/actions.py"
spec = importlib.util.spec_from_file_location("qualified_b2_actions", path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
fixture = Path(__file__).resolve().parent / "fixtures/arnavi_vps/client-v1.json"
contract = json.loads(fixture.read_text())
cases = {
case["preset"]: case
for case in contract["cases"]
if case["request"]["firmware"] == row["observed"]["firmware"]
}
for preset in catalog(equipment, row):
if preset["unavailable"]:
continue
body = plan(equipment, row, preset["command"])
body.pop("secondary")
body["id"] = "1" * 32
wire = bytes.fromhex(module.prepare(body)["binary"])
case = cases[preset["id"]]
assert body == case["request"]
wire = bytes.fromhex(case["wire_hex"])
if preset["encoding"].endswith("FC"):
assert wire.decode().replace("123456", "••••••") == preset["wire"]
else:
assert wire.hex(" ").upper() == preset["wire"]
def test_manual_repeat_uses_new_id_and_preserves_http_idempotency(ready, monkeypatch):
from k1link.fleet.equipment_command_repeat import repeat
equipment, hosts, row = ready
original = runtime.enqueue(hosts, row["id"], "1" * 32, "position")
runtime.cancel(equipment, row["id"], original["id"])
repeated = repeat(hosts, row["id"], original["id"], "2" * 32)
assert repeated["state"] == "waiting" and repeated["id"] != original["id"]
assert repeat(hosts, row["id"], original["id"], "2" * 32) == repeated
with pytest.raises(EquipmentError, match="завершения"):
repeat(hosts, row["id"], repeated["id"], "3" * 32)
assert len(journal.listing(equipment, row["id"])["items"]) == 2
assert not {"guard", "digest", "network_intent"} & repeated.keys()
def test_repeat_missing_history_is_rejected(ready):
from k1link.fleet.equipment_command_repeat import repeat
_, hosts, row = ready
with pytest.raises(EquipmentError, match="не найдена"):
repeat(hosts, row["id"], "f" * 32, "a" * 32)