Backend tweaks to make authorization work (#14339)

* Backend tweaks to make authorization work

* Lint

* Add test

* Validate redirect uris

* Fix tests

* Fix tests

* Lint
This commit is contained in:
Paulus Schoutsen 2018-05-10 04:38:11 -04:00 committed by Pascal Vizeli
parent 0f3ec94fba
commit 5ec7fc7ddb
17 changed files with 176 additions and 58 deletions

View file

@ -3,6 +3,8 @@ import pytest
from homeassistant.setup import async_setup_component
from tests.common import MockUser
@pytest.fixture
def hass_ws_client(aiohttp_client):
@ -20,3 +22,17 @@ def hass_ws_client(aiohttp_client):
return websocket
return create_client
@pytest.fixture
def hass_access_token(hass):
"""Return an access token to access Home Assistant."""
user = MockUser().add_to_hass(hass)
client = hass.loop.run_until_complete(hass.auth.async_create_client(
'Access Token Fixture',
redirect_uris=['/'],
no_secret=True,
))
refresh_token = hass.loop.run_until_complete(
hass.auth.async_create_refresh_token(user, client.id))
yield hass.auth.async_create_access_token(refresh_token)