fix(dal): decrypt the DAL's answer before reading it (#25)

A GET of the DAL answers sealed ({"content", "iv"}), like a PUT does.
_read_dal_or_page parsed the envelope as it came, so hosts, the ARP
table, port forwards and the Wi-Fi getters found nothing on every
gateway, and since nothing raised the HTML fallback never ran either.

Every DAL GET now goes through one helper that decrypts the answer,
checks for ZCFG_SUCCESS and returns its Object list; the status page
and the System page share the decryption. Hosts are read from
lanhosts and port forwards from nat, the names the gateway's web
interface uses: LAN_HOSTS and NAT_PORTMAP are answered like any
unknown name, with an empty Object. The new parsers live in
napalm_zyxel/parsers.py, under strict mypy.

Tests seal recorded, anonymised answers of a VMG4005-B50A
(V5.17(ABQA.3.1)C0) with a real ZyxelCrypto, so the driver decrypts
them. The Wi-Fi DAL names stay unverified: that gateway has no Wi-Fi.

Closes #25
This commit is contained in:
Christian Manivong committed 2026-11-12 19:03:40 +01:00
1 parent e05101f282
commit a47f9c3970
13 files changed
+675 -180

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
{
"result": "ZCFG_SUCCESS",
"ReplyMsg": "",
"ReplyMsgMultiLang": "",
"Object": []
}
@@ -0,0 +1,9 @@
{
"result": "ZCFG_SUCCESS",
"ModelName": "VMG4005-B50A",
"SoftwareVersion": "V5.17(ABQA.3.1)C0",
"CurrentLanguage": "de",
"AvailableLanguages": "en,cz,it,nl,pt,ru,tr,fr,de,es",
"RememberPassword": 0,
"FWUpgradeProgressST": 0
}
+167
View File
@@ -0,0 +1,167 @@
{
"result": "ZCFG_SUCCESS",
"ReplyMsg": "DeviceSource",
"ReplyMsgMultiLang": "",
"Object": [
{
"wanInfo": {
"wanStatus": 0,
"wanIfaceExist": 1,
"wanType": ""
},
"lanhosts": [
{
"Alias": "",
"PhysAddress": "02:00:00:00:00:02",
"IPAddress": "192.0.2.2",
"IPAddress6": "",
"IPLinkLocalAddress6": "N/A",
"AddressSource": "Static",
"DHCPClient": "",
"LeaseTimeRemaining": 0,
"AssociatedDevice": "",
"Layer1Interface": "Device.Ethernet.Interface.1",
"Layer3Interface": "Device.IP.Interface.1",
"VendorClassID": "",
"ClientID": "",
"UserClassID": "",
"HostName": "Unknown",
"Active": true,
"X_ZYXEL_DeleteLease": false,
"X_ZYXEL_ConnectionType": "Ethernet",
"X_ZYXEL_ConnectedAP": "",
"X_ZYXEL_HostType": "",
"X_ZYXEL_CapabilityType": "",
"X_ZYXEL_PhyRate": 1000,
"X_ZYXEL_WiFiStatus": false,
"X_ZYXEL_SignalStrength": 0,
"X_ZYXEL_SNR": 0,
"X_ZYXEL_RSSI": 0,
"X_ZYXEL_SoftwareVersion": "",
"X_ZYXEL_LastUpdate": 1769202204,
"X_ZYXEL_Address6Source": "",
"X_ZYXEL_DHCP6Client": "",
"X_ZYXEL_BytesSent": 0,
"X_ZYXEL_BytesReceived": 0,
"X_ZYXEL_OperatingStandard": "",
"X_ZYXEL_LastDataDownlinkRate": 0,
"X_ZYXEL_LastDataUplinkRate": 0,
"IPv4AddressNumberOfEntries": 0,
"IPv6AddressNumberOfEntries": 0,
"ClientDuid": "",
"ExpireTime": "",
"SupportedFrequencyBands": "",
"WiFiname": "",
"DeviceSource": "HOSTS_HOST",
"DeviceIcon": "",
"Internet_Blocking_Enable": false,
"DeviceName": "Unknown",
"curHostName": "",
"dhcp4PoolExist": true,
"dhcp4PoolIid": [
1,
0,
0,
0,
0,
0
],
"dhcp4StaticAddrExist": false,
"dhcp4StaticAddrIid": [
0,
0,
0,
0,
0,
0
],
"dhcp4StaticAddrEnable": false,
"dhcp4StaticAddr": "",
"dhcp4StaticAddrNum": 0,
"dhcp4StaticAddrUsedByOtherHost": false,
"icon": "ipc",
"staticIP": ""
},
{
"Alias": "",
"PhysAddress": "02:00:00:00:00:03",
"IPAddress": "192.0.2.3",
"IPAddress6": "",
"IPLinkLocalAddress6": "N/A",
"AddressSource": "Static",
"DHCPClient": "",
"LeaseTimeRemaining": 0,
"AssociatedDevice": "",
"Layer1Interface": "",
"Layer3Interface": "Device.IP.Interface.1",
"VendorClassID": "",
"ClientID": "",
"UserClassID": "",
"HostName": "Unknown",
"Active": true,
"X_ZYXEL_DeleteLease": false,
"X_ZYXEL_ConnectionType": "Ethernet",
"X_ZYXEL_ConnectedAP": "",
"X_ZYXEL_HostType": "",
"X_ZYXEL_CapabilityType": "",
"X_ZYXEL_PhyRate": 0,
"X_ZYXEL_WiFiStatus": false,
"X_ZYXEL_SignalStrength": 0,
"X_ZYXEL_SNR": 0,
"X_ZYXEL_RSSI": 0,
"X_ZYXEL_SoftwareVersion": "",
"X_ZYXEL_LastUpdate": 1769202204,
"X_ZYXEL_Address6Source": "",
"X_ZYXEL_DHCP6Client": "",
"X_ZYXEL_BytesSent": 0,
"X_ZYXEL_BytesReceived": 0,
"X_ZYXEL_OperatingStandard": "",
"X_ZYXEL_LastDataDownlinkRate": 0,
"X_ZYXEL_LastDataUplinkRate": 0,
"IPv4AddressNumberOfEntries": 0,
"IPv6AddressNumberOfEntries": 0,
"ClientDuid": "",
"ExpireTime": "",
"SupportedFrequencyBands": "",
"WiFiname": "",
"DeviceSource": "HOSTS_HOST",
"DeviceIcon": "",
"Internet_Blocking_Enable": false,
"DeviceName": "Unknown",
"curHostName": "",
"dhcp4PoolExist": true,
"dhcp4PoolIid": [
1,
0,
0,
0,
0,
0
],
"dhcp4StaticAddrExist": false,
"dhcp4StaticAddrIid": [
0,
0,
0,
0,
0,
0
],
"dhcp4StaticAddrEnable": false,
"dhcp4StaticAddr": "",
"dhcp4StaticAddrNum": 0,
"dhcp4StaticAddrUsedByOtherHost": false,
"icon": "ipc",
"staticIP": ""
}
],
"STBVendorID": {
"STBVendorID1": "",
"STBVendorID2": "",
"STBVendorID3": "",
"STBVendorID4": "",
"STBVendorID5": ""
}
}
]
}
+6
View File
@@ -0,0 +1,6 @@
{
"result": "ZCFG_SUCCESS",
"ReplyMsg": "InternalClient",
"ReplyMsgMultiLang": "",
"Object": []
}
+82
View File
@@ -0,0 +1,82 @@
"""A logged-in driver whose gateway answers GETs from recorded fixtures, sealed.
The fixtures in ``fixtures/`` are a VMG4005-B50A's (firmware V5.17(ABQA.3.1)C0)
answers, anonymised: addresses under 192.0.2.0/24, MAC addresses replaced by
placeholders, the serial number replaced, the provisioning key and PLOAM password
emptied. The gateway seals a DAL answer as ``{"content", "iv"}``; :func:`driver`
seals each fixture with a real :class:`ZyxelCrypto` and the driver's own key, so
what the driver reads has gone through the decryption.
"""
from __future__ import annotations
import json
from pathlib import Path
from typing import Any
from unittest.mock import MagicMock
import requests
from napalm_zyxel import ZyxelVMGDriver
from napalm_zyxel.zyxel_driver import ZyxelCrypto
FIXTURES = Path(__file__).parent / "fixtures"
FIRMWARE = "vmg4005-b50a-ABQA.3.1"
AES_KEY = bytes(range(32))
def fixture(name: str) -> Any:
"""The recorded answer *name* (``cardpage_status``, ``lanhosts``, ...)."""
return json.loads((FIXTURES / f"{FIRMWARE}-{name}.json").read_text())
def dal(oid: str) -> str:
"""The path a DAL GET of *oid* is sent to."""
return f"cgi-bin/DAL?oid={oid}"
def response(status: int, text: str = "") -> requests.Response:
resp = requests.Response()
resp.status_code = status
resp._content = text.encode()
resp.url = "http://192.0.2.1/"
return resp
def _crypto() -> ZyxelCrypto:
crypto = ZyxelCrypto()
crypto.aes_key = AES_KEY
return crypto
def sealed(answer: Any) -> requests.Response:
"""*answer* the way the gateway sends it: AES-encrypted, ``{"content", "iv"}``."""
envelope = _crypto().encrypt_json(answer)
return response(200, json.dumps({"content": envelope["content"], "iv": envelope["iv"]}))
def driver(answers: dict[str, Any]) -> ZyxelVMGDriver:
"""A logged-in driver whose gateway answers a GET of each path in *answers*:
a response as it is, anything else sealed. Any other path answers 404."""
drv = ZyxelVMGDriver("192.0.2.1", "admin", "password")
# NAPALM's __del__ asks is_alive(), which opens a TCP connection: not in a test.
drv.is_alive = lambda: {"is_alive": False} # type: ignore[method-assign]
def get(url: str, params: dict[str, Any] | None = None, **_: Any) -> requests.Response:
for path, answer in answers.items():
if url.endswith(f"/{path}"):
return answer if isinstance(answer, requests.Response) else sealed(answer)
return response(404)
session = MagicMock(spec=requests.Session)
session.get.side_effect = get
drv._session = session
drv._sessionkey = "1"
drv._crypto = _crypto()
drv._device_info = fixture("getBasicInformation")
return drv
def requested(drv: ZyxelVMGDriver) -> list[str]:
"""The URLs the driver sent a GET to, in order."""
return [call.args[0] for call in drv._session.get.call_args_list] # type: ignore[union-attr]
+1 -3
View File
@@ -1,8 +1,6 @@
{
"coverage_floor": 68.0,
"function_complexity": {
"napalm_zyxel/zyxel_driver.py::ZyxelVMGDriver._parse_wireless_clients_dal": 12
},
"function_complexity": {},
"function_lines": {},
"mypy_relaxed": [
"napalm_zyxel.zyxel_driver"
+229
View File
@@ -0,0 +1,229 @@
"""A DAL GET is read the way the gateway sends it: sealed, with its data under ``Object`` (#25).
``_read_dal_or_page`` parsed the answer to ``GET /cgi-bin/DAL?oid=...`` as it came,
but the gateway seals it (``{"content", "iv"}``) like the answer to a PUT. The
parsers found none of their keys in the envelope and reported no hosts, ARP
entries, port forwards, SSIDs, radios or Wi-Fi clients, and since nothing raised,
the HTML fallback never ran either.
Decrypted, the answer is ``{"result": "ZCFG_SUCCESS", "Object": [...]}``. The host
list is the one the gateway's own web interface reads, ``oid=lanhosts``: the
driver asked for ``LAN_HOSTS``, a name the gateway does not know and answers, like
any unknown name, with an empty ``Object``. Port forwards are ``oid=nat`` (the
driver asked for ``NAT_PORTMAP``).
"""
from __future__ import annotations
import copy
import json
from typing import Any
import pytest
import requests
from napalm.base.exceptions import ConnectionException
from tests.gateway import dal, driver, fixture, requested, response
LANHOSTS = fixture("lanhosts")
def _with_host(**changes: Any) -> dict[str, Any]:
"""The recorded host list, its first host changed by *changes*."""
answer = copy.deepcopy(LANHOSTS)
answer["Object"][0]["lanhosts"][0].update(changes)
return answer
#: A port forward as the gateway's web interface edits it (the rule object its NAT
#: page sends to ``oid=nat``). The recorded gateway is a bridge and has none, so the
#: values are placeholders; the field names are the gateway's.
RULE: dict[str, Any] = {
"Index": 1,
"Enable": True,
"Protocol": "TCP",
"Description": "web",
"Interface": "IP.Interface.3",
"ExternalPortStart": 8443,
"ExternalPortEnd": 8443,
"InternalPortStart": 443,
"InternalPortEnd": 443,
"InternalClient": "192.0.2.3",
"SetOriginatingIP": False,
"OriginatingIpAddress": "",
"OriginatingSubnetMask": "255.255.255.255",
"WANIP": "",
"X_ZYXEL_AutoDetectWanStatus": False,
}
def _nat(*rules: dict[str, Any]) -> dict[str, Any]:
return {**fixture("nat"), "Object": list(rules)}
# --- the sealed answer ------------------------------------------------------------------
def test_the_sealed_host_list_is_decrypted_and_read():
hosts = driver({dal("lanhosts"): LANHOSTS}).get_hosts()
assert [(h["mac"], h["ip"]) for h in hosts] == [
("02:00:00:00:00:02", "192.0.2.2"),
("02:00:00:00:00:03", "192.0.2.3"),
]
def test_the_host_list_is_the_one_the_web_interface_reads():
drv = driver({dal("lanhosts"): LANHOSTS})
drv.get_hosts()
assert requested(drv) == ["http://192.0.2.1:80/cgi-bin/DAL?oid=lanhosts"]
def test_an_unsealed_answer_is_read_as_it_is():
hosts = driver({dal("lanhosts"): response(200, json.dumps(LANHOSTS))}).get_hosts()
assert len(hosts) == 2
def test_an_answer_the_gateway_refused_falls_back_to_the_page():
refused = {"result": "ZCFG_NO_SUCH_OBJECT", "Object": []}
page = response(200, "192.0.2.4 02:00:00:00:00:04 tablet")
hosts = driver({dal("lanhosts"): refused, "dhcp.htm": page}).get_hosts()
assert [h["ip"] for h in hosts] == ["192.0.2.4"]
def test_an_answer_that_cannot_be_decrypted_falls_back_to_the_page():
garbled = response(
200, json.dumps({"content": "bm90IHNlYWxlZA==", "iv": "AAAAAAAAAAAAAAAAAAAAAA=="})
)
page = response(200, "192.0.2.4 02:00:00:00:00:04 tablet")
hosts = driver({dal("lanhosts"): garbled, "dhcp.htm": page}).get_hosts()
assert [h["ip"] for h in hosts] == ["192.0.2.4"]
def test_a_gateway_with_no_hosts_has_none():
empty = copy.deepcopy(LANHOSTS)
empty["Object"][0]["lanhosts"] = []
assert driver({dal("lanhosts"): empty}).get_hosts() == []
# --- the hosts --------------------------------------------------------------------------
def test_a_recorded_host_reads_as_it_is_on_the_gateway():
host = driver({dal("lanhosts"): LANHOSTS}).get_hosts()[0]
assert host == {
"mac": "02:00:00:00:00:02",
"ip": "192.0.2.2",
"hostname": "", # the gateway says "Unknown"
"interface_type": "LAN",
"is_active": True,
}
def test_a_host_name_the_gateway_knows_is_reported():
hosts = driver({dal("lanhosts"): _with_host(HostName="printer")}).get_hosts()
assert hosts[0]["hostname"] == "printer"
def test_a_wifi_host_is_on_the_wlan():
answer = _with_host(X_ZYXEL_ConnectionType="Wi-Fi 2.4GHz")
assert driver({dal("lanhosts"): answer}).get_hosts()[0]["interface_type"] == "WLAN"
def test_only_a_dhcp_host_has_a_lease():
answer = _with_host(AddressSource="DHCP", LeaseTimeRemaining=3600)
hosts = driver({dal("lanhosts"): answer}).get_hosts()
assert hosts[0]["lease_time_remaining"] == 3600
assert "lease_time_remaining" not in hosts[1] # AddressSource "Static"
def test_an_inactive_host_is_reported_inactive():
hosts = driver({dal("lanhosts"): _with_host(Active=False)}).get_hosts()
assert hosts[0]["is_active"] is False
def test_the_arp_table_holds_the_active_hosts():
drv = driver({dal("lanhosts"): _with_host(Active=False)})
assert drv.get_arp_table() == [
{"interface": "LAN", "mac": "02:00:00:00:00:03", "ip": "192.0.2.3", "age": -1.0}
]
# --- port forwards ----------------------------------------------------------------------
def test_the_recorded_bridge_has_no_port_forwards():
assert driver({dal("nat"): fixture("nat")}).get_port_forwards() == []
def test_a_port_forward_reads_as_the_gateway_lists_it():
forwards = driver({dal("nat"): _nat(RULE)}).get_port_forwards()
assert forwards == [
{
"name": "web",
"protocol": "TCP",
"external_port": 8443,
"internal_ip": "192.0.2.3",
"internal_port": 443,
"enabled": True,
}
]
def test_a_forward_for_tcp_and_udp_is_one_per_protocol():
forwards = driver({dal("nat"): _nat({**RULE, "Protocol": "ALL"})}).get_port_forwards()
assert [f["protocol"] for f in forwards] == ["TCP", "UDP"]
def test_a_disabled_forward_is_reported_disabled():
forwards = driver({dal("nat"): _nat({**RULE, "Enable": False})}).get_port_forwards()
assert forwards[0]["enabled"] is False
def test_a_forward_limited_to_one_source_names_it():
rule = {**RULE, "SetOriginatingIP": True, "OriginatingIpAddress": "198.51.100.7"}
forwards = driver({dal("nat"): _nat(rule)}).get_port_forwards()
assert forwards[0]["remote_host"] == "198.51.100.7"
def test_port_forwards_are_read_from_the_nat_oid():
drv = driver({dal("nat"): fixture("nat")})
drv.get_port_forwards()
assert requested(drv) == ["http://192.0.2.1:80/cgi-bin/DAL?oid=nat"]
# --- Wi-Fi ------------------------------------------------------------------------------
@pytest.mark.parametrize(
("getter", "oid", "empty"),
[
("get_wireless_clients", "WIFI_CLIENTS", []),
("get_ssids", "WIFI_SSIDS", {}),
("get_radio_status", "WIFI_RADIO", {}),
],
)
def test_a_sealed_wifi_answer_is_decrypted(getter, oid, empty):
"""The recorded gateway has no Wi-Fi: it answers these with an empty ``Object``."""
assert getattr(driver({dal(oid): fixture("LAN_HOSTS")}), getter)() == empty
def test_a_wifi_answer_without_object_falls_back_to_the_page():
answer = {"result": "ZCFG_SUCCESS"}
drv = driver({dal("WIFI_SSIDS"): answer, "wireless.htm": response(200, "")})
drv.get_ssids()
assert requested(drv)[-1].endswith("/wireless.htm")
def test_a_wifi_client_under_object_is_read():
"""Not recorded: the field names are the parser's, not yet checked against a gateway."""
client = {"MACAddress": "02:00:00:00:00:05", "SSID": "guest", "Signal": -61}
answer = {"result": "ZCFG_SUCCESS", "Object": [client]}
clients = driver({dal("WIFI_CLIENTS"): answer}).get_wireless_clients()
assert [(c["mac"], c["signal"]) for c in clients] == [("02:00:00:00:00:05", -61)]
def test_a_failed_request_still_raises():
drv = driver({dal("lanhosts"): requests.Response()})
drv._session.get.side_effect = requests.ConnectTimeout("timed out") # type: ignore[union-attr]
with pytest.raises(ConnectionException, match="timed out"):
drv.get_hosts()
+10 -8
View File
@@ -18,8 +18,9 @@ import requests
from napalm.base.exceptions import ConnectionException
from napalm_zyxel import ZyxelVMGDriver
from tests.gateway import fixture
HOSTS_DAL = {"hosts": [{"MACAddress": "AA:BB:CC:DD:EE:01", "IPAddress": "192.168.1.33"}]}
HOSTS_DAL = fixture("lanhosts") # tests/gateway.py
HOSTS_PAGE = "192.168.1.34 aa:bb:cc:dd:ee:02 tablet"
@@ -102,8 +103,8 @@ def test_a_reboot_that_fails_to_reach_the_gateway_raises():
@pytest.mark.parametrize(
("getter", "oid", "page"),
[
("get_hosts", "LAN_HOSTS", "dhcp.htm"),
("get_port_forwards", "NAT_PORTMAP", "Status.htm"),
("get_hosts", "lanhosts", "dhcp.htm"),
("get_port_forwards", "nat", "Status.htm"),
("get_wireless_clients", "WIFI_CLIENTS", "wireless.htm"),
("get_ssids", "WIFI_SSIDS", "wireless.htm"),
("get_radio_status", "WIFI_RADIO", "wireless.htm"),
@@ -118,25 +119,26 @@ def test_a_getter_raises_when_neither_the_dal_nor_the_page_can_be_read(getter, o
def test_get_arp_table_raises_when_the_hosts_cannot_be_read():
driver = _driver({"cgi-bin/DAL?oid=LAN_HOSTS": _response(500), "dhcp.htm": _response(500)})
driver = _driver({"cgi-bin/DAL?oid=lanhosts": _response(500), "dhcp.htm": _response(500)})
with pytest.raises(RuntimeError):
driver.get_arp_table()
def test_a_failed_dal_request_falls_back_to_the_page():
driver = _driver(
{"cgi-bin/DAL?oid=LAN_HOSTS": _response(500), "dhcp.htm": _response(200, HOSTS_PAGE)}
{"cgi-bin/DAL?oid=lanhosts": _response(500), "dhcp.htm": _response(200, HOSTS_PAGE)}
)
assert [h["ip"] for h in driver.get_hosts()] == ["192.168.1.34"]
def test_the_dal_answer_is_used_when_there_is_one():
driver = _driver({"cgi-bin/DAL?oid=LAN_HOSTS": _response(200, json.dumps(HOSTS_DAL))})
assert [h["ip"] for h in driver.get_hosts()] == ["192.168.1.33"]
driver = _driver({"cgi-bin/DAL?oid=lanhosts": _response(200, json.dumps(HOSTS_DAL))})
assert [h["ip"] for h in driver.get_hosts()] == ["192.0.2.2", "192.0.2.3"]
def test_a_gateway_that_lists_no_hosts_has_none():
driver = _driver({"cgi-bin/DAL?oid=LAN_HOSTS": _response(200, '{"hosts": []}')})
answer = {"result": "ZCFG_SUCCESS", "Object": [{"lanhosts": []}]}
driver = _driver({"cgi-bin/DAL?oid=lanhosts": _response(200, json.dumps(answer))})
assert driver.get_hosts() == []
+23 -66
View File
@@ -333,61 +333,20 @@ class TestZyxelVMGDriver:
with pytest.raises(ConnectionClosedException):
self.driver._dal_query("PINGTEST", {})
def test_parse_port_forwards_dal(self):
self._setup_mocked_http()
data = {
"NATPortMap": [
{
"Description": "Web Server",
"Protocol": "TCP",
"ExternalPort": 80,
"InternalIP": "192.168.1.10",
"InternalPort": 8080,
"Enabled": True,
}
]
}
result = self.driver._parse_port_forwards_dal(data)
assert len(result) == 1
assert result[0]["name"] == "Web Server"
assert result[0]["external_port"] == 80
assert result[0]["internal_ip"] == "192.168.1.10"
def test_parse_hosts_dal(self):
self._setup_mocked_http()
data = {
"LANHosts": [
{
"MACAddress": "aa:bb:cc:dd:ee:ff",
"IPAddress": "192.168.1.100",
"HostName": "laptop",
"InterfaceType": "lan",
"Active": True,
}
]
}
result = self.driver._parse_hosts_dal(data)
assert len(result) == 1
assert result[0]["mac"] == "aa:bb:cc:dd:ee:ff"
assert result[0]["ip"] == "192.168.1.100"
assert result[0]["hostname"] == "laptop"
def test_parse_wireless_clients_dal(self):
self._setup_mocked_http()
data = {
"assoc": [
{
"MACAddress": "11:22:33:44:55:66",
"SSID": "MyWiFi",
"Radio": "wlan0",
"Signal": -45,
"TxRate": 300.0,
"RxRate": 150.0,
"Uptime": 3600,
"IPAddress": "192.168.1.50",
}
]
}
data = [
{
"MACAddress": "11:22:33:44:55:66",
"SSID": "MyWiFi",
"Radio": "wlan0",
"Signal": -45,
"TxRate": 300.0,
"RxRate": 150.0,
"Uptime": 3600,
"IPAddress": "192.168.1.50",
}
]
result = self.driver._parse_wireless_clients_dal(data)
assert len(result) == 1
assert result[0]["mac"] == "11:22:33:44:55:66"
@@ -396,19 +355,17 @@ class TestZyxelVMGDriver:
def test_parse_ssids_dal(self):
self._setup_mocked_http()
data = {
"ssids": [
{
"SSID": "MyWiFi",
"Radio": "wlan0",
"BSSID": "00:1a:2b:3c:4d:5e",
"Encryption": "WPA2",
"Enabled": True,
"Hidden": False,
"Clients": 3,
}
]
}
data = [
{
"SSID": "MyWiFi",
"Radio": "wlan0",
"BSSID": "00:1a:2b:3c:4d:5e",
"Encryption": "WPA2",
"Enabled": True,
"Hidden": False,
"Clients": 3,
}
]
result = self.driver._parse_ssids_dal(data)
assert "MyWiFi" in result
assert result["MyWiFi"]["encryption"] == "WPA2"