diff --git a/supervisor/api/network.py b/supervisor/api/network.py index 1a5c934a9..bf93f6ee8 100644 --- a/supervisor/api/network.py +++ b/supervisor/api/network.py @@ -84,7 +84,7 @@ def ipconfig_struct(config: IpConfig) -> dict: ATTR_METHOD: config.method, ATTR_ADDRESS: [address.with_prefixlen for address in config.address], ATTR_NAMESERVERS: [str(address) for address in config.nameservers], - ATTR_GATEWAY: str(config.gateway), + ATTR_GATEWAY: str(config.gateway) if config.gateway else None, } diff --git a/tests/api/test_network.py b/tests/api/test_network.py index 2839c36aa..b903d30c9 100644 --- a/tests/api/test_network.py +++ b/tests/api/test_network.py @@ -23,8 +23,11 @@ async def test_api_network_info(api_client, coresys): for interface in result["data"]["interfaces"]: if interface["interface"] == TEST_INTERFACE: assert interface["primary"] + assert interface["ipv4"]["gateway"] == "192.168.2.1" if interface["interface"] == TEST_INTERFACE_WLAN: assert not interface["primary"] + assert interface["ipv4"] is None + assert interface["ipv6"] is None assert result["data"]["docker"]["interface"] == DOCKER_NETWORK assert result["data"]["docker"]["address"] == str(DOCKER_NETWORK_MASK)