Fix authorization header in cors (#21662)

* Fix authorization headers in cors

* Use aiohttp authorization header instead of custom const
This commit is contained in:
Paul Bottein authored and Paulus Schoutsen committed 2019-03-09 10:00:10 -08:00
1 parent fc81826763
commit 4d9cf15c45
2 files changed
+15 -3

No files matched your search

+13 -1
View File
@@ -7,11 +7,14 @@ from aiohttp.hdrs import (
ACCESS_CONTROL_ALLOW_HEADERS,
ACCESS_CONTROL_REQUEST_HEADERS,
ACCESS_CONTROL_REQUEST_METHOD,
AUTHORIZATION,
ORIGIN
)
import pytest
from homeassistant.const import HTTP_HEADER_HA_AUTH
from homeassistant.const import (
HTTP_HEADER_HA_AUTH
)
from homeassistant.setup import async_setup_component
from homeassistant.components.http.cors import setup_cors
from homeassistant.components.http.view import HomeAssistantView
@@ -84,6 +87,15 @@ async def test_cors_requests(client):
assert req.headers[ACCESS_CONTROL_ALLOW_ORIGIN] == \
TRUSTED_ORIGIN
# With auth token in headers
req = await client.get('/', headers={
AUTHORIZATION: 'Bearer some-token',
ORIGIN: TRUSTED_ORIGIN
})
assert req.status == 200
assert req.headers[ACCESS_CONTROL_ALLOW_ORIGIN] == \
TRUSTED_ORIGIN
async def test_cors_preflight_allowed(client):
"""Test cross origin resource sharing preflight (OPTIONS) request."""