Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/ssdp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class _SsdpServiceDescription:

ssdp_usn: str
ssdp_st: str
ssdp_location: str
ssdp_location: str | None = None
ssdp_nt: str | None = None
ssdp_udn: str | None = None
ssdp_ext: str | None = None
Expand Down
112 changes: 66 additions & 46 deletions tests/components/axis/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import respx

from homeassistant import data_entry_flow
from homeassistant.components import dhcp, zeroconf
from homeassistant.components import dhcp, ssdp, zeroconf
from homeassistant.components.axis import config_flow
from homeassistant.components.axis.const import (
CONF_EVENTS,
Expand Down Expand Up @@ -263,32 +263,36 @@ async def test_reauth_flow_update_configuration(hass):
),
(
SOURCE_SSDP,
{
"st": "urn:axis-com:service:BasicService:1",
"usn": f"uuid:Upnp-BasicDevice-1_0-{MAC}::urn:axis-com:service:BasicService:1",
"ext": "",
"server": "Linux/4.14.173-axis8, UPnP/1.0, Portable SDK for UPnP devices/1.8.7",
"deviceType": "urn:schemas-upnp-org:device:Basic:1",
"friendlyName": f"AXIS M1065-LW - {MAC}",
"manufacturer": "AXIS",
"manufacturerURL": "http://www.axis.com/",
"modelDescription": "AXIS M1065-LW Network Camera",
"modelName": "AXIS M1065-LW",
"modelNumber": "M1065-LW",
"modelURL": "http://www.axis.com/",
"serialNumber": MAC,
"UDN": f"uuid:Upnp-BasicDevice-1_0-{MAC}",
"serviceList": {
"service": {
"serviceType": "urn:axis-com:service:BasicService:1",
"serviceId": "urn:axis-com:serviceId:BasicServiceId",
"controlURL": "/upnp/control/BasicServiceId",
"eventSubURL": "/upnp/event/BasicServiceId",
"SCPDURL": "/scpd_basic.xml",
}
ssdp.SsdpServiceInfo(
ssdp_usn="mock_usn",
ssdp_st="mock_st",
upnp={
"st": "urn:axis-com:service:BasicService:1",
"usn": f"uuid:Upnp-BasicDevice-1_0-{MAC}::urn:axis-com:service:BasicService:1",
"ext": "",
"server": "Linux/4.14.173-axis8, UPnP/1.0, Portable SDK for UPnP devices/1.8.7",
"deviceType": "urn:schemas-upnp-org:device:Basic:1",
"friendlyName": f"AXIS M1065-LW - {MAC}",
"manufacturer": "AXIS",
"manufacturerURL": "http://www.axis.com/",
"modelDescription": "AXIS M1065-LW Network Camera",
"modelName": "AXIS M1065-LW",
"modelNumber": "M1065-LW",
"modelURL": "http://www.axis.com/",
"serialNumber": MAC,
"UDN": f"uuid:Upnp-BasicDevice-1_0-{MAC}",
"serviceList": {
"service": {
"serviceType": "urn:axis-com:service:BasicService:1",
"serviceId": "urn:axis-com:serviceId:BasicServiceId",
"controlURL": "/upnp/control/BasicServiceId",
"eventSubURL": "/upnp/event/BasicServiceId",
"SCPDURL": "/scpd_basic.xml",
}
},
"presentationURL": f"http://{DEFAULT_HOST}:80/",
},
"presentationURL": f"http://{DEFAULT_HOST}:80/",
},
),
),
(
SOURCE_ZEROCONF,
Expand Down Expand Up @@ -354,11 +358,15 @@ async def test_discovery_flow(hass, source: str, discovery_info: dict):
),
(
SOURCE_SSDP,
{
"friendlyName": f"AXIS M1065-LW - {MAC}",
"serialNumber": MAC,
"presentationURL": f"http://{DEFAULT_HOST}:80/",
},
ssdp.SsdpServiceInfo(
ssdp_usn="mock_usn",
ssdp_st="mock_st",
upnp={
"friendlyName": f"AXIS M1065-LW - {MAC}",
"serialNumber": MAC,
"presentationURL": f"http://{DEFAULT_HOST}:80/",
},
),
),
(
SOURCE_ZEROCONF,
Expand Down Expand Up @@ -403,11 +411,15 @@ async def test_discovered_device_already_configured(
),
(
SOURCE_SSDP,
{
"friendlyName": f"AXIS M1065-LW - {MAC}",
"serialNumber": MAC,
"presentationURL": "http://2.3.4.5:8080/",
},
ssdp.SsdpServiceInfo(
ssdp_usn="mock_usn",
ssdp_st="mock_st",
upnp={
"friendlyName": f"AXIS M1065-LW - {MAC}",
"serialNumber": MAC,
"presentationURL": "http://2.3.4.5:8080/",
},
),
8080,
),
(
Expand Down Expand Up @@ -474,11 +486,15 @@ async def test_discovery_flow_updated_configuration(
),
(
SOURCE_SSDP,
{
"friendlyName": "",
"serialNumber": "01234567890",
"presentationURL": "",
},
ssdp.SsdpServiceInfo(
ssdp_usn="mock_usn",
ssdp_st="mock_st",
upnp={
"friendlyName": "",
"serialNumber": "01234567890",
"presentationURL": "",
},
),
),
(
SOURCE_ZEROCONF,
Expand Down Expand Up @@ -518,11 +534,15 @@ async def test_discovery_flow_ignore_non_axis_device(
),
(
SOURCE_SSDP,
{
"friendlyName": f"AXIS M1065-LW - {MAC}",
"serialNumber": MAC,
"presentationURL": "http://169.254.3.4:80/",
},
ssdp.SsdpServiceInfo(
ssdp_usn="mock_usn",
ssdp_st="mock_st",
upnp={
"friendlyName": f"AXIS M1065-LW - {MAC}",
"serialNumber": MAC,
"presentationURL": "http://169.254.3.4:80/",
},
),
),
(
SOURCE_ZEROCONF,
Expand Down
16 changes: 10 additions & 6 deletions tests/components/nanoleaf/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pytest

from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.components import ssdp, zeroconf
from homeassistant.components.nanoleaf.const import DOMAIN
from homeassistant.const import CONF_HOST, CONF_TOKEN
from homeassistant.core import HomeAssistant
Expand Down Expand Up @@ -462,11 +462,15 @@ async def test_ssdp_discovery(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_SSDP},
data={
"_host": TEST_HOST,
"nl-devicename": TEST_NAME,
"nl-deviceid": TEST_DEVICE_ID,
},
data=ssdp.SsdpServiceInfo(
ssdp_usn="mock_usn",
ssdp_st="mock_st",
upnp={
"_host": TEST_HOST,
"nl-devicename": TEST_NAME,
"nl-deviceid": TEST_DEVICE_ID,
},
),
)

assert result["type"] == "form"
Expand Down
30 changes: 19 additions & 11 deletions tests/components/octoprint/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pyoctoprintapi import ApiError, DiscoverySettings

from homeassistant import config_entries, data_entry_flow
from homeassistant.components import zeroconf
from homeassistant.components import ssdp, zeroconf
from homeassistant.components.octoprint.const import DOMAIN
from homeassistant.core import HomeAssistant

Expand Down Expand Up @@ -235,11 +235,15 @@ async def test_show_ssdp_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_SSDP},
data={
"presentationURL": "http://192.168.1.123:80/discovery/device.xml",
"port": 80,
"UDN": "uuid:83747482",
},
data=ssdp.SsdpServiceInfo(
ssdp_usn="mock_usn",
ssdp_st="mock_st",
upnp={
"presentationURL": "http://192.168.1.123:80/discovery/device.xml",
"port": 80,
"UDN": "uuid:83747482",
},
),
)
assert result["type"] == "form"
assert not result["errors"]
Expand Down Expand Up @@ -512,11 +516,15 @@ async def test_duplicate_ssdp_ignored(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_SSDP},
data={
"presentationURL": "http://192.168.1.123:80/discovery/device.xml",
"port": 80,
"UDN": "uuid:83747482",
},
data=ssdp.SsdpServiceInfo(
ssdp_usn="mock_usn",
ssdp_st="mock_st",
upnp={
"presentationURL": "http://192.168.1.123:80/discovery/device.xml",
"port": 80,
"UDN": "uuid:83747482",
},
),
)
assert result["type"] == "abort"
assert result["reason"] == "already_configured"
14 changes: 10 additions & 4 deletions tests/components/yeelight/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest

from homeassistant import config_entries
from homeassistant.components import dhcp, zeroconf
from homeassistant.components import dhcp, ssdp, zeroconf
from homeassistant.components.yeelight.config_flow import MODEL_UNKNOWN, CannotConnect
from homeassistant.components.yeelight.const import (
CONF_DETECTED_MODEL,
Expand Down Expand Up @@ -52,6 +52,12 @@
CONF_NIGHTLIGHT_SWITCH: DEFAULT_NIGHTLIGHT_SWITCH,
}

SSDP_INFO = ssdp.SsdpServiceInfo(
ssdp_usn="mock_usn",
ssdp_st="mock_st",
upnp=CAPABILITIES,
)


async def test_discovery(hass: HomeAssistant):
"""Test setting up discovery."""
Expand Down Expand Up @@ -627,7 +633,7 @@ async def test_discovered_ssdp(hass):
f"{MODULE_CONFIG_FLOW}.AsyncBulb", return_value=mocked_bulb
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=CAPABILITIES
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=SSDP_INFO
)
await hass.async_block_till_done()

Expand Down Expand Up @@ -656,7 +662,7 @@ async def test_discovered_ssdp(hass):
f"{MODULE_CONFIG_FLOW}.AsyncBulb", return_value=mocked_bulb
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=CAPABILITIES
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=SSDP_INFO
)
await hass.async_block_till_done()

Expand Down Expand Up @@ -719,7 +725,7 @@ async def test_discovered_zeroconf(hass):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_SSDP},
data=CAPABILITIES,
data=SSDP_INFO,
)
await hass.async_block_till_done()

Expand Down