From a5a69bdf71f2f22d1a5f302eb82541fa56c0fccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Fri, 17 Jan 2020 22:54:28 +0100 Subject: [PATCH] Adds icon endpoint to NO_AUTH (#30910) * Adds icon endpoint to NO_AUTH * Add test for no_auth icon get * Blackout --- homeassistant/components/hassio/http.py | 4 +++- tests/components/hassio/test_http.py | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/hassio/http.py b/homeassistant/components/hassio/http.py index ddb9269219b..be2cec5ae9c 100644 --- a/homeassistant/components/hassio/http.py +++ b/homeassistant/components/hassio/http.py @@ -31,7 +31,9 @@ NO_TIMEOUT = re.compile( r")$" ) -NO_AUTH = re.compile(r"^(?:" r"|app/.*" r"|addons/[^/]+/logo" r")$") +NO_AUTH = re.compile( + r"^(?:" r"|app/.*" r"|addons/[^/]+/logo" r"|addons/[^/]+/icon" r")$" +) class HassIOView(HomeAssistantView): diff --git a/tests/components/hassio/test_http.py b/tests/components/hassio/test_http.py index 52cb3232ca6..5789dde64c1 100644 --- a/tests/components/hassio/test_http.py +++ b/tests/components/hassio/test_http.py @@ -60,7 +60,7 @@ async def test_forward_request_no_auth_for_panel( async def test_forward_request_no_auth_for_logo(hassio_client, aioclient_mock): - """Test no auth needed for .""" + """Test no auth needed for logo.""" aioclient_mock.get("http://127.0.0.1/addons/bl_b392/logo", text="response") resp = await hassio_client.get("/api/hassio/addons/bl_b392/logo") @@ -74,6 +74,21 @@ async def test_forward_request_no_auth_for_logo(hassio_client, aioclient_mock): assert len(aioclient_mock.mock_calls) == 1 +async def test_forward_request_no_auth_for_icon(hassio_client, aioclient_mock): + """Test no auth needed for icon.""" + aioclient_mock.get("http://127.0.0.1/addons/bl_b392/icon", text="response") + + resp = await hassio_client.get("/api/hassio/addons/bl_b392/icon") + + # Check we got right response + assert resp.status == 200 + body = await resp.text() + assert body == "response" + + # Check we forwarded command + assert len(aioclient_mock.mock_calls) == 1 + + async def test_forward_log_request(hassio_client, aioclient_mock): """Test fetching normal log path doesn't remove ANSI color escape codes.""" aioclient_mock.get("http://127.0.0.1/beer/logs", text="\033[32mresponse\033[0m")