Hass.io auth/sso part2 (#17324)

* Update discovery.py

* Create const.py

* Update auth.py

* Update const.py

* Update const.py

* Update http.py

* Update handler.py

* Update auth.py

* Update auth.py

* Update test_auth.py
This commit is contained in:
Pascal Vizeli 2018-10-11 10:55:38 +02:00 committed by Paulus Schoutsen
parent cffb704311
commit f5d3aa1826
6 changed files with 54 additions and 17 deletions

View file

@ -19,7 +19,8 @@ async def test_login_success(hass, hassio_client):
'/api/hassio_auth',
json={
"username": "test",
"password": "123456"
"password": "123456",
"addon": "samba",
},
headers={
HTTP_HEADER_HA_AUTH: API_PASSWORD
@ -42,7 +43,8 @@ async def test_login_error(hass, hassio_client):
'/api/hassio_auth',
json={
"username": "test",
"password": "123456"
"password": "123456",
"addon": "samba",
},
headers={
HTTP_HEADER_HA_AUTH: API_PASSWORD
@ -83,7 +85,8 @@ async def test_login_no_username(hass, hassio_client):
resp = await hassio_client.post(
'/api/hassio_auth',
json={
"password": "123456"
"password": "123456",
"addon": "samba",
},
headers={
HTTP_HEADER_HA_AUTH: API_PASSWORD
@ -93,3 +96,28 @@ async def test_login_no_username(hass, hassio_client):
# Check we got right response
assert resp.status == 400
assert not mock_login.called
async def test_login_success_extra(hass, hassio_client):
"""Test auth with extra data."""
await register_auth_provider(hass, {'type': 'homeassistant'})
with patch('homeassistant.auth.providers.homeassistant.'
'HassAuthProvider.async_validate_login',
Mock(return_value=mock_coro())) as mock_login:
resp = await hassio_client.post(
'/api/hassio_auth',
json={
"username": "test",
"password": "123456",
"addon": "samba",
"path": "/share",
},
headers={
HTTP_HEADER_HA_AUTH: API_PASSWORD
}
)
# Check we got right response
assert resp.status == 200
mock_login.assert_called_with("test", "123456")