Add Hass.io user headers to supervisor proxy
This commit is contained in:
1 parent
3f65a03024
commit
fd21d6cc9d
5 files changed
+46
-6
No files matched your search
@@ -40,9 +40,9 @@ def test_forward_request(hassio_client):
|
||||
'build_type', [
|
||||
'supervisor/info', 'homeassistant/update', 'host/info'
|
||||
])
|
||||
def test_auth_required_forward_request(hassio_client, build_type):
|
||||
def test_auth_required_forward_request(hassio_noauth_client, build_type):
|
||||
"""Test auth required for normal request."""
|
||||
resp = yield from hassio_client.post("/api/hassio/{}".format(build_type))
|
||||
resp = yield from hassio_noauth_client.post("/api/hassio/{}".format(build_type))
|
||||
|
||||
# Check we got right response
|
||||
assert resp.status == 401
|
||||
@@ -135,3 +135,20 @@ def test_bad_gateway_when_cannot_find_supervisor(hassio_client):
|
||||
HTTP_HEADER_HA_AUTH: API_PASSWORD
|
||||
})
|
||||
assert resp.status == 502
|
||||
|
||||
|
||||
async def test_forwarding_user_info(hassio_client, hass_admin_user,
|
||||
aioclient_mock):
|
||||
"""Test that we forward user info correctly."""
|
||||
aioclient_mock.get('http://127.0.0.1/hello')
|
||||
|
||||
resp = await hassio_client.get('/api/hassio/hello')
|
||||
|
||||
# Check we got right response
|
||||
assert resp.status == 200
|
||||
|
||||
assert len(aioclient_mock.mock_calls) == 1
|
||||
|
||||
req_headers = aioclient_mock.mock_calls[0][-1]
|
||||
req_headers['X-HASS-USER-ID'] == hass_admin_user.id
|
||||
req_headers['X-HASS-IS-ADMIN'] == '1'
|
||||
Reference in new issue
Block a user