1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Verify cloud user exists during boot (#25119)

This commit is contained in:
Paulus Schoutsen
2019-07-13 00:33:31 -07:00
committed by Pascal Vizeli
parent 59f6fd7630
commit 8ec75cf883
2 changed files with 37 additions and 1 deletions

View File

@@ -127,6 +127,36 @@ async def test_setup_existing_cloud_user(hass, hass_storage):
assert hass_storage[STORAGE_KEY]['data']['cloud_user'] == user.id
async def test_setup_invalid_cloud_user(hass, hass_storage):
"""Test setup with API push default data."""
hass_storage[STORAGE_KEY] = {
'version': 1,
'data': {
'cloud_user': 'non-existing'
}
}
with patch('hass_nabucasa.Cloud.start', return_value=mock_coro()):
result = await async_setup_component(hass, 'cloud', {
'http': {},
'cloud': {
cloud.CONF_MODE: cloud.MODE_DEV,
'cognito_client_id': 'test-cognito_client_id',
'user_pool_id': 'test-user_pool_id',
'region': 'test-region',
'relayer': 'test-relayer',
}
})
assert result
assert hass_storage[STORAGE_KEY]['data']['cloud_user'] != 'non-existing'
cloud_user = await hass.auth.async_get_user(
hass_storage[STORAGE_KEY]['data']['cloud_user']
)
assert cloud_user
assert cloud_user.groups[0].id == GROUP_ID_ADMIN
async def test_setup_setup_cloud_user(hass, hass_storage):
"""Test setup with API push default data."""
hass_storage[STORAGE_KEY] = {