Improve X-Forwarded-* request headers handling (#38696)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: Franck Nijhof <git@frenck.dev> Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
This commit is contained in:
19 files changed
+703
-195
No files matched your search
@@ -1,10 +1,6 @@
|
||||
"""Tests for the HTTP component."""
|
||||
from ipaddress import ip_address
|
||||
|
||||
from aiohttp import web
|
||||
|
||||
from homeassistant.components.http.const import KEY_REAL_IP
|
||||
|
||||
# Relic from the past. Kept here so we can run negative tests.
|
||||
HTTP_HEADER_HA_AUTH = "X-HA-access"
|
||||
|
||||
@@ -25,7 +21,7 @@ def mock_real_ip(app):
|
||||
"""Mock Real IP middleware."""
|
||||
nonlocal ip_to_mock
|
||||
|
||||
request[KEY_REAL_IP] = ip_address(ip_to_mock)
|
||||
request = request.clone(remote=ip_to_mock)
|
||||
|
||||
return await handler(request)
|
||||
|
||||
|
||||
Reference in new issue
Block a user