mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 02:49:40 +00:00
Frontend indicate require admin (#22272)
* Allow panels to indicate they are meant for admins * Panels to indicate when they require admin access * Do not return admin-only panels to non-admin users * Fix flake8
This commit is contained in:
@@ -8,6 +8,7 @@ import pytest
|
||||
from homeassistant.auth.const import GROUP_ID_ADMIN
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.components.hassio import STORAGE_KEY
|
||||
from homeassistant.components import frontend
|
||||
|
||||
from tests.common import mock_coro
|
||||
|
||||
@@ -44,6 +45,28 @@ def test_setup_api_ping(hass, aioclient_mock):
|
||||
assert hass.components.hassio.is_hassio()
|
||||
|
||||
|
||||
async def test_setup_api_panel(hass, aioclient_mock):
|
||||
"""Test setup with API ping."""
|
||||
assert await async_setup_component(hass, 'frontend', {})
|
||||
with patch.dict(os.environ, MOCK_ENVIRON):
|
||||
result = await async_setup_component(hass, 'hassio', {})
|
||||
assert result
|
||||
|
||||
panels = hass.data[frontend.DATA_PANELS]
|
||||
|
||||
assert panels.get('hassio').to_response() == {
|
||||
'component_name': 'custom',
|
||||
'icon': 'hass:home-assistant',
|
||||
'title': 'Hass.io',
|
||||
'url_path': 'hassio',
|
||||
'require_admin': True,
|
||||
'config': {'_panel_custom': {'embed_iframe': True,
|
||||
'js_url': '/api/hassio/app/entrypoint.js',
|
||||
'name': 'hassio-main',
|
||||
'trust_external': False}},
|
||||
}
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_setup_api_push_api_data(hass, aioclient_mock):
|
||||
"""Test setup with API push."""
|
||||
|
||||
Reference in New Issue
Block a user