mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-28 11:36:32 +00:00
test invalid channel value
use the actual error message from NetworkManager
This commit is contained in:
parent
c3a18d559e
commit
cc03e50329
@ -276,6 +276,31 @@ async def test_api_network_interface_update_wifi_error(api_client: TestClient):
|
||||
)
|
||||
|
||||
|
||||
async def test_api_network_interface_update_wifi_bad_channel(api_client: TestClient):
|
||||
"""Test network interface WiFi API error handling for bad channel."""
|
||||
# Simulate frontend WiFi interface edit where the user selects a bad channel.
|
||||
resp = await api_client.post(
|
||||
f"/network/interface/{TEST_INTERFACE_WLAN_NAME}/update",
|
||||
json={
|
||||
"enabled": True,
|
||||
"ipv4": {
|
||||
"method": "shared",
|
||||
"address": ["10.42.0.1/24"],
|
||||
},
|
||||
"ipv6": {
|
||||
"method": "auto",
|
||||
},
|
||||
"wifi": {"mode": "ap", "ssid": "HotSpot", "band": "bg", "channel": 17},
|
||||
},
|
||||
)
|
||||
result = await resp.json()
|
||||
assert result["result"] == "error"
|
||||
assert (
|
||||
result["message"]
|
||||
== "Can't create config and activate wlan0: 802-11-wireless.channel: '17' is not a valid channel"
|
||||
)
|
||||
|
||||
|
||||
async def test_api_network_interface_update_remove(api_client: TestClient):
|
||||
"""Test network manager api."""
|
||||
resp = await api_client.post(
|
||||
|
@ -240,6 +240,15 @@ class NetworkManager(DBusServiceMock):
|
||||
"org.freedesktop.NetworkManager.Device.InvalidConnection",
|
||||
"A 'wireless' setting with a valid SSID is required if no AP path was given.",
|
||||
)
|
||||
if (
|
||||
"channel" in connection["802-11-wireless"]
|
||||
and connection["802-11-wireless"]["channel"].value > 14
|
||||
):
|
||||
raise DBusError(
|
||||
"org.freedesktop.NetworkManager.Device.InvalidConnection",
|
||||
# this is the actual error from NetworkManager
|
||||
f"802-11-wireless.channel: '{connection['802-11-wireless']['channel'].value}' is not a valid channel",
|
||||
)
|
||||
|
||||
return [
|
||||
"/org/freedesktop/NetworkManager/Settings/1",
|
||||
|
Loading…
x
Reference in New Issue
Block a user