Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES/11293.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fixed flaky ``test_aiohttp_request_ctx_manager_not_found`` by switching the
unresolvable hostname to use the reserved ``.invalid`` TLD (RFC 2606), which is
guaranteed not to resolve, instead of relying on a real domain that could be
hijacked or unexpectedly resolved by some networks -- by :user:`copilot`.
8 changes: 6 additions & 2 deletions tests/test_client_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -3753,9 +3753,13 @@ async def handler(request: web.Request) -> NoReturn:


async def test_aiohttp_request_ctx_manager_not_found() -> None:
# Use the reserved ``.invalid`` TLD (RFC 2606) so DNS resolution is
# guaranteed to fail, instead of relying on a real domain name which
# may unexpectedly resolve on some networks (e.g. ISP NXDOMAIN
# hijacking) and make this test flaky. See #11293.
with pytest.raises(aiohttp.ClientConnectionError):
async with aiohttp.request("GET", "http://wrong-dns-name.com"):
assert False
async with aiohttp.request("GET", "http://wrong-dns-name.invalid"):
assert False, "never executed"


async def test_raising_client_connector_dns_error_on_dns_failure() -> None:
Expand Down
Loading