feat(fleet): integrate independent trackers, VPS pairing and recoverable commands
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
"""The native access policy must not inherit slot-specific operator credentials."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from test_equipment_network import context, full_core_context # noqa: F401
|
||||
|
||||
from k1link.device_plugins.arnavi_b2 import profiles
|
||||
from k1link.device_plugins.arnavi_b2.connectivity import SIM_FIELDS
|
||||
from k1link.device_plugins.arnavi_b2.usb_protocol import Configuration, ProtocolError, Setting
|
||||
from k1link.fleet import equipment_network
|
||||
|
||||
ACCESS = {n for numbers in SIM_FIELDS.values() for n in numbers}
|
||||
|
||||
|
||||
def with_access(config, *, empty=False):
|
||||
retained = tuple(r for r in config.records if r.number not in ACCESS)
|
||||
return Configuration(
|
||||
retained + tuple(Setting(n, b"" if empty else b"private-access") for n in sorted(ACCESS))
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("flags", [0, 1 << 10, 1 << 20, (1 << 10) | (1 << 20)])
|
||||
def test_native_clears_all_six_access_fields_and_only_gprs_bans(flags):
|
||||
before = with_access(
|
||||
Configuration(
|
||||
(
|
||||
Setting(72, (flags | 2072).to_bytes(4, "big")),
|
||||
Setting(5, b"synthetic"),
|
||||
Setting(222, b"unknown"),
|
||||
)
|
||||
)
|
||||
)
|
||||
policy = profiles.Policy(connectivity={"strategy": "native"}).model_dump()
|
||||
after = profiles.prepare(before, policy)
|
||||
assert after.integer(72, 4) == 2072
|
||||
assert all(after.text(n) == "" for n in ACCESS)
|
||||
assert {r.number: r.value for r in after.records if r.number not in ACCESS | {72}} == {
|
||||
r.number: r.value for r in before.records if r.number not in ACCESS | {72}
|
||||
}
|
||||
assert profiles.prepare(after, policy).encode() == after.encode()
|
||||
# Merely reading a device never opts future devices into clearing their APNs.
|
||||
assert profiles.portable(after)["connectivity"]["strategy"] == "preserve"
|
||||
|
||||
|
||||
def test_native_rejects_missing_fields_and_conflicting_operator_values():
|
||||
with pytest.raises(ProtocolError, match="required_setting_missing"):
|
||||
profiles.prepare(
|
||||
Configuration((Setting(72, bytes(4)),)), {"connectivity": {"strategy": "native"}}
|
||||
)
|
||||
for extra in (
|
||||
{"apn": "iot"},
|
||||
{"activate": True},
|
||||
{"automatic": True},
|
||||
{"preset_id": "ru-mts-public-v1"},
|
||||
{"apn1": "iot"},
|
||||
):
|
||||
with pytest.raises(ValueError):
|
||||
profiles.Policy(connectivity={"strategy": "native", **extra})
|
||||
|
||||
|
||||
@pytest.mark.parametrize("empty", [False, True])
|
||||
def test_network_verifies_new_gprs_but_does_not_restart_for_unrelated_edits(
|
||||
full_core_context, # noqa: F811
|
||||
empty,
|
||||
):
|
||||
equipment, _, row, config = full_core_context
|
||||
config = with_access(config, empty=empty)
|
||||
path: Path = equipment.root / "evidence" / row["evidence_id"] / "configuration.bin"
|
||||
path.write_bytes(config.encode())
|
||||
row["settings"]["connectivity"] = {"strategy": "native"}
|
||||
body = equipment_network.plan(equipment, row, full=True)
|
||||
assert body["kind"] == ("configure-all" if empty else "select-sim")
|
||||
if not empty:
|
||||
assert body["sim_policy"] == "both"
|
||||
explicit = equipment_network.plan(equipment, row, full=True, select_sim=True)
|
||||
assert explicit["kind"] == "select-sim" and explicit["sim_policy"] == "both"
|
||||
assert "sim_slot" not in explicit and "sim_guard" not in explicit
|
||||
Reference in New Issue
Block a user