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:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user