Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ac9be4ea8 | ||
|
|
45a673317c | ||
|
|
651c913ebb | ||
|
|
9e494d8c04 | ||
|
|
9507cb0858 |
No files matched your search
@@ -6,8 +6,7 @@
|
||||
# launched Firefox in true HEADLESS mode, which is content-process unstable on
|
||||
# the hosted runners (eval-CSP / context-destroyed). The stealth wrapper instead
|
||||
# launches Firefox HEADED on a real display; under `xvfb-run` (a virtual X
|
||||
# server) that's exactly what we get on a headless CI box - stable, and the same
|
||||
# thing webrtc-e2e.yml already relies on.
|
||||
# server) that's exactly what we get on a headless CI box - stable.
|
||||
#
|
||||
# Secret-free, so it's safe in public CI: the binary is the PUBLIC firefox-9
|
||||
# release (no token), and the webrtc e2e fake a local TCP-only SOCKS. The proxy
|
||||
@@ -219,3 +218,72 @@ jobs:
|
||||
path: ${{ runner.temp }}/e2e-watchdog.log
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
|
||||
# THE SAME e2e ON WINDOWS (Federico, 12/11: every test of the product runs on Linux AND Windows; where Windows behaves
|
||||
# differently the test adapts to the system). Before this, 562 of the 808 e2e had never run on Windows in any round. The census
|
||||
# of 12/11 (run 43307193708) took ~50 minutes in one job, so the files are split in four parts (the sorted list, every fourth
|
||||
# file: a split that does not move when a file is added elsewhere). Left out, by name, are the suites ci/required-suites.json
|
||||
# declares `linux_only` (the reason is on the row); tests/test_every_suite_runs_on_linux_and_windows.py holds both together.
|
||||
e2e-windows:
|
||||
name: e2e (windows, part ${{ matrix.part }})
|
||||
needs: core-on-index
|
||||
if: needs.core-on-index.outputs.available == 'true'
|
||||
runs-on: windows-2022
|
||||
timeout-minutes: 40
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
part: [1, 2, 3, 4]
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
with: { fetch-depth: 1 }
|
||||
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
||||
with: { python-version: '3.11' }
|
||||
- name: Install wrapper + test deps (+ Playwright ONLY as a system tool)
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install ".[dev]"
|
||||
python -m pip install "playwright==$(cat scripts/playwright_pin.txt)"
|
||||
- name: Fetch the published firefox binary
|
||||
run: echo "FF=$(cd "$RUNNER_TEMP" && python -m invisible_playwright fetch | tail -1)" >> "$GITHUB_ENV"
|
||||
- name: The files of this part, without the linux_only suites
|
||||
run: |
|
||||
set -e
|
||||
python -m pytest --collect-only -q -m e2e -o addopts= -p no:cacheprovider 2>/dev/null | grep "::" | cut -d: -f1 | sort -u > "$RUNNER_TEMP/e2e_files.txt"
|
||||
python - "${{ matrix.part }}" "$RUNNER_TEMP" <<'PY'
|
||||
import json, os, sys
|
||||
part, tmp = int(sys.argv[1]), sys.argv[2]
|
||||
rows = json.load(open("ci/required-suites.json", encoding="utf-8"))
|
||||
left_out = [t for r in rows if r.get("linux_only") for t in r["tests"]]
|
||||
files = [l.strip() for l in open(os.path.join(tmp, "e2e_files.txt")) if l.strip()]
|
||||
files = [f for f in files if f not in left_out]
|
||||
mine = [f for i, f in enumerate(files) if i % 4 == part - 1]
|
||||
nodes = [t for t in left_out if "::" in t and t.split("::")[0] in mine]
|
||||
open(os.path.join(tmp, "e2e_args.txt"), "w").write("\n".join(mine + ["--deselect=" + n for n in nodes]) + "\n")
|
||||
print("%d e2e files, %d left out as linux_only, %d in part %d, %d node(s) deselected"
|
||||
% (len(files) + len([t for t in left_out if "::" not in t]), len(left_out), len(mine), part, len(nodes)))
|
||||
PY
|
||||
- name: Run this part of the e2e
|
||||
env:
|
||||
PYTHONUNBUFFERED: "1"
|
||||
INVPW_TEST_WATCHDOG_FILE: ${{ runner.temp }}/e2e-watchdog.log
|
||||
run: |
|
||||
mapfile -t ARGS < <(tr -d '\r' < "$RUNNER_TEMP/e2e_args.txt")
|
||||
python -u scripts/run_e2e.py "$FF" "${ARGS[@]}"
|
||||
- name: Close every Firefox left
|
||||
if: always()
|
||||
shell: pwsh
|
||||
run: |
|
||||
Get-Process firefox -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
|
||||
"left: " + @(Get-Process firefox -ErrorAction SilentlyContinue).Count
|
||||
- name: Upload the hang evidence
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
||||
with:
|
||||
name: e2e-watchdog-windows-${{ matrix.part }}-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
path: ${{ runner.temp }}/e2e-watchdog.log
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
@@ -173,15 +173,15 @@ jobs:
|
||||
# untested until 2026-08-01, and the user who opened issue #51 was on
|
||||
# 3.14. test_marker_vocabulary.py compares this list to the floor.
|
||||
python: ["3.11", "3.12", "3.13", "3.14"]
|
||||
# Windows runners are the scarce, 2x-cost, slow-to-schedule ones, and a
|
||||
# burst of pushes queues them for a long time. Run the FULL Python range
|
||||
# on ubuntu (cheap, fast) and cover Windows on 3.12 only - this is a
|
||||
# pure-Python package, the OS-specific surface is tiny. The python LIST
|
||||
# above stays complete so test_marker_vocabulary still sees every version.
|
||||
# The FULL Python range on ubuntu; Windows on the two ends of the range,
|
||||
# 3.11 and 3.14 (Federico, 12/11: every test on Linux AND Windows; the
|
||||
# ends are where a version-specific difference shows first). The runners
|
||||
# are free for this public repository; the account runs 20 jobs at once.
|
||||
# The python LIST above stays complete so test_marker_vocabulary still
|
||||
# sees every version.
|
||||
exclude:
|
||||
- { os: windows-latest, python: "3.11" }
|
||||
- { os: windows-latest, python: "3.12" }
|
||||
- { os: windows-latest, python: "3.13" }
|
||||
- { os: windows-latest, python: "3.14" }
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
name: webrtc-e2e
|
||||
|
||||
# Live WebRTC realness check against the shipped patched binary.
|
||||
#
|
||||
# Manual (workflow_dispatch) on purpose: it needs a firefox-N binary that
|
||||
# carries the WebRTC fixes (synthetic srflx in genuine nICEr form + the
|
||||
# default-route fallback behind a proxy). Run it after publishing such a
|
||||
# binary - it is the release gate for "WebRTC looks real behind a proxy".
|
||||
# On this Linux runner an engine older than firefox-35 never gets the synthetic
|
||||
# srflx behind a SOCKS proxy (the wildcard default-route probe, fixed in
|
||||
# firefox-35): test_not_blocked_behind_tcp_only_socks skips on it, naming that
|
||||
# defect, and the floor below turns the skip red. From firefox-35 on, a
|
||||
# missing srflx fails the test itself.
|
||||
#
|
||||
# No external proxy provider, no credentials: the "behind a proxy" condition is faked by an
|
||||
# in-process TCP-only SOCKS5 server (refuses UDP ASSOCIATE) and the egress IP
|
||||
# is injected as an RFC 5737 TEST-NET address. Fully self-contained.
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
# Engine and GeoIP downloads go through the release API with this token.
|
||||
# Anonymous requests share a 60-an-hour limit per runner address and are the
|
||||
# ones GitHub drops first when it is degraded (2026-11-08: timeouts for
|
||||
# unauthenticated users failed the gates three times). user-install.yml stays
|
||||
# anonymous on purpose: it is the user's path.
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
jobs:
|
||||
# `pip install -e ".[dev]"` below resolves `invisible-core==N.M.0` from the
|
||||
# package index, and the core is published BEFORE this package. This gate
|
||||
# answers whether it is there yet; during that window the realness job is
|
||||
# SKIPPED with the reason in the run summary rather than faked green, and
|
||||
# once the core is up it runs unchanged. See
|
||||
# .github/workflows/core-on-index.yml.
|
||||
core-on-index:
|
||||
uses: ./.github/workflows/core-on-index.yml
|
||||
|
||||
webrtc-e2e:
|
||||
name: webrtc realness (ubuntu, py3.12)
|
||||
needs: core-on-index
|
||||
if: needs.core-on-index.outputs.available == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python 3.12
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
cache: pip
|
||||
|
||||
- name: Install package + dev extras
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -e ".[dev]"
|
||||
|
||||
- name: Fetch the patched Firefox binary and expose its path
|
||||
shell: bash
|
||||
run: |
|
||||
# NOT `echo "VAR=$(cmd)" >> $GITHUB_ENV`. echo exits 0 whatever the
|
||||
# substitution did, so `set -e` never sees a failure and an EMPTY
|
||||
# value lands in the environment. Both tests below then hit
|
||||
# `pytest.skip("no patched binary")`, pytest exits 0, and the job is
|
||||
# green having verified nothing - which is exactly what run #1 did.
|
||||
set -euo pipefail
|
||||
FETCH_OUTPUT="$(python -m invisible_playwright fetch)"
|
||||
printf '%s\n' "$FETCH_OUTPUT"
|
||||
BIN="$(printf '%s\n' "$FETCH_OUTPUT" | tail -n 1)"
|
||||
if [ -z "$BIN" ] || [ ! -e "$BIN" ]; then
|
||||
echo "invisible_playwright fetch returned '$BIN', which is not a" >&2
|
||||
echo "file. Refusing to run a suite that would skip itself green." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "STEALTHFOX_E2E_BINARY=$BIN" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Run WebRTC realness e2e (xvfb for the headless Firefox)
|
||||
run: |
|
||||
set -o pipefail
|
||||
sudo apt-get update && sudo apt-get install -y xvfb
|
||||
xvfb-run -a pytest tests/test_webrtc_realness.py -m e2e -o addopts="" -v -rs | tee webrtc-report.txt
|
||||
|
||||
# Run #1 was GREEN with the headline assertion skipped: "1 passed, 1
|
||||
# skipped", and the skipped one is the test this workflow's own header
|
||||
# calls the point of the gate. pytest's exit code cannot tell that from a
|
||||
# pass, and this file was the only one of four without a floor.
|
||||
- name: Refuse a run whose main assertion did not execute
|
||||
shell: bash
|
||||
run: |
|
||||
python - <<'PY'
|
||||
import pathlib, re, sys
|
||||
text = pathlib.Path("webrtc-report.txt").read_text(encoding="utf-8", errors="ignore")
|
||||
passed = int((re.search(r"(\d+) passed", text) or [0, 0])[1] or 0)
|
||||
skipped = int((re.search(r"(\d+) skipped", text) or [0, 0])[1] or 0)
|
||||
if skipped:
|
||||
print("these tests SKIPPED, so the gate verified less than it "
|
||||
"claims:", file=sys.stderr)
|
||||
for line in text.splitlines():
|
||||
if line.startswith("SKIPPED"):
|
||||
print(" " + line, file=sys.stderr)
|
||||
if passed < 2 or skipped:
|
||||
print(f"{passed} passed / {skipped} skipped - this gate exists for "
|
||||
f"the synthetic-srflx assertion; a run that skips it is not "
|
||||
f"a pass.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
print(f"{passed} tests ran, none skipped")
|
||||
PY
|
||||
@@ -1,7 +1,7 @@
|
||||
[
|
||||
{"id": "wrapper.e2e.udp", "giro": "G2", "os": ["linux", "windows"], "min_tests": 43, "exact": true, "tests": ["tests/test_preload_newtab_turns_the_privileged_about_process_off_e2e.py", "tests/test_the_association_is_ready_when_the_peerconnection_is_born_e2e.py", "tests/test_turn_over_tcp_is_tried_for_real_e2e.py", "tests/test_webrtc_realness.py::test_the_gather_is_real_without_a_proxy", "tests/test_the_whole_udp_chain_by_name_e2e.py::test_a_turn_srflx_by_name_arrives_through_the_relay_when_the_exit_of_the_lab_is_loopback", "tests/test_declared_host_network_e2e.py", "tests/test_a_page_over_ipv6_gathers_on_a_machine_declared_without_it_e2e.py", "tests/test_webrtc_realness.py::test_a_gateway_with_coherent_udp_gives_the_page_a_srflx_born_through_its_relay", "tests/test_webrtc_realness.py::test_a_host_with_ipv6_addresses_gathers_through_an_ipv4_relay", "tests/test_webrtc_realness.py::test_a_gateway_that_is_far_away_still_gives_the_page_a_srflx_born_through_its_relay", "tests/test_webrtc_realness.py::test_the_first_candidate_of_a_gather_does_not_wait_for_a_gateway_that_is_far_away", "tests/test_webrtc_realness.py::test_a_gather_after_the_page_loaded_through_the_gateway_costs_only_the_road_to_the_server", "tests/test_webrtc_realness.py::test_two_contexts_with_two_proxies_each_gets_the_srflx_of_its_own", "tests/test_webrtc_realness.py::test_the_turn_over_tcp_of_a_context_goes_through_the_proxy_of_that_context", "tests/test_webrtc_realness.py::test_a_proxy_that_does_not_relay_udp_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_udp_leaves_from_another_address_gives_no_srflx_at_all", "tests/test_webrtc_realness.py::test_a_proxy_whose_relay_never_answers_gives_no_srflx_at_all"], "marker": "e2e", "needs_root": false, "note": "Needs the candidate binary (STEALTHFOX_E2E_BINARY) and the engine that carries the UDP line. 57 = 1+7+6+1+21 from the five files + 21 from the 10 UDP-line tests of test_webrtc_realness.py (parametrized). The chain by name is here in its variant with the lab's exit on loopback (127.0.0.2) and the pref `media.peerconnection.ice.loopback`, on Linux and Windows: the exit of the lab is loopback, and a loopback mapped address is thrown away by nICEr unless the ICE context allows it. The variant without the pref (an exit that is not loopback) is the suite wrapper.e2e.udp.exit, Linux only; the address added to the interface of the Windows runner is work of the release after firefox-63. The preload_newtab test (2) is here: seen green on Linux as root (Docker) and on Windows 10 runs of 10 (windows-2022, round 5 engine); it reads the engine's own process log."},
|
||||
{"id": "wrapper.e2e.udp.exit", "giro": "G2", "os": ["linux"], "min_tests": 7, "exact": true, "tests": ["tests/test_the_whole_udp_chain_by_name_e2e.py::test_a_turn_srflx_by_name_arrives_through_the_relay_before_the_tick", "tests/test_a_proxy_that_cannot_carry_udp_leaks_nothing_direct_e2e.py"], "marker": "e2e", "needs_root": ["linux"], "note": "Linux only, and not collected on Windows: the exit of the lab is a documentation address (198.51.100.9) added to lo with `ip addr add`, which needs root and iproute2; a mapped address in 127/8 would be thrown away by nICEr as bogus (stun_client_ctx.cpp nr_stun_transport_addr_check) and the pref that allows it is off in a product. The page reads a srflx equal to the gateway exit and the relay of the TURN server, the TURN name resolved by the DoH through the proxy, in the tick of 2 s. On the Windows runner of GitHub (administrator, the network of the runner) it could run too: not yet. A skipped test would turn the verdict red, hence a suite of its own. Its twin with the lab's exit on loopback and the pref stays in wrapper.e2e.udp on both systems, so that Windows keeps the walk of the chain by name."},
|
||||
{"id": "wrapper.e2e.udp.sandbox", "giro": "G2", "os": ["linux"], "min_tests": 13, "exact": true, "tests": ["tests/test_the_socket_process_is_sandboxed_e2e.py", "tests/test_webrtc_realness.py::test_the_gather_is_real_without_a_proxy", "tests/test_webrtc_realness.py::test_a_gateway_with_coherent_udp_gives_the_page_a_srflx_born_through_its_relay", "tests/test_ice_names_by_the_context_proxy_e2e.py::test_a_gateway_without_udp_resolves_the_ice_name_then_ends_in_701"], "marker": "e2e", "needs_root": false, "note": "The browser WITH its sandbox, run by a normal user, as on any Linux that allows user namespaces. On the Ubuntu 24.04 runner AppArmor refuses them to a user, so every other non-root suite runs a browser WITHOUT the sandbox of its socket and content processes; the gate turns the restriction off for this leg (sysctl kernel.apparmor_restrict_unprivileged_userns=0) and the first test fails unless the socket and a tab process have a seccomp filter (Seccomp: 2). The three situations of the UDP line: A (a proxy that carries UDP: the srflx born through the relay), B (no proxy: the gather is real), C (a proxy with no UDP: the ICE server name goes by DoH through the proxy and the gather ends in 701). No root and no resolver trap needed."},
|
||||
{"id": "wrapper.e2e.udp.exit", "giro": "G2", "os": ["linux"], "min_tests": 7, "exact": true, "tests": ["tests/test_the_whole_udp_chain_by_name_e2e.py::test_a_turn_srflx_by_name_arrives_through_the_relay_before_the_tick", "tests/test_a_proxy_that_cannot_carry_udp_leaks_nothing_direct_e2e.py"], "marker": "e2e", "needs_root": ["linux"], "note": "Linux only, and not collected on Windows: the exit of the lab is a documentation address (198.51.100.9) added to lo with `ip addr add`, which needs root and iproute2; a mapped address in 127/8 would be thrown away by nICEr as bogus (stun_client_ctx.cpp nr_stun_transport_addr_check) and the pref that allows it is off in a product. The page reads a srflx equal to the gateway exit and the relay of the TURN server, the TURN name resolved by the DoH through the proxy, in the tick of 2 s. On the Windows runner of GitHub (administrator, the network of the runner) it could run too: not yet. A skipped test would turn the verdict red, hence a suite of its own. Its twin with the lab's exit on loopback and the pref stays in wrapper.e2e.udp on both systems, so that Windows keeps the walk of the chain by name.", "linux_only": "The lab's exit is a documentation address the host must hold besides its loopback (nICEr throws away a mapped address in 127/8). Linux holds it on lo as root; Windows takes no extra address on its loopback pseudo-interface, and adding it to the runner's adapter took the runner off the network (runs 43314251547 and 43334169682 died in the test step). A Windows twin waits for a way that leaves the runner's network alone."},
|
||||
{"id": "wrapper.e2e.udp.sandbox", "giro": "G2", "os": ["linux"], "min_tests": 13, "exact": true, "tests": ["tests/test_the_socket_process_is_sandboxed_e2e.py", "tests/test_webrtc_realness.py::test_the_gather_is_real_without_a_proxy", "tests/test_webrtc_realness.py::test_a_gateway_with_coherent_udp_gives_the_page_a_srflx_born_through_its_relay", "tests/test_ice_names_by_the_context_proxy_e2e.py::test_a_gateway_without_udp_resolves_the_ice_name_then_ends_in_701"], "marker": "e2e", "needs_root": false, "note": "The browser WITH its sandbox, run by a normal user, as on any Linux that allows user namespaces. On the Ubuntu 24.04 runner AppArmor refuses them to a user, so every other non-root suite runs a browser WITHOUT the sandbox of its socket and content processes; the gate turns the restriction off for this leg (sysctl kernel.apparmor_restrict_unprivileged_userns=0) and the first test fails unless the socket and a tab process have a seccomp filter (Seccomp: 2). The three situations of the UDP line: A (a proxy that carries UDP: the srflx born through the relay), B (no proxy: the gather is real), C (a proxy with no UDP: the ICE server name goes by DoH through the proxy and the gather ends in 701). No root and no resolver trap needed.", "linux_only": "It reads the seccomp filter of the socket and tab processes in /proc. The Windows twin reads the sandbox token of the same processes (integrity level, restrictions) and needs a measurement of the retail Firefox's tokens first; until then Linux only."},
|
||||
{"id": "wrapper.e2e.web", "giro": "G2", "os": ["linux", "windows"], "min_tests": 27, "exact": true, "tests": ["tests/test_networkidle_through_a_served_browser_with_routes_e2e.py", "tests/test_http3_through_the_proxy_e2e.py"], "marker": "e2e", "needs_root": false, "note": "The networkidle e2e with routes and the HTTP/3 e2e, split from wrapper.e2e.udp (about 260 s of 500 on Linux; the whole suite did not fit the 15 minutes of Windows)."},
|
||||
{"id": "wrapper.e2e.doh", "giro": "G2", "os": ["linux", "windows"], "min_tests": 19, "exact": true, "tests": ["tests/test_the_hosts_file_of_the_host_is_never_read_e2e.py", "tests/test_resolver_race_e2e.py", "tests/test_doh_under_stress_e2e.py", "tests/test_context_proxy_only_resolves_by_doh_e2e.py", "tests/test_doh_through_the_proxy_e2e.py", "tests/test_ice_names_by_the_context_proxy_e2e.py"], "marker": "e2e", "needs_root": ["linux"], "note": "Linux needs root: the resolver trap of the file (ResolverTrap) points /etc/resolv.conf at a counting resolver on port 53. Su Windows il resolver trap non gira: l'asserzione sul resolver di sistema è l'unica omessa. Run it without xdist (port 53 is one per host). On the Linux leg the gate exports INVPW_REQUIRE_TRAP=1: a trap that cannot run or bind port 53 is a failure, not a skipped assertion."},
|
||||
{"id": "wrapper.e2e.realness", "giro": "G2", "os": ["linux", "windows"], "min_tests": 32, "exact": true, "tests": ["tests/test_realness_behind_a_declared_exit_e2e.py"], "marker": "e2e", "needs_root": ["linux"], "note": "The realness check without a real proxy: six declared exits, the values a page reads, and the roads. Linux runs as root without xdist like the DoH suite (the resolver trap); on Windows the trap does not exist and the assertion on the system resolver is the only one omitted."},
|
||||
|
||||
@@ -280,6 +280,19 @@ class FakeDoh:
|
||||
with self._lock:
|
||||
return [a for a in self.answers if a.name == name and (qtype is None or a.qtype == qtype)]
|
||||
|
||||
def certificate_refusals(self) -> List[Tuple[str, str]]:
|
||||
"""The failed handshakes in which the client REFUSED the certificate: a TLS alert (unknown CA, bad certificate...).
|
||||
|
||||
Not every failed handshake is one. A client that drops a connection before the handshake ends (a speculative or a
|
||||
duplicate DoH connection the browser abandons) fails it too, and says nothing about the certificate: on Windows as
|
||||
ConnectionAbortedError [WinError 10053], elsewhere as a reset or an end of file. Only a refusal means that a lookup
|
||||
of a context without the certificate exception reached the DoH. Windows census of 12/11 (run 43333574229): a
|
||||
ConnectionAbortedError through the gateway of a context that HAS the exception was read as such a lookup.
|
||||
"""
|
||||
with self._lock:
|
||||
return [(via, error) for via, error in self.tls_failures
|
||||
if "ALERT" in error.upper() or "CERTIFICATE" in error.upper()]
|
||||
|
||||
def seen_names(self) -> List[str]:
|
||||
with self._lock:
|
||||
return sorted({q.name for q in self.queries})
|
||||
|
||||
@@ -89,11 +89,11 @@ def test_a_context_that_is_the_only_proxy_resolves_its_names_by_doh_through_it(f
|
||||
assert _asked_outside(doh, "page-a.test") == [], (
|
||||
"the DoH was asked for a name that is not the proxied context's: the default context, which has no proxy, must "
|
||||
"resolve natively and never use the DoH: %s" % _asked_outside(doh, "page-a.test") + why)
|
||||
# A lookup of a context without `ignore_https_errors` (the default one) can only fail the handshake with the FakeDoh:
|
||||
# a failed handshake is a lookup of the wrong context that reached the DoH through this gateway.
|
||||
assert doh.tls_failures == [], (
|
||||
"a DoH handshake failed: a context that does not accept the FakeDoh certificate (the default context, which has no "
|
||||
"proxy) used the DoH: %s" % doh.tls_failures + why)
|
||||
# A lookup of a context without `ignore_https_errors` (the default one) can only REFUSE the FakeDoh's certificate: a refusal
|
||||
# is a lookup of the wrong context that reached the DoH through this gateway (a dropped connection is not one).
|
||||
assert doh.certificate_refusals() == [], (
|
||||
"a DoH handshake was refused: a context that does not accept the FakeDoh certificate (the default context, which has no "
|
||||
"proxy) used the DoH: %s (every failed handshake: %s)" % (doh.certificate_refusals(), doh.tls_failures) + why)
|
||||
|
||||
assert watcher.watched_pids, ("the watcher never saw a browser process (it saw: %s): a watcher that cannot see proves "
|
||||
"nothing" % watcher.process_names)
|
||||
|
||||
@@ -96,9 +96,11 @@ def _only_the_doh_road_was_used(doh, gw, watcher):
|
||||
"a CONNECT carried a name: the browser must resolve with the DoH and connect by address" + why)
|
||||
assert "direct" not in {q.via for q in doh.queries}, "something reached the DoH without the proxy of the context" + why
|
||||
_assert_every_connection_went_through_the_gateway(doh, gw)
|
||||
# Context-only layout: the default context resolves natively and never uses the DoH, so a failed handshake (the lookup
|
||||
# Context-only layout: the default context resolves natively and never uses the DoH, so a refused certificate (the lookup
|
||||
# of a context that does not accept the FakeDoh certificate) is a lookup of the wrong context sent to the DoH.
|
||||
assert doh.tls_failures == [], "a DoH handshake failed: the default context used the DoH: %s" % doh.tls_failures + why
|
||||
assert doh.certificate_refusals() == [], (
|
||||
"a DoH handshake was refused: the default context used the DoH: %s (every failed handshake: %s)"
|
||||
% (doh.certificate_refusals(), doh.tls_failures) + why)
|
||||
assert watcher.watched_pids, ("the watcher never saw a browser process (it saw: %s): a watcher that cannot see proves "
|
||||
"nothing" % watcher.process_names)
|
||||
assert _direct_to_the_doh(watcher) == [], (
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
"""Every test of the product runs on Linux AND on Windows (no browser here).
|
||||
|
||||
Federico, 12/11: a test seen only on Linux proves nothing about the system the product imitates. On that day 562 of the 808
|
||||
e2e of this package had never run on Windows in any round (the e2e of a pull request ran on Linux only, and the candidate's
|
||||
gate carried 246 of them), and two suites of the gate (`wrapper.e2e.udp.exit`, `wrapper.e2e.udp.sandbox`) were Linux only.
|
||||
Where Windows behaves differently the test adapts to the system; it does not stay on one.
|
||||
|
||||
What this holds, reading the files as text (PyYAML is not a dependency of this package):
|
||||
|
||||
* every row of ci/required-suites.json names both systems, or names its Windows twin (`windows_twin`: the id of a row
|
||||
that runs on Windows), or says why it can only be Linux (`linux_only`: a test of Linux converging on Windows, which has
|
||||
no Windows counterpart because Windows IS the reference);
|
||||
* the jobs of e2e.yml that run scripts/run_e2e.py run on a Linux and on a Windows runner between them;
|
||||
* the unit job of tests.yml runs on both.
|
||||
|
||||
Known-bad inputs: the files as they were on 12/11 (two Linux-only rows with no twin; e2e.yml on ubuntu-24.04 only) ->
|
||||
`problems` names each of them.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SUITES = ROOT / "ci" / "required-suites.json"
|
||||
WORKFLOWS = ROOT / ".github" / "workflows"
|
||||
|
||||
|
||||
def suite_problems(rows: list) -> list:
|
||||
out = []
|
||||
windows_ids = {r["id"] for r in rows if "windows" in r.get("os", [])}
|
||||
for r in rows:
|
||||
systems = set(r.get("os", []))
|
||||
if {"linux", "windows"} <= systems:
|
||||
continue
|
||||
twin = r.get("windows_twin")
|
||||
reason = (r.get("linux_only") or "").strip()
|
||||
if "windows" not in systems and twin:
|
||||
if twin not in windows_ids:
|
||||
out.append("%s: its windows_twin %r is not a row that runs on Windows" % (r["id"], twin))
|
||||
continue
|
||||
if "windows" not in systems and reason:
|
||||
continue
|
||||
missing = sorted({"linux", "windows"} - systems)
|
||||
out.append("%s runs on %s only: it needs %s, a windows_twin, or a linux_only reason"
|
||||
% (r["id"], "/".join(sorted(systems)) or "nothing", " and ".join(missing)))
|
||||
return out
|
||||
|
||||
|
||||
def _jobs(text: str) -> list:
|
||||
"""(name, body) of each job under `jobs:` (two-space indentation, as every workflow here is written)."""
|
||||
body = text.split("\njobs:\n", 1)[1] if "\njobs:\n" in text else ""
|
||||
marks = list(re.finditer(r"^ ([A-Za-z0-9_-]+):\s*$", body, re.M))
|
||||
return [(m.group(1), body[m.start():(marks[i + 1].start() if i + 1 < len(marks) else len(body))]) for i, m in enumerate(marks)]
|
||||
|
||||
|
||||
def _runs_on_both(job: str) -> bool:
|
||||
runners = re.findall(r"\b(ubuntu-[0-9a-z.]+|windows-[0-9a-z.]+)\b", job)
|
||||
return any(r.startswith("ubuntu") for r in runners) and any(r.startswith("windows") for r in runners)
|
||||
|
||||
|
||||
def workflow_problems(e2e_text: str, tests_text: str) -> list:
|
||||
out = []
|
||||
e2e = [(n, b) for n, b in _jobs(e2e_text) if "scripts/run_e2e.py" in b]
|
||||
if not e2e:
|
||||
out.append("e2e.yml has no job that runs scripts/run_e2e.py")
|
||||
elif not _runs_on_both(" ".join(b for _n, b in e2e)):
|
||||
out.append("the jobs of e2e.yml that run scripts/run_e2e.py (%s) do not run on both a Linux and a Windows runner"
|
||||
% ", ".join(n for n, _b in e2e))
|
||||
unit = [(n, b) for n, b in _jobs(tests_text) if re.search(r"python -m pytest|pytest ", b) and "matrix" in b]
|
||||
if not unit:
|
||||
out.append("tests.yml has no unit job with a matrix")
|
||||
for name, body in unit:
|
||||
if not _runs_on_both(body):
|
||||
out.append("tests.yml job %r does not run on both a Linux and a Windows runner" % name)
|
||||
return out
|
||||
|
||||
|
||||
def test_every_suite_of_the_gate_runs_on_both_systems_or_names_its_twin():
|
||||
assert suite_problems(json.loads(SUITES.read_text(encoding="utf-8"))) == []
|
||||
|
||||
|
||||
def test_the_e2e_and_the_unit_tests_of_a_pull_request_run_on_both_systems():
|
||||
assert workflow_problems((WORKFLOWS / "e2e.yml").read_text(encoding="utf-8"),
|
||||
(WORKFLOWS / "tests.yml").read_text(encoding="utf-8")) == []
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------------------------- the checkers can fail
|
||||
ROWS_OF_12_11 = [
|
||||
{"id": "wrapper.e2e.udp", "os": ["linux", "windows"]},
|
||||
{"id": "wrapper.e2e.udp.exit", "os": ["linux"]},
|
||||
{"id": "wrapper.e2e.udp.sandbox", "os": ["linux"]},
|
||||
]
|
||||
|
||||
E2E_OF_12_11 = """
|
||||
jobs:
|
||||
core-on-index:
|
||||
uses: ./.github/workflows/core-on-index.yml
|
||||
e2e:
|
||||
name: e2e (linux, xvfb)
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- run: xvfb-run -a python -u scripts/run_e2e.py "$FF"
|
||||
"""
|
||||
|
||||
TESTS_OF_12_11 = """
|
||||
jobs:
|
||||
unit:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- { os: ubuntu-latest, python: '3.11' }
|
||||
- { os: windows-latest, python: '3.12' }
|
||||
steps:
|
||||
- run: python -m pytest -m unit
|
||||
"""
|
||||
|
||||
|
||||
def test_the_rows_of_12_11_are_refused():
|
||||
found = suite_problems(ROWS_OF_12_11)
|
||||
assert len(found) == 2 and all("linux only" in p for p in found), found
|
||||
|
||||
|
||||
def test_a_twin_that_does_not_run_on_windows_is_refused():
|
||||
rows = [{"id": "a", "os": ["linux"], "windows_twin": "b"}, {"id": "b", "os": ["linux"]}]
|
||||
assert any("windows_twin 'b' is not a row that runs on Windows" in p for p in suite_problems(rows))
|
||||
|
||||
|
||||
def test_a_twin_or_a_reason_is_accepted():
|
||||
rows = [{"id": "a", "os": ["linux"], "windows_twin": "b"}, {"id": "b", "os": ["windows"], "windows_twin": None},
|
||||
{"id": "c", "os": ["linux"], "linux_only": "Linux converging on Windows: Windows is the reference"}]
|
||||
assert [p for p in suite_problems(rows) if not p.startswith("b ")] == []
|
||||
|
||||
|
||||
def test_the_e2e_of_12_11_is_refused_and_the_unit_job_passes():
|
||||
found = workflow_problems(E2E_OF_12_11, TESTS_OF_12_11)
|
||||
assert found == ["the jobs of e2e.yml that run scripts/run_e2e.py (e2e) do not run on both a Linux and a Windows runner"], found
|
||||
@@ -146,7 +146,9 @@ def _back_to_back_contexts(mode, firefox_binary, doh, pages, gateway, trap, watc
|
||||
assert _asked_outside(doh, *names) == [], (
|
||||
"the DoH was asked for a name that is not one of the proxied contexts' (the default context has no proxy and "
|
||||
"must resolve natively): %s" % _asked_outside(doh, *names) + why)
|
||||
assert doh.tls_failures == [], "a context without the FakeDoh certificate exception used the DoH: %s" % doh.tls_failures + why
|
||||
assert doh.certificate_refusals() == [], (
|
||||
"a context without the FakeDoh certificate exception used the DoH (it refused the certificate): %s (every failed "
|
||||
"handshake: %s)" % (doh.certificate_refusals(), doh.tls_failures) + why)
|
||||
else:
|
||||
# The launch proxy is the proxy of the default context too: its background names go to the DoH through the launch
|
||||
# proxy (their handshakes fail BY DESIGN and are counted by the accounting above), so here nothing may go direct or
|
||||
@@ -188,7 +190,9 @@ def _beside_a_proxied_context(firefox_binary, doh, pages, gateway, trap, watcher
|
||||
"the FakeDoh was asked for a name that is not A's (B and the default context have no proxy and must not use the "
|
||||
"DoH): %s" % _asked_outside(doh, name_a) + why)
|
||||
assert "direct" not in {q.via for q in doh.queries}, "something reached the DoH without A's proxy" + why
|
||||
assert doh.tls_failures == [], "a context without the FakeDoh certificate exception used the DoH: %s" % doh.tls_failures + why
|
||||
assert doh.certificate_refusals() == [], (
|
||||
"a context without the FakeDoh certificate exception used the DoH (it refused the certificate): %s (every failed "
|
||||
"handshake: %s)" % (doh.certificate_refusals(), doh.tls_failures) + why)
|
||||
_assert_every_connection_went_through_the_gateway(doh, gw_a)
|
||||
|
||||
assert watcher.watched_pids, ("the watcher never saw a browser process (it saw: %s): a watcher that cannot see "
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
"""The FakeDoh tells a certificate the client refused from a connection the client dropped (no browser).
|
||||
|
||||
Windows census of 12/11 (run 43333574229): test_resolver_race_e2e read a ConnectionAbortedError [WinError 10053], through the
|
||||
gateway of a context that HAS the certificate exception, as "a context without the FakeDoh certificate exception used the DoH".
|
||||
A dropped connection (a speculative or duplicate DoH connection the browser abandons) says nothing about the certificate; only
|
||||
a TLS alert from the client does. Known-bad: FakeDoh before this change has no certificate_refusals, and the e2e asserted
|
||||
`tls_failures == []`, which a dropped connection alone fails.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from _doh_servers import FakeDoh
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
ABORTED_ON_WINDOWS = ("gw-a", "ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine")
|
||||
RESET = ("gw-1", "ConnectionResetError: [Errno 104] Connection reset by peer")
|
||||
EOF = ("gw-1", "SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1006)")
|
||||
UNKNOWN_CA = ("gw-1", "SSLError: [SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:1006)")
|
||||
BAD_CERTIFICATE = ("direct", "SSLError: [SSL: SSLV3_ALERT_BAD_CERTIFICATE] sslv3 alert bad certificate (_ssl.c:1006)")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def doh():
|
||||
server = FakeDoh({})
|
||||
yield server
|
||||
server.close()
|
||||
|
||||
|
||||
def test_a_dropped_connection_is_not_a_refused_certificate(doh):
|
||||
doh.tls_failures.extend([ABORTED_ON_WINDOWS, RESET, EOF])
|
||||
assert doh.certificate_refusals() == []
|
||||
assert len(doh.tls_failures) == 3, "the failures stay listed for the message of a failed assertion"
|
||||
|
||||
|
||||
def test_a_tls_alert_from_the_client_is_a_refused_certificate(doh):
|
||||
doh.tls_failures.extend([ABORTED_ON_WINDOWS, UNKNOWN_CA, BAD_CERTIFICATE])
|
||||
assert doh.certificate_refusals() == [UNKNOWN_CA, BAD_CERTIFICATE]
|
||||
@@ -44,7 +44,8 @@ def problems(text: str, suite: dict) -> list:
|
||||
nodes = [t for t in suite["tests"] if "::" in t]
|
||||
steps = _steps(text)
|
||||
root = [body for name, body in steps if "root e2e" in name]
|
||||
runner = [body for name, body in steps if "scripts/run_e2e.py" in body]
|
||||
# the Linux run (xvfb): the Windows parts of e2e.yml leave the linux_only suites out by reading ci/required-suites.json
|
||||
runner = [body for name, body in steps if "scripts/run_e2e.py" in body and "xvfb-run" in body]
|
||||
if len(root) != 1:
|
||||
return ["there is no (or more than one) step for the root e2e: %d" % len(root)]
|
||||
if len(runner) != 1:
|
||||
|
||||
Reference in new issue
Block a user