Adds icon endpoint to NO_AUTH (#30910)

* Adds icon endpoint to NO_AUTH

* Add test for no_auth icon get

* Blackout
pull/30924/head
Joakim Sørensen 2020-01-17 22:54:28 +01:00 committed by Paulus Schoutsen
parent 196bf2f3a0
commit a5a69bdf71
2 changed files with 19 additions and 2 deletions

View File

@ -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):

View File

@ -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")