mirror of
https://github.com/home-assistant/core
synced 2024-10-07 10:13:38 +02:00
Make auth backwards compat again (#18792)
* Made auth not backwards compat * Fix tests
This commit is contained in:
parent
38ecf71307
commit
28215d7edd
@ -462,10 +462,11 @@ class AuthStore:
|
|||||||
for group in self._groups.values():
|
for group in self._groups.values():
|
||||||
g_dict = {
|
g_dict = {
|
||||||
'id': group.id,
|
'id': group.id,
|
||||||
|
# Name not read for sys groups. Kept here for backwards compat
|
||||||
|
'name': group.name
|
||||||
} # type: Dict[str, Any]
|
} # type: Dict[str, Any]
|
||||||
|
|
||||||
if group.id not in (GROUP_ID_READ_ONLY, GROUP_ID_ADMIN):
|
if group.id not in (GROUP_ID_READ_ONLY, GROUP_ID_ADMIN):
|
||||||
g_dict['name'] = group.name
|
|
||||||
g_dict['policy'] = group.policy
|
g_dict['policy'] = group.policy
|
||||||
|
|
||||||
groups.append(g_dict)
|
groups.append(g_dict)
|
||||||
|
@ -199,13 +199,22 @@ async def test_loading_empty_data(hass, hass_storage):
|
|||||||
assert len(users) == 0
|
assert len(users) == 0
|
||||||
|
|
||||||
|
|
||||||
async def test_system_groups_only_store_id(hass, hass_storage):
|
async def test_system_groups_store_id_and_name(hass, hass_storage):
|
||||||
"""Test that for system groups we only store the ID."""
|
"""Test that for system groups we store the ID and name.
|
||||||
|
|
||||||
|
Name is stored so that we remain backwards compat with < 0.82.
|
||||||
|
"""
|
||||||
store = auth_store.AuthStore(hass)
|
store = auth_store.AuthStore(hass)
|
||||||
await store._async_load()
|
await store._async_load()
|
||||||
data = store._data_to_save()
|
data = store._data_to_save()
|
||||||
assert len(data['users']) == 0
|
assert len(data['users']) == 0
|
||||||
assert data['groups'] == [
|
assert data['groups'] == [
|
||||||
{'id': auth_store.GROUP_ID_ADMIN},
|
{
|
||||||
{'id': auth_store.GROUP_ID_READ_ONLY},
|
'id': auth_store.GROUP_ID_ADMIN,
|
||||||
|
'name': auth_store.GROUP_NAME_ADMIN,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': auth_store.GROUP_ID_READ_ONLY,
|
||||||
|
'name': auth_store.GROUP_NAME_READ_ONLY,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user