Use IndieAuth for client ID (#15369)

* Use IndieAuth for client ID

* Lint

* Lint & Fix tests

* Allow local IP addresses

* Update comment
This commit is contained in:
Paulus Schoutsen 2018-07-09 18:24:46 +02:00 committed by GitHub
parent f7d7d825b0
commit 0d4841cbea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 329 additions and 347 deletions

View file

@ -1,22 +1,26 @@
"""Integration tests for the auth component."""
from . import async_setup_auth, CLIENT_AUTH, CLIENT_REDIRECT_URI
from . import async_setup_auth
from tests.common import CLIENT_ID, CLIENT_REDIRECT_URI
async def test_login_new_user_and_refresh_token(hass, aiohttp_client):
"""Test logging in with new user and refreshing tokens."""
client = await async_setup_auth(hass, aiohttp_client, setup_api=True)
resp = await client.post('/auth/login_flow', json={
'client_id': CLIENT_ID,
'handler': ['insecure_example', None],
'redirect_uri': CLIENT_REDIRECT_URI,
}, auth=CLIENT_AUTH)
})
assert resp.status == 200
step = await resp.json()
resp = await client.post(
'/auth/login_flow/{}'.format(step['flow_id']), json={
'client_id': CLIENT_ID,
'username': 'test-user',
'password': 'test-pass',
}, auth=CLIENT_AUTH)
})
assert resp.status == 200
step = await resp.json()
@ -24,9 +28,10 @@ async def test_login_new_user_and_refresh_token(hass, aiohttp_client):
# Exchange code for tokens
resp = await client.post('/auth/token', data={
'client_id': CLIENT_ID,
'grant_type': 'authorization_code',
'code': code
}, auth=CLIENT_AUTH)
})
assert resp.status == 200
tokens = await resp.json()
@ -35,9 +40,10 @@ async def test_login_new_user_and_refresh_token(hass, aiohttp_client):
# Use refresh token to get more tokens.
resp = await client.post('/auth/token', data={
'client_id': CLIENT_ID,
'grant_type': 'refresh_token',
'refresh_token': tokens['refresh_token']
}, auth=CLIENT_AUTH)
})
assert resp.status == 200
tokens = await resp.json()