Add test fixture for unauthenticated HTTP client (#55561)

* Add test fixture for unauthenticated HTTP client

* Remove things from the future
This commit is contained in:
Erik Montnemery 2021-09-02 13:09:16 +02:00 committed by GitHub
parent b3b9fb0a7c
commit cdaba62d2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 4 deletions

View File

@ -16,7 +16,7 @@ CLIENT_SECRET = "5678"
async def test_full_flow(
hass: HomeAssistant,
aiohttp_client,
hass_client_no_auth,
aioclient_mock,
current_request_with_host,
) -> None:
@ -47,7 +47,7 @@ async def test_full_flow(
f"&state={state}"
)
client = await aiohttp_client(hass.http.app)
client = await hass_client_no_auth()
resp = await client.get(f"/auth/external/callback?code=abcd&state={state}")
assert resp.status == 200
assert resp.headers["content-type"] == "text/html; charset=utf-8"

View File

@ -92,7 +92,7 @@ async def test_abort_if_existing_entry(hass):
async def test_full_flow(
hass, aiohttp_client, aioclient_mock, current_request_with_host
hass, hass_client_no_auth, aioclient_mock, current_request_with_host
):
"""Check full flow."""
assert await setup.async_setup_component(
@ -127,7 +127,7 @@ async def test_full_flow(
f"&state={state}&scope=profile+user-read+user-read-results+user-exec-command"
)
client = await aiohttp_client(hass.http.app)
client = await hass_client_no_auth()
resp = await client.get(f"/auth/external/callback?code=abcd&state={state}")
assert resp.status == 200
assert resp.headers["content-type"] == "text/html; charset=utf-8"

View File

@ -331,6 +331,17 @@ def hass_client(hass, aiohttp_client, hass_access_token):
return auth_client
@pytest.fixture
def hass_client_no_auth(hass, aiohttp_client):
"""Return an unauthenticated HTTP client."""
async def client():
"""Return an authenticated client."""
return await aiohttp_client(hass.http.app)
return client
@pytest.fixture
def current_request():
"""Mock current request."""