1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Protect our user agent (#51486)

* Protect our user agent

* Fix expected error
This commit is contained in:
Paulus Schoutsen
2021-06-04 09:14:18 -07:00
committed by GitHub
parent 5e067c2631
commit ede7932a57
2 changed files with 18 additions and 1 deletions

View File

@@ -195,3 +195,14 @@ async def test_async_aiohttp_proxy_stream_client_err(aioclient_mock, camera_clie
resp = await camera_client.get("/api/camera_proxy_stream/camera.config_test")
assert resp.status == 502
async def test_client_session_immutable_headers(hass):
"""Test we can't mutate headers."""
session = client.async_get_clientsession(hass)
with pytest.raises(TypeError):
session.headers["user-agent"] = "bla"
with pytest.raises(AttributeError):
session.headers.update({"user-agent": "bla"})