Allow core to mark addons as system managed (#5145)

* Allow core to mark addons as system managed

* System managed options only settable by Home Assistant
This commit is contained in:
Mike Degatano
2024-08-13 09:14:42 -04:00
committed by GitHub
parent 5d6738ced8
commit eb3986bea2
8 changed files with 159 additions and 7 deletions

View File

@@ -1,4 +1,5 @@
"""Test API security layer."""
import asyncio
from http import HTTPStatus
from unittest.mock import patch
@@ -180,6 +181,8 @@ async def test_bad_requests(
("post", "/addons/abc123/restart", {"admin", "manager"}),
("post", "/addons/abc123/security", {"admin"}),
("post", "/os/datadisk/wipe", {"admin"}),
("post", "/addons/self/sys_options", set()),
("post", "/addons/abc123/sys_options", set()),
],
)
async def test_token_validation(
@@ -205,3 +208,12 @@ async def test_token_validation(
request_path, headers={"Authorization": "Bearer abc123"}
)
assert resp.status == 403
async def test_home_assistant_paths(api_token_validation: TestClient, coresys: CoreSys):
"""Test Home Assistant only paths."""
coresys.homeassistant.supervisor_token = "abc123"
resp = await api_token_validation.post(
"/addons/local_test/sys_options", headers={"Authorization": "Bearer abc123"}
)
assert resp.status == 200