mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Detect ingress host used when adding a Mealie integration (#130418)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
parent
ccbbcbb264
commit
132a8cc31b
@ -38,6 +38,10 @@ class MealieConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
) -> tuple[dict[str, str], str | None]:
|
||||
"""Check connection to the Mealie API."""
|
||||
assert self.host is not None
|
||||
|
||||
if "/hassio/ingress/" in self.host:
|
||||
return {"base": "ingress_url"}, None
|
||||
|
||||
client = MealieClient(
|
||||
self.host,
|
||||
token=api_token,
|
||||
|
@ -8,7 +8,7 @@
|
||||
"verify_ssl": "[%key:common::config_flow::data::verify_ssl%]"
|
||||
},
|
||||
"data_description": {
|
||||
"host": "The URL of your Mealie instance."
|
||||
"host": "The URL of your Mealie instance, for example, http://192.168.1.123:1234"
|
||||
}
|
||||
},
|
||||
"reauth_confirm": {
|
||||
@ -29,6 +29,7 @@
|
||||
"error": {
|
||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
|
||||
"ingress_url": "Ingress URLs are only used for accessing the Mealie UI. Use your Home Assistant IP address and the network port within the configuration tab of the Mealie add-on.",
|
||||
"unknown": "[%key:common::config_flow::error::unknown%]",
|
||||
"mealie_version": "Minimum required version is v1.0.0. Please upgrade Mealie and then retry."
|
||||
},
|
||||
|
@ -85,6 +85,40 @@ async def test_flow_errors(
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_ingress_host(
|
||||
hass: HomeAssistant,
|
||||
mock_mealie_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
"""Test disallow ingress host."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_USER},
|
||||
)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{
|
||||
CONF_HOST: "http://homeassistant/hassio/ingress/db21ed7f_mealie",
|
||||
CONF_API_TOKEN: "token",
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "ingress_url"}
|
||||
|
||||
mock_mealie_client.get_user_info.side_effect = None
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{CONF_HOST: "http://homeassistant:9001", CONF_API_TOKEN: "token"},
|
||||
)
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("version"),
|
||||
[
|
||||
|
Loading…
x
Reference in New Issue
Block a user