mirror of
https://github.com/home-assistant/core
synced 2024-10-04 07:58:43 +02:00
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:
parent
b3b9fb0a7c
commit
cdaba62d2c
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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."""
|
||||
|
Loading…
Reference in New Issue
Block a user