diff --git a/tests/components/home_connect/test_config_flow.py b/tests/components/home_connect/test_config_flow.py index 2852dc4fb57..1f4120115ea 100644 --- a/tests/components/home_connect/test_config_flow.py +++ b/tests/components/home_connect/test_config_flow.py @@ -15,7 +15,7 @@ CLIENT_SECRET = "5678" 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( @@ -48,7 +48,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" diff --git a/tests/components/home_plus_control/test_config_flow.py b/tests/components/home_plus_control/test_config_flow.py index 4a7dbd3d3ee..5eb4115f031 100644 --- a/tests/components/home_plus_control/test_config_flow.py +++ b/tests/components/home_plus_control/test_config_flow.py @@ -20,7 +20,7 @@ from tests.components.home_plus_control.conftest import ( 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( @@ -54,7 +54,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" @@ -138,7 +138,7 @@ async def test_abort_if_entry_exists(hass, current_request_with_host): async def test_abort_if_invalid_token( - hass, aiohttp_client, aioclient_mock, current_request_with_host + hass, hass_client_no_auth, aioclient_mock, current_request_with_host ): """Check flow abort when the token has an invalid value.""" assert await setup.async_setup_component( @@ -172,7 +172,7 @@ async def test_abort_if_invalid_token( 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" diff --git a/tests/components/http/test_init.py b/tests/components/http/test_init.py index 65f01118c71..446b6c218bb 100644 --- a/tests/components/http/test_init.py +++ b/tests/components/http/test_init.py @@ -64,10 +64,10 @@ async def test_registering_view_while_running( hass.http.register_view(TestView) -async def test_not_log_password(hass, aiohttp_client, caplog, legacy_auth): +async def test_not_log_password(hass, hass_client_no_auth, caplog, legacy_auth): """Test access with password doesn't get logged.""" assert await async_setup_component(hass, "api", {"http": {}}) - client = await aiohttp_client(hass.http.app) + client = await hass_client_no_auth() logging.getLogger("aiohttp.access").setLevel(logging.INFO) resp = await client.get("/api/", params={"api_password": "test-password"}) diff --git a/tests/components/ifttt/test_init.py b/tests/components/ifttt/test_init.py index 077fb6d7470..1ca8395e11f 100644 --- a/tests/components/ifttt/test_init.py +++ b/tests/components/ifttt/test_init.py @@ -5,7 +5,7 @@ from homeassistant.config import async_process_ha_core_config from homeassistant.core import callback -async def test_config_flow_registers_webhook(hass, aiohttp_client): +async def test_config_flow_registers_webhook(hass, hass_client_no_auth): """Test setting up IFTTT and sending webhook.""" await async_process_ha_core_config( hass, @@ -30,7 +30,7 @@ async def test_config_flow_registers_webhook(hass, aiohttp_client): hass.bus.async_listen(ifttt.EVENT_RECEIVED, handle_event) - client = await aiohttp_client(hass.http.app) + client = await hass_client_no_auth() await client.post(f"/api/webhook/{webhook_id}", json={"hello": "ifttt"}) assert len(ifttt_events) == 1 diff --git a/tests/components/neato/test_config_flow.py b/tests/components/neato/test_config_flow.py index 3f07e4c4b0a..48bdf247f51 100644 --- a/tests/components/neato/test_config_flow.py +++ b/tests/components/neato/test_config_flow.py @@ -19,7 +19,7 @@ OAUTH2_TOKEN = VENDOR.token_endpoint 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( @@ -50,7 +50,7 @@ async def test_full_flow( "&scope=public_profile+control_robots+maps" ) - 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" @@ -91,7 +91,7 @@ async def test_abort_if_already_setup(hass: HomeAssistant): async def test_reauth( - hass: HomeAssistant, aiohttp_client, aioclient_mock, current_request_with_host + hass: HomeAssistant, hass_client_no_auth, aioclient_mock, current_request_with_host ): """Test initialization of the reauth flow.""" assert await setup.async_setup_component( @@ -127,7 +127,7 @@ async def test_reauth( }, ) - 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 diff --git a/tests/components/netatmo/test_config_flow.py b/tests/components/netatmo/test_config_flow.py index 6bd8086c820..8f18ae1410a 100644 --- a/tests/components/netatmo/test_config_flow.py +++ b/tests/components/netatmo/test_config_flow.py @@ -44,7 +44,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( @@ -89,7 +89,7 @@ async def test_full_flow( f"&state={state}&scope={scope}" ) - 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" diff --git a/tests/components/onboarding/test_views.py b/tests/components/onboarding/test_views.py index 75fcb9c0746..66f68ad8b33 100644 --- a/tests/components/onboarding/test_views.py +++ b/tests/components/onboarding/test_views.py @@ -91,14 +91,14 @@ async def mock_supervisor_fixture(hass, aioclient_mock): yield -async def test_onboarding_progress(hass, hass_storage, aiohttp_client): +async def test_onboarding_progress(hass, hass_storage, hass_client_no_auth): """Test fetching progress.""" mock_storage(hass_storage, {"done": ["hello"]}) assert await async_setup_component(hass, "onboarding", {}) await hass.async_block_till_done() - client = await aiohttp_client(hass.http.app) + client = await hass_client_no_auth() with patch.object(views, "STEPS", ["hello", "world"]): resp = await client.get("/api/onboarding") @@ -110,7 +110,7 @@ async def test_onboarding_progress(hass, hass_storage, aiohttp_client): assert data[1] == {"step": "world", "done": False} -async def test_onboarding_user_already_done(hass, hass_storage, aiohttp_client): +async def test_onboarding_user_already_done(hass, hass_storage, hass_client_no_auth): """Test creating a new user when user step already done.""" mock_storage(hass_storage, {"done": [views.STEP_USER]}) @@ -118,7 +118,7 @@ async def test_onboarding_user_already_done(hass, hass_storage, aiohttp_client): assert await async_setup_component(hass, "onboarding", {}) await hass.async_block_till_done() - client = await aiohttp_client(hass.http.app) + client = await hass_client_no_auth() resp = await client.post( "/api/onboarding/users", @@ -134,13 +134,13 @@ async def test_onboarding_user_already_done(hass, hass_storage, aiohttp_client): assert resp.status == HTTP_FORBIDDEN -async def test_onboarding_user(hass, hass_storage, aiohttp_client): +async def test_onboarding_user(hass, hass_storage, hass_client_no_auth): """Test creating a new user.""" assert await async_setup_component(hass, "person", {}) assert await async_setup_component(hass, "onboarding", {}) await hass.async_block_till_done() - client = await aiohttp_client(hass.http.app) + client = await hass_client_no_auth() resp = await client.post( "/api/onboarding/users", @@ -194,14 +194,14 @@ async def test_onboarding_user(hass, hass_storage, aiohttp_client): ] -async def test_onboarding_user_invalid_name(hass, hass_storage, aiohttp_client): +async def test_onboarding_user_invalid_name(hass, hass_storage, hass_client_no_auth): """Test not providing name.""" mock_storage(hass_storage, {"done": []}) assert await async_setup_component(hass, "onboarding", {}) await hass.async_block_till_done() - client = await aiohttp_client(hass.http.app) + client = await hass_client_no_auth() resp = await client.post( "/api/onboarding/users", @@ -216,14 +216,14 @@ async def test_onboarding_user_invalid_name(hass, hass_storage, aiohttp_client): assert resp.status == 400 -async def test_onboarding_user_race(hass, hass_storage, aiohttp_client): +async def test_onboarding_user_race(hass, hass_storage, hass_client_no_auth): """Test race condition on creating new user.""" mock_storage(hass_storage, {"done": ["hello"]}) assert await async_setup_component(hass, "onboarding", {}) await hass.async_block_till_done() - client = await aiohttp_client(hass.http.app) + client = await hass_client_no_auth() resp1 = client.post( "/api/onboarding/users", @@ -340,14 +340,16 @@ async def test_onboarding_integration_invalid_redirect_uri( assert len(user.refresh_tokens) == 1, user -async def test_onboarding_integration_requires_auth(hass, hass_storage, aiohttp_client): +async def test_onboarding_integration_requires_auth( + hass, hass_storage, hass_client_no_auth +): """Test finishing integration step.""" mock_storage(hass_storage, {"done": [const.STEP_USER]}) assert await async_setup_component(hass, "onboarding", {}) await hass.async_block_till_done() - client = await aiohttp_client(hass.http.app) + client = await hass_client_no_auth() resp = await client.post( "/api/onboarding/integration", json={"client_id": CLIENT_ID} diff --git a/tests/components/ondilo_ico/test_config_flow.py b/tests/components/ondilo_ico/test_config_flow.py index 69d69e06b7c..e1edfc2a63c 100644 --- a/tests/components/ondilo_ico/test_config_flow.py +++ b/tests/components/ondilo_ico/test_config_flow.py @@ -30,7 +30,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( @@ -60,7 +60,7 @@ async def test_full_flow( "&scope=api" ) - 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" diff --git a/tests/components/owntracks/test_init.py b/tests/components/owntracks/test_init.py index 0946358548e..856d3ece298 100644 --- a/tests/components/owntracks/test_init.py +++ b/tests/components/owntracks/test_init.py @@ -39,7 +39,7 @@ def mock_dev_track(mock_device_tracker_conf): @pytest.fixture -def mock_client(hass, aiohttp_client): +def mock_client(hass, hass_client_no_auth): """Start the Home Assistant HTTP component.""" mock_component(hass, "group") mock_component(hass, "zone") @@ -50,7 +50,7 @@ def mock_client(hass, aiohttp_client): ).add_to_hass(hass) hass.loop.run_until_complete(async_setup_component(hass, "owntracks", {})) - return hass.loop.run_until_complete(aiohttp_client(hass.http.app)) + return hass.loop.run_until_complete(hass_client_no_auth()) async def test_handle_valid_message(mock_client): diff --git a/tests/components/plex/test_config_flow.py b/tests/components/plex/test_config_flow.py index 45904588a10..9f9e4e1cdfb 100644 --- a/tests/components/plex/test_config_flow.py +++ b/tests/components/plex/test_config_flow.py @@ -509,7 +509,7 @@ async def test_external_timed_out(hass, current_request_with_host): assert result["reason"] == "token_request_timeout" -async def test_callback_view(hass, aiohttp_client, current_request_with_host): +async def test_callback_view(hass, hass_client_no_auth, current_request_with_host): """Test callback view.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER} @@ -525,7 +525,7 @@ async def test_callback_view(hass, aiohttp_client, current_request_with_host): ) assert result["type"] == "external" - client = await aiohttp_client(hass.http.app) + client = await hass_client_no_auth() forward_url = f'{config_flow.AUTH_CALLBACK_PATH}?flow_id={result["flow_id"]}' resp = await client.get(forward_url) diff --git a/tests/components/push/test_camera.py b/tests/components/push/test_camera.py index 644db2b9dd5..d4759350341 100644 --- a/tests/components/push/test_camera.py +++ b/tests/components/push/test_camera.py @@ -9,7 +9,7 @@ from homeassistant.util import dt as dt_util from tests.common import async_fire_time_changed -async def test_bad_posting(hass, aiohttp_client): +async def test_bad_posting(hass, hass_client_no_auth): """Test that posting to wrong api endpoint fails.""" await async_process_ha_core_config( hass, @@ -30,7 +30,7 @@ async def test_bad_posting(hass, aiohttp_client): await hass.async_block_till_done() assert hass.states.get("camera.config_test") is not None - client = await aiohttp_client(hass.http.app) + client = await hass_client_no_auth() # missing file async with client.post("/api/webhook/camera.config_test") as resp: @@ -40,7 +40,7 @@ async def test_bad_posting(hass, aiohttp_client): assert camera_state.state == "idle" # no file supplied we are still idle -async def test_posting_url(hass, aiohttp_client): +async def test_posting_url(hass, hass_client_no_auth): """Test that posting to api endpoint works.""" await async_process_ha_core_config( hass, @@ -60,7 +60,7 @@ async def test_posting_url(hass, aiohttp_client): ) await hass.async_block_till_done() - client = await aiohttp_client(hass.http.app) + client = await hass_client_no_auth() files = {"image": io.BytesIO(b"fake")} # initial state