mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Remove check if base url is local (#19494)
This commit is contained in:
parent
264d18bc83
commit
ec28ee3c42
@ -1,10 +1,7 @@
|
|||||||
"""Helpers for data entry flows for config entries."""
|
"""Helpers for data entry flows for config entries."""
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from ipaddress import ip_address
|
|
||||||
from urllib.parse import urlparse
|
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.util.network import is_local
|
|
||||||
|
|
||||||
|
|
||||||
def register_discovery_flow(domain, title, discovery_function,
|
def register_discovery_flow(domain, title, discovery_function,
|
||||||
@ -115,15 +112,6 @@ class WebhookFlowHandler(config_entries.ConfigFlow):
|
|||||||
if not self._allow_multiple and self._async_current_entries():
|
if not self._allow_multiple and self._async_current_entries():
|
||||||
return self.async_abort(reason='one_instance_allowed')
|
return self.async_abort(reason='one_instance_allowed')
|
||||||
|
|
||||||
try:
|
|
||||||
url_parts = urlparse(self.hass.config.api.base_url)
|
|
||||||
|
|
||||||
if is_local(ip_address(url_parts.hostname)):
|
|
||||||
return self.async_abort(reason='not_internet_accessible')
|
|
||||||
except ValueError:
|
|
||||||
# If it's not an IP address, it's very likely publicly accessible
|
|
||||||
pass
|
|
||||||
|
|
||||||
if user_input is None:
|
if user_input is None:
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id='user',
|
step_id='user',
|
||||||
|
@ -183,19 +183,6 @@ async def test_webhook_multiple_entries_allowed(hass, webhook_flow_conf):
|
|||||||
assert result['type'] == data_entry_flow.RESULT_TYPE_FORM
|
assert result['type'] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
|
||||||
|
|
||||||
async def test_webhook_config_flow_aborts_external_url(hass,
|
|
||||||
webhook_flow_conf):
|
|
||||||
"""Test configuring a webhook without an external url."""
|
|
||||||
flow = config_entries.HANDLERS['test_single']()
|
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
hass.config.api = Mock(base_url='http://192.168.1.10')
|
|
||||||
result = await flow.async_step_user()
|
|
||||||
|
|
||||||
assert result['type'] == data_entry_flow.RESULT_TYPE_ABORT
|
|
||||||
assert result['reason'] == 'not_internet_accessible'
|
|
||||||
|
|
||||||
|
|
||||||
async def test_webhook_config_flow_registers_webhook(hass, webhook_flow_conf):
|
async def test_webhook_config_flow_registers_webhook(hass, webhook_flow_conf):
|
||||||
"""Test setting up an entry creates a webhook."""
|
"""Test setting up an entry creates a webhook."""
|
||||||
flow = config_entries.HANDLERS['test_single']()
|
flow = config_entries.HANDLERS['test_single']()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user