1
0
mirror of https://github.com/home-assistant/core.git synced 2026-02-26 04:46:08 +00:00

Fix AWS S3 config flow endpoint URL validation (#164085)

Co-authored-by: mik-laj <12058428+mik-laj@users.noreply.github.com>
This commit is contained in:
Kamil Breguła
2026-02-25 18:17:04 +01:00
committed by GitHub
parent 2fccbd6e47
commit 09765fe53d
2 changed files with 11 additions and 5 deletions

View File

@@ -60,9 +60,8 @@ class S3ConfigFlow(ConfigFlow, domain=DOMAIN):
}
)
if not urlparse(user_input[CONF_ENDPOINT_URL]).hostname.endswith(
AWS_DOMAIN
):
hostname = urlparse(user_input[CONF_ENDPOINT_URL]).hostname
if not hostname or not hostname.endswith(AWS_DOMAIN):
errors[CONF_ENDPOINT_URL] = "invalid_endpoint_url"
else:
try:

View File

@@ -122,12 +122,19 @@ async def test_abort_if_already_configured(
assert result["reason"] == "already_configured"
@pytest.mark.parametrize(
("endpoint_url"),
[
("@@@"),
("http://example.com"),
],
)
async def test_flow_create_not_aws_endpoint(
hass: HomeAssistant,
hass: HomeAssistant, endpoint_url: str
) -> None:
"""Test config flow with a not aws endpoint should raise an error."""
result = await _async_start_flow(
hass, USER_INPUT | {CONF_ENDPOINT_URL: "http://example.com"}
hass, USER_INPUT | {CONF_ENDPOINT_URL: endpoint_url}
)
assert result["type"] is FlowResultType.FORM