Block options flow for default hostname in dnsip (#148221)

This commit is contained in:
G Johansson
2025-07-05 21:36:15 +02:00
committed by GitHub
parent eb0f11a859
commit 160e4e4d05
3 changed files with 39 additions and 1 deletions
@@ -16,6 +16,7 @@ from homeassistant.components.dnsip.const import (
CONF_PORT_IPV6,
CONF_RESOLVER,
CONF_RESOLVER_IPV6,
DEFAULT_HOSTNAME,
DOMAIN,
)
from homeassistant.config_entries import ConfigEntryState
@@ -379,3 +380,36 @@ async def test_options_error(hass: HomeAssistant, p_input: dict[str, str]) -> No
assert result2["errors"] == {"resolver": "invalid_resolver"}
if p_input[CONF_IPV6]:
assert result2["errors"] == {"resolver_ipv6": "invalid_resolver"}
async def test_cannot_configure_options_for_myip(hass: HomeAssistant) -> None:
"""Test options config flow aborts for default myip hostname."""
entry = MockConfigEntry(
domain=DOMAIN,
unique_id="12345",
data={
CONF_HOSTNAME: DEFAULT_HOSTNAME,
CONF_NAME: "myip",
CONF_IPV4: True,
CONF_IPV6: False,
},
options={
CONF_RESOLVER: "208.67.222.222",
CONF_RESOLVER_IPV6: "2620:119:53::5",
CONF_PORT: 53,
CONF_PORT_IPV6: 53,
},
)
entry.add_to_hass(hass)
with patch(
"homeassistant.components.dnsip.config_flow.aiodns.DNSResolver",
return_value=RetrieveDNS(),
):
assert await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_options"