Add user group (#21832)
* Add user group * Rename system group to plural
This commit is contained in:
1 parent
14b05b0a91
commit
5b2c6648fb
5 files changed
+63
-6
No files matched your search
@@ -14,6 +14,17 @@ def test_admin_policy():
|
||||
assert perms.check_entity('light.kitchen', 'edit')
|
||||
|
||||
|
||||
def test_user_policy():
|
||||
"""Test user policy works."""
|
||||
# Make sure it's valid
|
||||
POLICY_SCHEMA(system_policies.USER_POLICY)
|
||||
|
||||
perms = PolicyPermissions(system_policies.USER_POLICY, None)
|
||||
assert perms.check_entity('light.kitchen', 'read')
|
||||
assert perms.check_entity('light.kitchen', 'control')
|
||||
assert perms.check_entity('light.kitchen', 'edit')
|
||||
|
||||
|
||||
def test_read_only_policy():
|
||||
"""Test read only policy works."""
|
||||
# Make sure it's valid
|
||||
|
||||
@@ -64,7 +64,7 @@ async def test_loading_no_group_data_format(hass, hass_storage):
|
||||
|
||||
store = auth_store.AuthStore(hass)
|
||||
groups = await store.async_get_groups()
|
||||
assert len(groups) == 2
|
||||
assert len(groups) == 3
|
||||
admin_group = groups[0]
|
||||
assert admin_group.name == auth_store.GROUP_NAME_ADMIN
|
||||
assert admin_group.system_generated
|
||||
@@ -73,6 +73,10 @@ async def test_loading_no_group_data_format(hass, hass_storage):
|
||||
assert read_group.name == auth_store.GROUP_NAME_READ_ONLY
|
||||
assert read_group.system_generated
|
||||
assert read_group.id == auth_store.GROUP_ID_READ_ONLY
|
||||
user_group = groups[2]
|
||||
assert user_group.name == auth_store.GROUP_NAME_USER
|
||||
assert user_group.system_generated
|
||||
assert user_group.id == auth_store.GROUP_ID_USER
|
||||
|
||||
users = await store.async_get_users()
|
||||
assert len(users) == 2
|
||||
@@ -157,7 +161,7 @@ async def test_loading_all_access_group_data_format(hass, hass_storage):
|
||||
|
||||
store = auth_store.AuthStore(hass)
|
||||
groups = await store.async_get_groups()
|
||||
assert len(groups) == 2
|
||||
assert len(groups) == 3
|
||||
admin_group = groups[0]
|
||||
assert admin_group.name == auth_store.GROUP_NAME_ADMIN
|
||||
assert admin_group.system_generated
|
||||
@@ -166,6 +170,10 @@ async def test_loading_all_access_group_data_format(hass, hass_storage):
|
||||
assert read_group.name == auth_store.GROUP_NAME_READ_ONLY
|
||||
assert read_group.system_generated
|
||||
assert read_group.id == auth_store.GROUP_ID_READ_ONLY
|
||||
user_group = groups[2]
|
||||
assert user_group.name == auth_store.GROUP_NAME_USER
|
||||
assert user_group.system_generated
|
||||
assert user_group.id == auth_store.GROUP_ID_USER
|
||||
|
||||
users = await store.async_get_users()
|
||||
assert len(users) == 2
|
||||
@@ -189,12 +197,16 @@ async def test_loading_empty_data(hass, hass_storage):
|
||||
"""Test we correctly load with no existing data."""
|
||||
store = auth_store.AuthStore(hass)
|
||||
groups = await store.async_get_groups()
|
||||
assert len(groups) == 2
|
||||
assert len(groups) == 3
|
||||
admin_group = groups[0]
|
||||
assert admin_group.name == auth_store.GROUP_NAME_ADMIN
|
||||
assert admin_group.system_generated
|
||||
assert admin_group.id == auth_store.GROUP_ID_ADMIN
|
||||
read_group = groups[1]
|
||||
user_group = groups[1]
|
||||
assert user_group.name == auth_store.GROUP_NAME_USER
|
||||
assert user_group.system_generated
|
||||
assert user_group.id == auth_store.GROUP_ID_USER
|
||||
read_group = groups[2]
|
||||
assert read_group.name == auth_store.GROUP_NAME_READ_ONLY
|
||||
assert read_group.system_generated
|
||||
assert read_group.id == auth_store.GROUP_ID_READ_ONLY
|
||||
@@ -217,6 +229,10 @@ async def test_system_groups_store_id_and_name(hass, hass_storage):
|
||||
'id': auth_store.GROUP_ID_ADMIN,
|
||||
'name': auth_store.GROUP_NAME_ADMIN,
|
||||
},
|
||||
{
|
||||
'id': auth_store.GROUP_ID_USER,
|
||||
'name': auth_store.GROUP_NAME_USER,
|
||||
},
|
||||
{
|
||||
'id': auth_store.GROUP_ID_READ_ONLY,
|
||||
'name': auth_store.GROUP_NAME_READ_ONLY,
|
||||
|
||||
Reference in new issue
Block a user