fix desktop tests
docker / image (push) Failing after 5s
lint / ruff (push) Successful in 15s
tests / backend (push) Successful in 1m42s
tests / desktop (push) Successful in 24s
tests / web (push) Successful in 39s
tests / android-core (push) Successful in 39s
android / apk (push) Failing after 5m0s
docker / image (push) Failing after 5s
lint / ruff (push) Successful in 15s
tests / backend (push) Successful in 1m42s
tests / desktop (push) Successful in 24s
tests / web (push) Successful in 39s
tests / android-core (push) Successful in 39s
android / apk (push) Failing after 5m0s
This commit is contained in:
1 file changed
+17
-12
@@ -231,18 +231,23 @@ def test_junk_on_the_socket_does_not_take_the_stub_down(stub):
|
||||
|
||||
|
||||
def test_a_dead_upstream_becomes_servfail(tmp_path):
|
||||
resolver = StubResolver(ports=(0,), upstream_path=str(tmp_path / "empty.conf"), timeout=0.3)
|
||||
assert resolver.start()
|
||||
try:
|
||||
# The file does not exist and /etc/resolv.conf points at resolved, which
|
||||
# is filtered out — so there is nowhere to forward to.
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock:
|
||||
sock.settimeout(2)
|
||||
sock.sendto(query("example.com"), ("127.0.0.1", resolver.port))
|
||||
response, _ = sock.recvfrom(4096)
|
||||
assert response[3] & 0x0F == 2 # SERVFAIL, not a lie about the address
|
||||
finally:
|
||||
resolver.stop()
|
||||
# A socket that is bound and listening but never answers. The upstream must
|
||||
# be named explicitly: an empty or missing file falls back to the machine's
|
||||
# /etc/resolv.conf, which in CI is Docker's resolver and *does* answer.
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as dead:
|
||||
dead.bind(("127.0.0.1", 0))
|
||||
conf = tmp_path / "resolv.conf"
|
||||
conf.write_text(f"nameserver 127.0.0.1:{dead.getsockname()[1]}\n")
|
||||
resolver = StubResolver(ports=(0,), upstream_path=str(conf), timeout=0.3)
|
||||
assert resolver.start()
|
||||
try:
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock:
|
||||
sock.settimeout(2)
|
||||
sock.sendto(query("example.com"), ("127.0.0.1", resolver.port))
|
||||
response, _ = sock.recvfrom(4096)
|
||||
assert response[3] & 0x0F == 2 # SERVFAIL, not a lie about the address
|
||||
finally:
|
||||
resolver.stop()
|
||||
|
||||
|
||||
def test_upstreams_are_read_from_resolv_conf_and_loops_are_dropped(tmp_path):
|
||||
|
||||
Reference in new issue
Block a user