User management (#15420)
* User management * Lint * Fix dict * Reuse data instance * OrderedDict all the way
This commit is contained in:
1 parent
84858f5c19
commit
70fe463ef0
21 files changed
+982
-116
No files matched your search
@@ -2,6 +2,7 @@
|
||||
import pytest
|
||||
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.components import websocket_api
|
||||
|
||||
from tests.common import MockUser, CLIENT_ID
|
||||
|
||||
@@ -9,13 +10,27 @@ from tests.common import MockUser, CLIENT_ID
|
||||
@pytest.fixture
|
||||
def hass_ws_client(aiohttp_client):
|
||||
"""Websocket client fixture connected to websocket server."""
|
||||
async def create_client(hass):
|
||||
async def create_client(hass, access_token=None):
|
||||
"""Create a websocket client."""
|
||||
wapi = hass.components.websocket_api
|
||||
assert await async_setup_component(hass, 'websocket_api')
|
||||
|
||||
client = await aiohttp_client(hass.http.app)
|
||||
websocket = await client.ws_connect(wapi.URL)
|
||||
auth_resp = await websocket.receive_json()
|
||||
|
||||
if auth_resp['type'] == wapi.TYPE_AUTH_OK:
|
||||
assert access_token is None, \
|
||||
'Access token given but no auth required'
|
||||
return websocket
|
||||
|
||||
assert access_token is not None, 'Access token required for fixture'
|
||||
|
||||
await websocket.send_json({
|
||||
'type': websocket_api.TYPE_AUTH,
|
||||
'access_token': access_token.token
|
||||
})
|
||||
|
||||
auth_ok = await websocket.receive_json()
|
||||
assert auth_ok['type'] == wapi.TYPE_AUTH_OK
|
||||
|
||||
|
||||
Reference in new issue
Block a user