Move http server code into it's own module (#176968)

This commit is contained in:
Robert Resch
2026-07-21 17:23:25 +02:00
committed by GitHub
parent ff9db47e0e
commit fe092acee4
7 changed files with 579 additions and 539 deletions
+1 -1
View File
@@ -111,7 +111,7 @@ def trusted_networks_auth(
async def test_auth_middleware_loaded_by_default(hass: HomeAssistant) -> None:
"""Test accessing to server from banned IP when feature is off."""
with patch("homeassistant.components.http.async_setup_auth") as mock_setup:
with patch("homeassistant.components.http.server.async_setup_auth") as mock_setup:
await async_setup_component(hass, DOMAIN, {"http": {}})
assert len(mock_setup.mock_calls) == 1
+2 -2
View File
@@ -310,7 +310,7 @@ async def test_access_from_supervisor_ip(
async def test_ban_middleware_not_loaded_by_config(hass: HomeAssistant) -> None:
"""Test accessing to server from banned IP when feature is off."""
with patch("homeassistant.components.http.setup_bans") as mock_setup:
with patch("homeassistant.components.http.server.setup_bans") as mock_setup:
await async_setup_component(
hass, DOMAIN, {"http": {http.CONF_IP_BAN_ENABLED: False}}
)
@@ -320,7 +320,7 @@ async def test_ban_middleware_not_loaded_by_config(hass: HomeAssistant) -> None:
async def test_ban_middleware_loaded_by_default(hass: HomeAssistant) -> None:
"""Test accessing to server from banned IP when feature is off."""
with patch("homeassistant.components.http.setup_bans") as mock_setup:
with patch("homeassistant.components.http.server.setup_bans") as mock_setup:
await async_setup_component(hass, DOMAIN, {"http": {}})
assert len(mock_setup.mock_calls) == 1
+2 -2
View File
@@ -31,7 +31,7 @@ TRUSTED_ORIGIN = "https://home-assistant.io"
async def test_cors_middleware_loaded_by_default(hass: HomeAssistant) -> None:
"""Test accessing to server from banned IP when feature is off."""
with patch("homeassistant.components.http.setup_cors") as mock_setup:
with patch("homeassistant.components.http.server.setup_cors") as mock_setup:
await async_setup_component(hass, DOMAIN, {"http": {}})
assert len(mock_setup.mock_calls) == 1
@@ -39,7 +39,7 @@ async def test_cors_middleware_loaded_by_default(hass: HomeAssistant) -> None:
async def test_cors_middleware_loaded_from_config(hass: HomeAssistant) -> None:
"""Test accessing to server from banned IP when feature is off."""
with patch("homeassistant.components.http.setup_cors") as mock_setup:
with patch("homeassistant.components.http.server.setup_cors") as mock_setup:
await async_setup_component(
hass,
DOMAIN,
+6 -4
View File
@@ -492,7 +492,7 @@ async def test_emergency_ssl_certificate_when_invalid_get_url_fails(
hass.config.recovery_mode = True
with patch(
"homeassistant.components.http.get_url", side_effect=NoURLAvailableError
"homeassistant.components.http.server.get_url", side_effect=NoURLAvailableError
) as mock_get_url:
assert await async_setup_component(hass, DOMAIN, {}) is True
await hass.async_start()
@@ -525,7 +525,8 @@ async def test_invalid_ssl_and_cannot_create_emergency_cert(
hass.config.recovery_mode = True
with patch(
"homeassistant.components.http.x509.CertificateBuilder", side_effect=OSError
"homeassistant.components.http.server.x509.CertificateBuilder",
side_effect=OSError,
) as mock_builder:
assert await async_setup_component(hass, DOMAIN, {}) is True
await hass.async_start()
@@ -566,7 +567,8 @@ async def test_invalid_ssl_and_cannot_create_emergency_cert_with_ssl_peer_cert(
hass.config.recovery_mode = True
with patch(
"homeassistant.components.http.x509.CertificateBuilder", side_effect=OSError
"homeassistant.components.http.server.x509.CertificateBuilder",
side_effect=OSError,
) as mock_builder:
assert await async_setup_component(hass, DOMAIN, {}) is False
await hass.async_start()
@@ -639,7 +641,7 @@ async def test_create_server_passes_configuration(hass: HomeAssistant) -> None:
async def test_cors_defaults(hass: HomeAssistant) -> None:
"""Test the CORS default settings."""
with patch("homeassistant.components.http.setup_cors") as mock_setup:
with patch("homeassistant.components.http.server.setup_cors") as mock_setup:
assert await async_setup_component(hass, DOMAIN, {})
assert len(mock_setup.mock_calls) == 1