feat(device-plugins): add profiled K1 lifecycle and canonical data plane
This commit is contained in:
@@ -8,31 +8,34 @@ from k1link.ble.wifi_provisioning import (
|
||||
|
||||
|
||||
def test_build_wifi_provisioning_frame_layout() -> None:
|
||||
frame = build_wifi_provisioning_frame("LabNet", "correct horse")
|
||||
credential = "x" * 13
|
||||
frame = build_wifi_provisioning_frame("LabNet", credential)
|
||||
|
||||
assert len(frame) == FRAME_LENGTH
|
||||
assert frame[0] == 6
|
||||
assert frame[1:7] == b"LabNet"
|
||||
assert frame[7:33] == bytes(26)
|
||||
assert frame[33] == 13
|
||||
assert frame[34:47] == b"correct horse"
|
||||
assert frame[34:47] == b"x" * 13
|
||||
assert frame[47:98] == bytes(51)
|
||||
assert frame[98] == 0
|
||||
|
||||
|
||||
def test_build_wifi_provisioning_frame_uses_utf8_byte_lengths() -> None:
|
||||
frame = build_wifi_provisioning_frame("Сеть", "пароль")
|
||||
ssid = "Ж" * 4
|
||||
credential = "я" * 6
|
||||
frame = build_wifi_provisioning_frame(ssid, credential)
|
||||
|
||||
assert frame[0] == len("Сеть".encode())
|
||||
assert frame[33] == len("пароль".encode())
|
||||
assert frame[0] == len(ssid.encode())
|
||||
assert frame[33] == len(credential.encode())
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("ssid", "password", "message"),
|
||||
[
|
||||
("", "password", "SSID must not be empty"),
|
||||
("", "x" * 8, "SSID must not be empty"),
|
||||
("network", "", "password must not be empty"),
|
||||
("x" * 33, "password", "at most 32 UTF-8 bytes"),
|
||||
("x" * 33, "y" * 8, "at most 32 UTF-8 bytes"),
|
||||
("network", "x" * 65, "at most 64 UTF-8 bytes"),
|
||||
],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user