Android TV Remote: Abort zeroconf if mac address is missing (#94026)
Abort zeroconf if mac address is missingpull/94033/head
parent
efb92ca9ee
commit
53e456f453
|
@ -135,7 +135,8 @@ class AndroidTVRemoteConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
self.host = discovery_info.host
|
||||
self.name = discovery_info.name.removesuffix("._androidtvremote2._tcp.local.")
|
||||
self.mac = discovery_info.properties.get("bt")
|
||||
assert self.mac
|
||||
if not self.mac:
|
||||
return self.async_abort(reason="cannot_connect")
|
||||
await self.async_set_unique_id(format_mac(self.mac))
|
||||
self._abort_if_unique_id_configured(
|
||||
updates={CONF_HOST: self.host, CONF_NAME: self.name}
|
||||
|
|
|
@ -712,6 +712,30 @@ async def test_zeroconf_flow_already_configured_host_not_changed_no_reload_entry
|
|||
assert len(mock_setup_entry.mock_calls) == 0
|
||||
|
||||
|
||||
async def test_zeroconf_flow_abort_if_mac_is_missing(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test when mac is missing in the zeroconf discovery we abort."""
|
||||
host = "1.2.3.4"
|
||||
name = "My Android TV"
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host=host,
|
||||
addresses=[host],
|
||||
port=6466,
|
||||
hostname=host,
|
||||
type="mock_type",
|
||||
name=name + "._androidtvremote2._tcp.local.",
|
||||
properties={},
|
||||
),
|
||||
)
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
async def test_reauth_flow_success(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
|
|
Loading…
Reference in New Issue