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
+1 -66
View File
@@ -1,13 +1,11 @@
"""Card identity, three-field APN overlay and the last network write boundary."""
import json
import time
import pytest
from test_b2_cellular_telemetry import package, status
from test_b2_cellular_telemetry import status
from test_b2_sim_identity import CARD_A, CARD_B, IMEI, capture, exchange
from test_b2_sim_network import AT, tags, update
from test_vps_host import full_context, reach_sim_restart, sim_context, store # noqa: F401
from k1link.device_plugins.arnavi_b2 import profiles, sim_access
from k1link.device_plugins.arnavi_b2.sim_network import binding
@@ -95,66 +93,3 @@ def test_automatic_overlay_replaces_apn_and_credentials_only_for_selected_sim():
assert all(desired.value(n) == config.value(n) for n in (67, 68, 69, 222))
assert desired.integer(72, 4) == 1 << 10
assert not profiles.portable(desired)["connectivity"]["automatic"]
def guarded(context):
command, body, _, _, _, now = context
body["sim_guard"] = {"slot": 2, "sid": CARD_A[1]}
command.sim_guard.observe(body["imei"], package(int(now[0]), tags(2, CARD_A[1]) + status()))
return command, body, now
def test_card_swap_after_dispatch_prevents_http_configuration_write(sim_context): # noqa: F811
command, body, now = guarded(sim_context)
_, _, before, _, wire, _ = sim_context
command.submit(body)
command.session_activity[body["imei"], "live"] = time.monotonic()
assert command.take(body["imei"], "live")
command.web_receive(wire(5, before.encode()), "192.0.2.1")
now[0] += 16
command.session_activity[body["imei"], "live"] = time.monotonic()
assert command.take(body["imei"], "live")
command.sim_guard.observe(body["imei"], package(int(now[0]), tags(2, CARD_B[1]) + status()))
assert command.web_receive(wire(2), "192.0.2.1") is None
result = command.get(body["id"])
assert result["state"] == "rejected" and result["reason"] == "sim_card_changed"
assert "write_reply_sent_at" not in result and "sim_guard" not in result
def test_gprs_without_new_card_identity_cannot_confirm_automatic_access(sim_context): # noqa: F811
command, body, now = guarded(sim_context)
reach_sim_restart(sim_context)
assert command.take(body["imei"], "live")
now[0] += 2
command.session_started[body["imei"], "new"] = time.monotonic()
now[0] += 1
command.receive(body["imei"], package(int(now[0]), status()), "new")
assert command.get(body["id"])["state"] == "dispatched"
now[0] += 1
command.receive(body["imei"], package(int(now[0]), tags(2, CARD_A[1]) + status()), "new")
result = command.get(body["id"])
assert result["state"] == "sim_selected" and result["sim_guard_verified"] is True
def test_guard_and_waiting_intent_survive_vps_restart(sim_context): # noqa: F811
from ndc_vps.commands import Commands
from ndc_vps.operations import Operations
command, body, now = guarded(sim_context)
runtime = Operations(command.store, command)
runtime.submit(body)
command.sim_guard.observe(body["imei"], package(int(now[0] + 1), status(second=0)))
now[0] += 2
command.session_activity[body["imei"], "live"] = time.monotonic()
runtime.advance(body["imei"])
assert runtime.get(body["id"])["runtime_phase"] == "waiting-identity"
assert runtime.get(body["id"])["attempt_count"] == 0
restored = Operations(command.store, Commands(command.store))
restored.commands.sessions[body["imei"]] = {"new"}
restored.commands.session_activity[body["imei"], "new"] = time.monotonic()
restored.commands.sim_guard.observe(
body["imei"], package(int(now[0]), tags(2, CARD_B[1]) + status())
)
assert restored.get(body["id"])["state"] == "rejected"
assert restored.get(body["id"])["reason"] == "sim_card_changed"
assert restored.get(body["id"])["attempt_count"] == 0