tests: the question of the exit behind a proxy of the lab is answered by the lab, never by the internet
The product asks "where do I leave from" through the proxy of a launch, HTTPS, to the exit services of the core. Some proxies of the tests forward for real (Socks5TcpOnly, the recorder of the SOCKS auth test, the gateway beyond its own answers): they carried the question to the internet, and the answer was the public address of the runner, which changed in the middle of a session (ProxyEgressDrifted on the ledger PR of 0.56.0). Each proxy of the tests that forwards for real now declares its exit and the lab answers with it. A question that reaches one without a declaration is refused there, and an autouse fixture fails the test with the name of the proxy and of the service. Ten unit tests (red on the old bench). min_tests of wrapper.unit.all: +10.
This commit is contained in:
1 parent
54e1761ac1
commit
3f3214d75c
7 files changed
+302
-12
No files matched your search
@@ -13,6 +13,6 @@
|
||||
{"id": "wrapper.e2e.compositing", "giro": "G2", "os": ["linux", "windows"], "min_tests": 9, "exact": true, "tests": ["tests/test_software_compositing_is_declared_e2e.py", "tests/test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e.py"], "marker": "e2e", "needs_root": false, "note": "The engine DECLARES software compositing on every machine (core: the compositing entries of zoom.stealth.gfx.feature_status carry the VM decision, and on Windows gfx.webrender.software=true, gfx.webrender.software.d3d11=false). 3 = (1) the compositor read from a privileged context is 'WebRender (Software)' on Windows and on Linux (windowUtils.layerManagerType of each window: Troubleshoot.snapshot().graphics throws on this engine, `ext is null`, so it is not the route); (2) the GPU process uses under 1.5 s of CPU on the fixed 10-scene loop of one browser (Windows runner: 0.32 s declared, 2.7-4.2 s not, runs 43652292533 and 43642744101; on Linux it is held to the bound if a GPU process exists); (3) the 86 keys of the page-bytes probe plus the canvas 2D scenes (drawImage scaled with smoothing off/low/medium/high, text with linear/radial/conic gradients) equal tests/data/page_bytes_<os>.json, PNGs on decoded pixels. EXPECTED RED on the core 64.71.0 (tests 1 and 2 on Windows). The reference of Windows holds the 75 stable keys and 6 of the 11 PNG keys of run 43652292533; the five other PNG keys and the new canvas keys, and all of Linux, are written from the first run on the engine of the reference (the failure of test 3 prints RECORD-BEGIN ... RECORD-END with the entries to merge): a reference that is not complete is red, never skipped. 9 = those 3 + the 6 families of tests/test_a_screenshot_draws_the_text_of_the_bundled_fonts_as_the_content_does_e2e.py (from firefox-66, engine_at_least): a screenshot draws the text of Arial, Times New Roman, Consolas and Segoe UI, with accents, the typographic apostrophe, the euro sign, Chinese, Arabic and Russian, and of MS PGothic (face 2 of msgothic5_32.ttc: Japanese and Latin) and NSimSun (face 1 of simsun.ttc: Chinese), two faces that are not the first of their collection, with the same bytes as the content process drew them in a canvas (an SVG image with a foreignObject of the same markup), cut from the same page.screenshot, on both systems and with no threshold. EXPECTED RED on every engine that rebuilds the text in the parent with another font than the bundle (Linux: fontconfig answers DejaVu Sans), and skipped, hence red here, on an engine older than firefox-66. It saves the screenshot, the two boxes and a result.json under RUNNER_TEMP/invpw-evidence."},
|
||||
{"id": "wrapper.e2e.fontconfig", "giro": "G2", "os": ["linux"], "min_tests": 2, "exact": true, "tests": ["tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py"], "marker": "e2e", "needs_root": false, "linux_only": "Fontconfig exists only on Linux: the parent of the engine shows <GRE>/fonts to it (FcConfigAppFontAddDir) to rebuild a font from a path and a face index. On Windows DirectWrite opens the file from its path, with no folder to scan and no cache to read, so this test has no Windows counterpart.", "note": "2 = (1) the stand-in that runs the engine under strace stays in the engine's place, as the core launches it (the leader of a process group of its own): a fake engine with a child, no browser; the process the launcher holds lives as long as the fake engine, and the group killed holds strace and the child (the stand-in that exec'd setsid forked and exited 0 at once: candidate 44161687675); (2) the warm launch of the parent reads the bundle from fontconfig's cache and does not scan it again (from firefox-66, engine_at_least). Two launches under strace with the same XDG_CACHE_HOME of the test, the first cold and the second warm: the cold parent opens every font file of <GRE>/fonts (the folder as the disk lists it) before any page and fontconfig writes its cache; the warm parent does not open every one of them, and it opens a *.cache-* file of fontconfig (a few files are opened to be used, so the verdict asks about the whole folder, as a scan does). Scan and drawing are told apart by position: only what the parent opens before the first page counts (the opens that draw are written as after_startup). Evidence in RUNNER_TEMP/invpw-evidence/fontconfig-cache: the interval and the number of opens of the bundle, the names of the files of the bundle each launch opened before the first page, the size of the cache file, the VmRSS of the parent after about:blank and after a page with every family, and a third launch with gfx.bundled-fonts.activate=0 (the behaviour before), which is evidence only. Needs strace on the runner: without it both are red, not skipped. No threshold."},
|
||||
{"id": "wrapper.unit.compositing", "giro": "G1", "os": ["linux", "windows"], "min_tests": 30, "exact": true, "tests": ["tests/test_the_page_bytes_reference_compares_decoded_pixels.py"], "marker": "unit", "needs_root": false, "note": "The helpers of wrapper.e2e.compositing on known inputs, no browser: the PNG compared on decoded pixels (another deBG chunk and compression are the same, one pixel is not, every scanline filter), the comparison with a reference (changed, missing and extra keys named, the entry to record), the type of an engine process, an engine process known by its executable and not by the name it gives itself (Linux), and the CPU of a window, and the shape of the committed Windows reference, and the box cut out of a screenshot (its pixels, a box outside the picture refused, written as a PNG and read back, two boxes told apart by a pixel that is named, the pixels that are not grey)."},
|
||||
{"id": "wrapper.unit.all.linux", "giro": "G1", "os": ["linux"], "min_tests": 2131, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_verdict.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_css_calc_is_windows_e2e.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_refusal_is_declared.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_every_suite_runs_on_linux_and_windows.py", "tests/test_expose_binding_refusal.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fixtures_name_why_the_package_is_missing.py", "tests/test_fork.py", "tests/test_frame_dispatch.py", "tests/test_geoip_used.py", "tests/test_goto_follows_the_base_url.py", "tests/test_hook_wiring.py", "tests/test_imports.py", "tests/test_integration.py", "tests/test_juggler_event_buffer.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py", "tests/test_juggler_lives_in_the_core.py", "tests/test_juggler_posix_pipe.py", "tests/test_juggler_transport.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_keyboard_rhythm.py", "tests/test_launch_counters_run_on_github.py", "tests/test_launcher_config.py", "tests/test_launcher_helpers.py", "tests/test_math_sin_cos_tan_are_windows_e2e.py", "tests/test_motion_never_hides_a_programming_error.py", "tests/test_navigation_response.py", "tests/test_new_page_defaults.py", "tests/test_no_event_of_any_family_is_lost_by_the_hand_over.py", "tests/test_no_legacy_in_the_wrapper.py", "tests/test_no_override_leaves_the_persona_scheme.py", "tests/test_no_thread_is_started_on_the_reader.py", "tests/test_page_number_follows_the_call.py", "tests/test_persistent_profile_keeps_state.py", "tests/test_pin.py", "tests/test_pin_dicts_are_valid.py", "tests/test_pinning_doc.py", "tests/test_pointer_server.py", "tests/test_popup_adoption_unit.py", "tests/test_prefs_composition_arm.py", "tests/test_preload_newtab_is_written_only_when_asked.py", "tests/test_protocol_names_are_declared.py", "tests/test_proxy_reaches_the_broLine truncated
|
||||
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 2132, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_verdict.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_css_calc_is_windows_e2e.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_refusal_is_declared.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_every_suite_runs_on_linux_and_windows.py", "tests/test_expose_binding_refusal.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fixtures_name_why_the_package_is_missing.py", "tests/test_fork.py", "tests/test_frame_dispatch.py", "tests/test_geoip_used.py", "tests/test_goto_follows_the_base_url.py", "tests/test_hook_wiring.py", "tests/test_imports.py", "tests/test_integration.py", "tests/test_juggler_event_buffer.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py", "tests/test_juggler_lives_in_the_core.py", "tests/test_juggler_transport.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_keyboard_rhythm.py", "tests/test_launch_counters_run_on_github.py", "tests/test_launcher_config.py", "tests/test_launcher_helpers.py", "tests/test_math_sin_cos_tan_are_windows_e2e.py", "tests/test_motion_never_hides_a_programming_error.py", "tests/test_navigation_response.py", "tests/test_new_page_defaults.py", "tests/test_no_event_of_any_family_is_lost_by_the_hand_over.py", "tests/test_no_legacy_in_the_wrapper.py", "tests/test_no_override_leaves_the_persona_scheme.py", "tests/test_no_thread_is_started_on_the_reader.py", "tests/test_page_number_follows_the_call.py", "tests/test_persistent_profile_keeps_state.py", "tests/test_pin.py", "tests/test_pin_dicts_are_valid.py", "tests/test_pinning_doc.py", "tests/test_pointer_server.py", "tests/test_popup_adoption_unit.py", "tests/test_prefs_composition_arm.py", "tests/test_prefs_composition_arm_on_windows.py", "tests/test_preload_newtab_is_written_only_when_asked.py", "tests/test_protocol_names_are_declared.py", "tests/test_proLine truncated
|
||||
{"id": "wrapper.unit.all.linux", "giro": "G1", "os": ["linux"], "min_tests": 2141, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_verdict.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_css_calc_is_windows_e2e.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_refusal_is_declared.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_every_suite_runs_on_linux_and_windows.py", "tests/test_expose_binding_refusal.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fixtures_name_why_the_package_is_missing.py", "tests/test_fork.py", "tests/test_frame_dispatch.py", "tests/test_geoip_used.py", "tests/test_goto_follows_the_base_url.py", "tests/test_hook_wiring.py", "tests/test_imports.py", "tests/test_integration.py", "tests/test_juggler_event_buffer.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py", "tests/test_juggler_lives_in_the_core.py", "tests/test_juggler_posix_pipe.py", "tests/test_juggler_transport.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_keyboard_rhythm.py", "tests/test_launch_counters_run_on_github.py", "tests/test_launcher_config.py", "tests/test_launcher_helpers.py", "tests/test_math_sin_cos_tan_are_windows_e2e.py", "tests/test_motion_never_hides_a_programming_error.py", "tests/test_navigation_response.py", "tests/test_new_page_defaults.py", "tests/test_no_event_of_any_family_is_lost_by_the_hand_over.py", "tests/test_no_legacy_in_the_wrapper.py", "tests/test_no_override_leaves_the_persona_scheme.py", "tests/test_no_thread_is_started_on_the_reader.py", "tests/test_page_number_follows_the_call.py", "tests/test_persistent_profile_keeps_state.py", "tests/test_pin.py", "tests/test_pin_dicts_are_valid.py", "tests/test_pinning_doc.py", "tests/test_pointer_server.py", "tests/test_popup_adoption_unit.py", "tests/test_prefs_composition_arm.py", "tests/test_preload_newtab_is_written_only_when_asked.py", "tests/test_protocol_names_are_declared.py", "tests/test_proxy_reaches_the_broLine truncated
|
||||
{"id": "wrapper.unit.all.windows", "giro": "G1", "os": ["windows"], "min_tests": 2142, "exact": true, "tests": ["tests/test_a_162_message_is_read_like_a_161_one.py", "tests/test_a_click_makes_one_mousemove_at_its_point.py", "tests/test_a_closed_context_leaves_nothing_in_the_registry.py", "tests/test_a_closed_page_says_nothing.py", "tests/test_a_closed_pipe_is_a_closed_target.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_a_context_proxy_carries_its_measured_udp_exit.py", "tests/test_a_context_route_disables_the_cache.py", "tests/test_a_detached_frame_answers_detached.py", "tests/test_a_dialog_is_a_protocol_object.py", "tests/test_a_dialog_is_answered_after_a_pause.py", "tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_a_failed_expect_carries_its_call_log.py", "tests/test_a_failed_launch_stops_the_display.py", "tests/test_a_field_is_typed_after_a_pause.py", "tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py", "tests/test_a_launch_has_one_deadline.py", "tests/test_a_launch_without_a_session_gets_one.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py", "tests/test_a_module_that_leaves_a_browser_open_fails.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_a_non_finite_number_crosses_the_wire_as_a_tag.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_path_leaves_as_one_stroke.py", "tests/test_a_port_number_is_held_until_it_is_used.py", "tests/test_a_request_and_a_response_are_light.py", "tests/test_a_request_says_what_it_is.py", "tests/test_a_session_ends_before_the_next_test_starts.py", "tests/test_a_stroke_is_judged_by_its_shape_not_its_length.py", "tests/test_a_unit_test_does_not_read_the_seal_of_the_job.py", "tests/test_actions_without_a_point.py", "tests/test_add_script_tag.py", "tests/test_an_expect_reads_its_value_once.py", "tests/test_async_api.py", "tests/test_browser_output_is_drained.py", "tests/test_ci_downloads_are_authenticated.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_ci_host_gate.py", "tests/test_ci_lab_geoip.py", "tests/test_ci_lab_geoip_verify.py", "tests/test_ci_lab_intermediates.py", "tests/test_ci_real_geoip_check.py", "tests/test_ci_real_geoip_exit_code.py", "tests/test_ci_runs_once_per_commit.py", "tests/test_ci_verdict.py", "tests/test_ci_workflows_build_the_geoip_database.py", "tests/test_ci_workflows_set_the_intermediates_list.py", "tests/test_cli.py", "tests/test_click_rhythm.py", "tests/test_connect_does_not_start_threads_on_the_loop.py", "tests/test_context_locale_is_a_list.py", "tests/test_core_pin.py", "tests/test_cpu_by_type_window.py", "tests/test_cross_origin_iframe.py", "tests/test_css_calc_is_windows_e2e.py", "tests/test_cursor_dispatch.py", "tests/test_cursor_wiring.py", "tests/test_docs_name_the_mcp_repo_as_it_is.py", "tests/test_doh_session_prefs_unit.py", "tests/test_drag_motion.py", "tests/test_e2e_hermetic.py", "tests/test_element_handle_actions.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_every_page_draws_its_own_acts.py", "tests/test_every_refusal_is_declared.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_every_suite_runs_on_linux_and_windows.py", "tests/test_expose_binding_refusal.py", "tests/test_fission_identity_parity_e2e.py", "tests/test_fixtures_name_why_the_package_is_missing.py", "tests/test_fork.py", "tests/test_frame_dispatch.py", "tests/test_geoip_used.py", "tests/test_goto_follows_the_base_url.py", "tests/test_hook_wiring.py", "tests/test_imports.py", "tests/test_integration.py", "tests/test_juggler_event_buffer.py", "tests/test_juggler_event_listeners.py", "tests/test_juggler_injected.py", "tests/test_juggler_lives_in_the_core.py", "tests/test_juggler_transport.py", "tests/test_key_delay_reaches_the_keyboard.py", "tests/test_keyboard_rhythm.py", "tests/test_launch_counters_run_on_github.py", "tests/test_launcher_config.py", "tests/test_launcher_helpers.py", "tests/test_math_sin_cos_tan_are_windows_e2e.py", "tests/test_motion_never_hides_a_programming_error.py", "tests/test_navigation_response.py", "tests/test_new_page_defaults.py", "tests/test_no_event_of_any_family_is_lost_by_the_hand_over.py", "tests/test_no_legacy_in_the_wrapper.py", "tests/test_no_override_leaves_the_persona_scheme.py", "tests/test_no_thread_is_started_on_the_reader.py", "tests/test_page_number_follows_the_call.py", "tests/test_persistent_profile_keeps_state.py", "tests/test_pin.py", "tests/test_pin_dicts_are_valid.py", "tests/test_pinning_doc.py", "tests/test_pointer_server.py", "tests/test_popup_adoption_unit.py", "tests/test_prefs_composition_arm.py", "tests/test_prefs_composition_arm_on_windows.py", "tests/test_preload_newtab_is_written_only_when_asked.py", "tests/test_protocol_names_are_declared.py", "tests/test_proLine truncated
|
||||
]
|
||||
@@ -609,8 +609,13 @@ class DohGateway(Gateway):
|
||||
username/password offered, ``first_connection_delay`` holds the first accepted connection that many seconds
|
||||
before it is answered (a gateway that is slow to say hello), and :meth:`kill` makes the gateway dead: the port
|
||||
refuses, and every open tunnel is closed.
|
||||
|
||||
It carries nothing past loopback, so the question of the exit cannot leave through it (``forwards_for_real`` is False: it declares
|
||||
no exit, and the lab leaves that question to the discovery, which this gateway refuses).
|
||||
"""
|
||||
|
||||
forwards_for_real = False
|
||||
|
||||
def __init__(self, name: str, doh: FakeDoh, *, user: Optional[str] = None, password: Optional[str] = None,
|
||||
first_connection_delay: float = 0.0, **gateway: object):
|
||||
# ``gateway`` goes to the base Gateway as it is (``udp="relay"``, ``relay_host``, ``rtt_ms``, ``exit_host``,
|
||||
|
||||
+18
-5
@@ -12,9 +12,15 @@ This module is that declaration, made once per session by the autouse fixture of
|
||||
* the question with NO proxy is answered :data:`LAB_EGRESS_IP`, a public address (so the core does not refuse it as unroutable) that the GeoIP database of
|
||||
the lab (``scripts/ci_lab_geoip.py``: one record for every public address that is not one of its six exits) maps to New York, en-US. The same session
|
||||
as before on every runner, whatever its address and whatever its network;
|
||||
* the question WITH a proxy is left to what answered it before: the local gateways of the tests answer ``api.ipify.org`` themselves
|
||||
(``tests/_socks_servers.py``), and a test that replaces the question (``tests/_udp_line.egress_by_proxy``) does it with ``monkeypatch`` for its own
|
||||
duration, which undoes to this answer and not to the network;
|
||||
* the question WITH a proxy is answered by the proxy of the lab it goes through, never by a service of the internet. The product asks it HTTPS
|
||||
(``https://api.ipify.org`` through the proxy), and no proxy of the tests can answer a TLS request as the service: a proxy that FORWARDS for real
|
||||
(``Socks5TcpOnly``, the gateway of ``tests/_socks_servers.py``, the SOCKS5 server of ``test_proxy_socks_auth_e2e.py``) carried it to the
|
||||
internet, and the launch was told the address of whatever machine ran the test, which on a GitHub runner changed (NAT) in the middle of a session:
|
||||
``ProxyEgressDrifted``. Such a proxy DECLARES its exit (``_socks_servers.declare_exit``) and this module answers with it, with no request at all;
|
||||
as a backstop it refuses to forward the question (``_socks_servers.asks_the_world``), and the autouse fixture ``_no_test_asks_the_world_where_it_leaves_from``
|
||||
of ``conftest.py`` fails the test that made it. A proxy that refuses everything past loopback (the DoH gateways, the HTTP proxy of the tests) cannot
|
||||
carry the question anywhere: it is not declared, and its question goes to the discovery, which it refuses. A test that replaces the question
|
||||
(``tests/_udp_line.egress_by_proxy``) does it with ``monkeypatch`` for its own duration, which undoes to this answer and not to the network;
|
||||
* the database is the lab's too: when ``STEALTHFOX_GEOIP_MMDB`` is not set (a developer's machine; the CI legs set it) it is built here, from the same table
|
||||
and the same bytes, instead of the core asking GitHub which database is the latest.
|
||||
|
||||
@@ -30,6 +36,7 @@ from pathlib import Path
|
||||
from typing import Any, Callable, Dict, List, Optional
|
||||
|
||||
from _servers import LocalServer
|
||||
from _socks_servers import declared_exit_of
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
@@ -44,7 +51,9 @@ LAB_EGRESS_IP = _address(8, 8, 8, 8)
|
||||
|
||||
|
||||
class DeclaredExit:
|
||||
"""The replacement of ``discover_egress_ip``: counts the questions it answers, and passes a proxied one on to what answered it before."""
|
||||
"""The replacement of ``discover_egress_ip``: counts the questions it answers. A question with no proxy is answered :attr:`ip`; one behind a proxy
|
||||
that forwards for real is answered the exit that proxy declared (``_socks_servers.declare_exit``); one behind a proxy that declared nothing (a
|
||||
proxy that refuses the world) is passed on to what answered it before."""
|
||||
|
||||
def __init__(self, original: Callable[..., str], ip: str = LAB_EGRESS_IP) -> None:
|
||||
self.original = original
|
||||
@@ -56,7 +65,11 @@ class DeclaredExit:
|
||||
if not proxy:
|
||||
self.direct_questions += 1
|
||||
return self.ip
|
||||
self.proxied_questions.append(proxy.get("server") if isinstance(proxy, dict) else proxy)
|
||||
server = proxy.get("server") if isinstance(proxy, dict) else proxy
|
||||
self.proxied_questions.append(server)
|
||||
declared = declared_exit_of(server)
|
||||
if declared is not None:
|
||||
return declared
|
||||
return self.original(proxy, *args, **kwargs)
|
||||
|
||||
|
||||
|
||||
+91
-5
@@ -26,9 +26,11 @@ documentation NUMBER of its own, so the datagrams of the measurement are told ap
|
||||
``STUN_NUMBER``). The measurement is a UDP ASSOCIATE of its own: :attr:`Gateway.associates` and :attr:`Gateway.datagrams` count it.
|
||||
|
||||
Everything is on loopback, so the "exit address" is made observable and
|
||||
controllable instead of real: the TCP exit is what the gateway's fake "what is
|
||||
my address" endpoint (``api.ipify.org:80``, the one the product asks) answers,
|
||||
and the UDP exit is what the fake STUN server puts in its XOR-MAPPED-ADDRESS.
|
||||
controllable instead of real: the TCP exit is what the gateway declares
|
||||
(``declare_exit``) and the lab answers when the product asks "what is my address"
|
||||
through it (``tests/_lab_egress.py``; the product asks HTTPS, which no gateway can
|
||||
answer as the service; the plain-HTTP endpoint ``api.ipify.org:80`` is still
|
||||
answered here for the tests that ask it), and the UDP exit is what the fake STUN server puts in its XOR-MAPPED-ADDRESS.
|
||||
Both are chosen by the test (``tcp_exit`` and ``udp_exit`` arguments).
|
||||
|
||||
Any other CONNECT is really forwarded, and any other UDP datagram is really
|
||||
@@ -50,7 +52,7 @@ import socket
|
||||
import struct
|
||||
import threading
|
||||
import time
|
||||
from typing import Callable, List, Optional, Set, Tuple
|
||||
from typing import Callable, Dict, List, Optional, Set, Tuple
|
||||
|
||||
#: The name the product's STUN probe sends through the relay. The relay maps it
|
||||
#: to the fake STUN server; every other destination is forwarded for real.
|
||||
@@ -76,6 +78,67 @@ WHOAMI6 = ("api6.ipify.org", 80)
|
||||
_MAGIC = b"\x21\x12\xa4\x42"
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------
|
||||
# The exit of a proxy that forwards for real. The question "where do I leave from" is HTTPS (api.ipify.org:443), and no gateway
|
||||
# of the tests can answer a TLS request as the service: a proxy that FORWARDS (a CONNECT to anything outside loopback goes out for
|
||||
# real) would carry it to the internet, and the answer would be the address of whatever machine runs the test (a GitHub runner
|
||||
# that changes NAT in the middle of a session: ``ProxyEgressDrifted``). So such a proxy DECLARES its exit (``declare_exit``) and
|
||||
# ``tests/_lab_egress.DeclaredExit`` answers the question with it; and as a backstop each of them refuses to forward the question
|
||||
# (``asks_the_world``), which records it and makes the test fail (``nobody_asked_the_world``), so that a proxy that forgot to declare
|
||||
# is a red with its name and not a flaky green.
|
||||
# ----------------------------------------------------------------------------------------------------------------
|
||||
#: The hosts of the services of the core that tell a caller its address (``invisible_core._geo._IP_ECHO_ENDPOINTS`` and
|
||||
#: ``_IPV6_ECHO_ENDPOINTS``; ``tests/test_a_launch_asks_nobody_on_the_internet_where_it_leaves_from.py`` checks that this list covers them).
|
||||
EXIT_SERVICES = ("api.ipify.org", "api6.ipify.org", "icanhazip.com", "ipv6.icanhazip.com", "checkip.amazonaws.com", "ifconfig.me")
|
||||
|
||||
#: ``host:port`` of a proxy of the tests that forwards for real -> the exit it declares. Filled by the proxies themselves.
|
||||
_DECLARED_EXITS: Dict[str, str] = {}
|
||||
#: The questions of the exit that reached a forwarding proxy and were refused there: one sentence each, until a test reads them.
|
||||
_WORLD_QUESTIONS: List[str] = []
|
||||
|
||||
|
||||
def _endpoint(server: str) -> str:
|
||||
"""``host:port`` of a proxy given as ``scheme://host:port`` (or as ``host:port``)."""
|
||||
return server.split("://", 1)[-1].rsplit("@", 1)[-1].rstrip("/")
|
||||
|
||||
|
||||
def declare_exit(server: str, exit_ip: str) -> None:
|
||||
"""The proxy at ``server`` forwards for real and says its exit is ``exit_ip``."""
|
||||
_DECLARED_EXITS[_endpoint(server)] = exit_ip
|
||||
|
||||
|
||||
def forget_exit(server: str) -> None:
|
||||
_DECLARED_EXITS.pop(_endpoint(server), None)
|
||||
|
||||
|
||||
def declared_exit_of(server: Optional[str]) -> Optional[str]:
|
||||
"""The exit a forwarding proxy of the tests declared, or None for any other proxy (one that refuses the world, or not a proxy of ours)."""
|
||||
return _DECLARED_EXITS.get(_endpoint(server)) if server else None
|
||||
|
||||
|
||||
def asks_the_world(server: str, host: str, port: int) -> bool:
|
||||
"""True, and the question is recorded, when a CONNECT to ``host:port`` is the question of the exit: the proxy must refuse it, not forward it."""
|
||||
if host.lower() not in EXIT_SERVICES:
|
||||
return False
|
||||
_WORLD_QUESTIONS.append("%s was asked %s:%d: the question of the exit reached a proxy that would have forwarded it to the internet" % (
|
||||
server, host, port))
|
||||
return True
|
||||
|
||||
|
||||
def nobody_asked_the_world() -> List[str]:
|
||||
"""The questions of the exit refused since the last call (and forgets them): empty when every one was answered by the lab."""
|
||||
asked = list(_WORLD_QUESTIONS)
|
||||
del _WORLD_QUESTIONS[:]
|
||||
return asked
|
||||
|
||||
|
||||
def _lab_exit() -> str:
|
||||
"""The exit of the lab (``tests/_lab_egress.LAB_EGRESS_IP``), imported when asked."""
|
||||
from _lab_egress import LAB_EGRESS_IP
|
||||
|
||||
return LAB_EGRESS_IP
|
||||
|
||||
|
||||
def _recv_exact(s: socket.socket, n: int) -> bytes:
|
||||
data = b""
|
||||
while len(data) < n:
|
||||
@@ -152,6 +215,11 @@ class FakeStun:
|
||||
class Gateway:
|
||||
"""A SOCKS5 server. ``udp`` is ``"relay"`` or ``"refuse"`` (reply code 7)."""
|
||||
|
||||
#: Whether a CONNECT that is not special is forwarded for real, past loopback: such a gateway declares ``tcp_exit`` as its exit
|
||||
#: (``declare_exit``). A subclass that refuses everything but loopback (``tests/_doh_servers.DohGateway``) sets False: it cannot carry the
|
||||
#: question of the exit anywhere, and the question is left to what answers it.
|
||||
forwards_for_real = True
|
||||
|
||||
def __init__(self, *, udp: str, tcp_exit: str, udp_exit: str,
|
||||
user: Optional[str] = None, password: Optional[str] = None,
|
||||
relay_host: str = "127.0.0.1", rtt_ms: int = 0,
|
||||
@@ -228,6 +296,8 @@ class Gateway:
|
||||
self._listener.listen(32)
|
||||
self.port: int = self._listener.getsockname()[1]
|
||||
self._closed = False
|
||||
if self.forwards_for_real:
|
||||
declare_exit(self.server, tcp_exit)
|
||||
threading.Thread(target=self._accept, daemon=True).start()
|
||||
|
||||
# --- what the test hands to the product ---------------------------------
|
||||
@@ -253,6 +323,7 @@ class Gateway:
|
||||
|
||||
def close(self) -> None:
|
||||
self._closed = True
|
||||
forget_exit(self.server)
|
||||
for s in (self._listener,):
|
||||
try:
|
||||
s.close()
|
||||
@@ -404,6 +475,9 @@ class Gateway:
|
||||
self._send(c, b"HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: %d\r\n"
|
||||
b"Connection: close\r\n\r\n%s" % (len(body), body))
|
||||
return
|
||||
if self.forwards_for_real and asks_the_world(self.server, host, port):
|
||||
self._send(c, self._reply(2)) # not allowed: the exit of this gateway is declared, it is not asked of the internet
|
||||
return
|
||||
try:
|
||||
up = self._open_upstream(self._target(host, port))
|
||||
except OSError:
|
||||
@@ -619,17 +693,24 @@ class Socks5TcpOnly:
|
||||
candidates before Fix C.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, exit_ip: Optional[str] = None):
|
||||
self._srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self._srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
self._srv.bind(("127.0.0.1", 0))
|
||||
self._srv.listen(16)
|
||||
self.port = self._srv.getsockname()[1]
|
||||
#: It relays a CONNECT for real, so it declares its exit (what a launch behind it is told: the lab's, unless a test gives another).
|
||||
self.exit_ip = exit_ip or _lab_exit()
|
||||
declare_exit(self.server, self.exit_ip)
|
||||
self.udp_associate_attempts = 0
|
||||
self._stop = False
|
||||
self._t = threading.Thread(target=self._serve, daemon=True)
|
||||
self._t.start()
|
||||
|
||||
@property
|
||||
def server(self) -> str:
|
||||
return "socks5://127.0.0.1:%d" % self.port
|
||||
|
||||
def _serve(self):
|
||||
while not self._stop:
|
||||
try:
|
||||
@@ -677,6 +758,10 @@ class Socks5TcpOnly:
|
||||
conn.sendall(b"\x05\x07\x00\x01\x00\x00\x00\x00\x00\x00") # cmd not supported
|
||||
conn.close()
|
||||
return
|
||||
if asks_the_world(self.server, addr, port):
|
||||
conn.sendall(b"\x05\x02\x00\x01\x00\x00\x00\x00\x00\x00") # not allowed: the exit is declared, not asked of the internet
|
||||
conn.close()
|
||||
return
|
||||
try:
|
||||
upstream = socket.create_connection((addr, port), timeout=30)
|
||||
except OSError:
|
||||
@@ -711,6 +796,7 @@ class Socks5TcpOnly:
|
||||
|
||||
def close(self):
|
||||
self._stop = True
|
||||
forget_exit(self.server)
|
||||
try:
|
||||
self._srv.close()
|
||||
except Exception:
|
||||
|
||||
@@ -224,6 +224,23 @@ def _the_lab_declares_the_exit(request, tmp_path_factory):
|
||||
yield _lab_egress.install(patch, tmp_path_factory.mktemp("lab-geoip"))
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _no_test_asks_the_world_where_it_leaves_from():
|
||||
"""A test fails when the question of the exit reached a proxy of the tests that forwards for real.
|
||||
|
||||
The product asks "where do I leave from" through the proxy of a launch, HTTPS, to api.ipify.org and its siblings. A proxy of the tests that forwards
|
||||
for real would have carried it to the internet, and the answer is the address of the machine that runs the test: it changes on a runner, in the
|
||||
middle of a session (``ProxyEgressDrifted``). Each such proxy declares its exit and the lab answers with it (``tests/_lab_egress.py``); one that
|
||||
was not declared, or a test that bypassed the lab, makes the proxy REFUSE the question (``_socks_servers.asks_the_world``), and this fixture turns
|
||||
that into a failure with the name of the proxy and of the service, instead of a launch that works until the network of the runner changes."""
|
||||
import _socks_servers
|
||||
|
||||
yield
|
||||
asked = _socks_servers.nobody_asked_the_world()
|
||||
if asked:
|
||||
pytest.fail("the question of the exit went toward the internet: " + "; ".join(asked), pytrace=False)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def local_egress_echo(monkeypatch):
|
||||
"""The REAL discovery of the exit, for the test that must prove it, against an echo service of its own on loopback: the three services of the
|
||||
|
||||
@@ -152,3 +152,159 @@ def test_the_conftest_declares_the_exit_for_the_whole_session_and_before_any_mod
|
||||
"the exit of the lab is declared by an autouse fixture of SESSION scope (a module-scoped browser is launched before any function-scoped one): %r"
|
||||
% (declaration,))
|
||||
assert fixtures["browser"].get("scope") == "module", "the conftest's module browser is the reason for the scope above"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------------------------------------------
|
||||
# The question WITH a proxy. The product asks it HTTPS (api.ipify.org:443 THROUGH the proxy), which no gateway of the tests can answer as the
|
||||
# service; a proxy of the tests that forwards for real carried it to the internet and the launch was told the address of the machine that runs
|
||||
# the test (a GitHub runner whose NAT changed in the middle of a session: ProxyEgressDrifted: the address seen at launch and the one seen later differed). A proxy that forwards
|
||||
# for real DECLARES its exit and the lab answers with it; the proxies of the tests are the only roads out of the test process in these tests, so
|
||||
# a question that reached one of them without being declared is refused there and fails the test.
|
||||
# ---------------------------------------------------------------------------------------------------------------------------------------
|
||||
LEFT = "left the machine"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def what_would_leave(monkeypatch):
|
||||
"""The CONNECTs a proxy of the tests would have made past loopback, with the internet closed: ``socket.create_connection`` is what every
|
||||
forwarding proxy of the tests uses to open its upstream. The list is what a runner would have sent to a service of the internet."""
|
||||
left = []
|
||||
real = socket.create_connection
|
||||
|
||||
def spy(address, *args, **kwargs):
|
||||
host, port = address[0], address[1]
|
||||
if host in ("127.0.0.1", "localhost"):
|
||||
return real(address, *args, **kwargs)
|
||||
left.append("%s:%d" % (host, port))
|
||||
raise OSError("%s %s:%d: the internet is closed in this test" % (LEFT, host, port))
|
||||
|
||||
monkeypatch.setattr(socket, "create_connection", spy)
|
||||
return left
|
||||
|
||||
|
||||
def _socks5_tcp_only():
|
||||
from _socks_servers import Socks5TcpOnly
|
||||
|
||||
proxy = Socks5TcpOnly()
|
||||
return proxy, {"server": "socks5://127.0.0.1:%d" % proxy.port}, _lab_egress.LAB_EGRESS_IP
|
||||
|
||||
|
||||
def _socks5_with_credentials():
|
||||
# the proxy of tests/test_proxy_socks_auth_e2e.py (a file of the e2e: the class is the one that e2e test launches behind)
|
||||
from test_proxy_socks_auth_e2e import _PASS, _USER, _Socks5AuthRecorder
|
||||
|
||||
proxy = _Socks5AuthRecorder()
|
||||
return proxy, {"server": "socks5://127.0.0.1:%d" % proxy.port, "username": _USER, "password": _PASS}, _lab_egress.LAB_EGRESS_IP
|
||||
|
||||
|
||||
def _gateway_that_forwards():
|
||||
from _socks_servers import EXIT, coherent
|
||||
|
||||
gateway = coherent()
|
||||
return gateway, gateway.proxy, EXIT
|
||||
|
||||
|
||||
FORWARDING_PROXIES = [
|
||||
pytest.param(_socks5_tcp_only, id="Socks5TcpOnly"),
|
||||
pytest.param(_socks5_with_credentials, id="Socks5AuthRecorder"),
|
||||
pytest.param(_gateway_that_forwards, id="Gateway"),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("make", FORWARDING_PROXIES)
|
||||
def test_the_question_behind_a_proxy_that_forwards_never_reaches_the_internet(make, what_would_leave):
|
||||
"""THE RED OF THE RUNNER: the lab declares the exit of a launch behind a proxy of the tests with ``DeclaredExit`` over the REAL discovery. Until
|
||||
the proxy declared its exit, the proxied question went to the real function and from it through the proxy to api.ipify.org:443."""
|
||||
from invisible_core import _geo
|
||||
|
||||
proxy, endpoint, exit_ip = make()
|
||||
try:
|
||||
declared = _lab_egress.DeclaredExit(_geo.discover_egress_ip)
|
||||
try:
|
||||
answer = declared(endpoint, timeout=3, budget=6)
|
||||
except Exception as error: # the closed internet makes the real function fail: what it SENT is the verdict
|
||||
answer = error
|
||||
finally:
|
||||
proxy.close()
|
||||
assert what_would_leave == [], "the question of the exit was carried to the internet through %s: %s" % (endpoint["server"], what_would_leave)
|
||||
assert answer == exit_ip, "the proxy declares its exit and the lab answers it: %r" % (answer,)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("make", FORWARDING_PROXIES)
|
||||
def test_a_forwarding_proxy_refuses_the_question_it_was_not_declared_for_and_the_test_fails(make, what_would_leave):
|
||||
"""The backstop: the REAL discovery, not behind ``DeclaredExit`` (a test that replaced the question, a launch that does not go through it).
|
||||
The proxy refuses to forward the question, names it, and ``nobody_asked_the_world`` (which the autouse fixture of the conftest reads after every
|
||||
test) hands it over once."""
|
||||
import _socks_servers
|
||||
from invisible_core import _geo
|
||||
|
||||
_socks_servers.nobody_asked_the_world()
|
||||
proxy, endpoint, _exit = make()
|
||||
try:
|
||||
with pytest.raises(Exception):
|
||||
_geo.discover_egress_ip(endpoint, timeout=3, budget=6)
|
||||
finally:
|
||||
proxy.close()
|
||||
asked = _socks_servers.nobody_asked_the_world()
|
||||
assert what_would_leave == [], "a proxy of the tests forwarded the question of the exit: %s" % what_would_leave
|
||||
assert asked and all(endpoint["server"].split("://", 1)[1] in line and ":443" in line for line in asked), asked
|
||||
assert _socks_servers.nobody_asked_the_world() == [], "the questions are handed over once"
|
||||
|
||||
|
||||
def test_a_proxy_that_refuses_the_world_keeps_its_question_for_what_answered_it_before():
|
||||
"""A gateway that refuses everything past loopback (the DoH family, the HTTP proxy) cannot carry the question anywhere: it is not declared, and the
|
||||
lab leaves the question to the discovery, which the proxy refuses, as before."""
|
||||
from _doh_servers import DohGateway, FakeDoh
|
||||
|
||||
asked = []
|
||||
|
||||
def before(proxy=None, *args, **kwargs):
|
||||
asked.append(proxy["server"])
|
||||
return "203.0.113.9"
|
||||
|
||||
with FakeDoh({}) as doh, DohGateway("closed", doh) as gateway:
|
||||
assert _lab_egress.DeclaredExit(before)(gateway.proxy) == "203.0.113.9" and asked == [gateway.server]
|
||||
|
||||
|
||||
def test_a_declared_exit_is_answered_without_asking_anyone_and_is_forgotten_with_the_proxy():
|
||||
import _socks_servers
|
||||
|
||||
asked = []
|
||||
|
||||
def before(proxy=None, *args, **kwargs):
|
||||
asked.append(proxy)
|
||||
return "203.0.113.9"
|
||||
|
||||
exit_ = _lab_egress.DeclaredExit(before)
|
||||
_socks_servers.declare_exit("socks5://127.0.0.1:61999", "198.51.100.77")
|
||||
try:
|
||||
assert exit_({"server": "socks5://127.0.0.1:61999"}) == "198.51.100.77"
|
||||
assert exit_({"server": "http://user:pw@127.0.0.1:61999"}) == "198.51.100.77", "the scheme and the credentials are not the identity of a proxy"
|
||||
assert asked == [] and len(exit_.proxied_questions) == 2
|
||||
finally:
|
||||
_socks_servers.forget_exit("socks5://127.0.0.1:61999")
|
||||
assert exit_({"server": "socks5://127.0.0.1:61999"}) == "203.0.113.9" and len(asked) == 1
|
||||
|
||||
|
||||
def test_the_services_a_proxy_refuses_are_the_services_of_the_core():
|
||||
"""The list the proxies refuse (``_socks_servers.EXIT_SERVICES``) covers every host the core asks: a service added to the core without it is red here."""
|
||||
from urllib.parse import urlsplit
|
||||
|
||||
import _socks_servers
|
||||
from invisible_core import _geo
|
||||
|
||||
hosts = {urlsplit(url).hostname for url in tuple(_geo._IP_ECHO_ENDPOINTS) + tuple(_geo._IPV6_ECHO_ENDPOINTS)}
|
||||
assert hosts <= set(_socks_servers.EXIT_SERVICES), sorted(hosts - set(_socks_servers.EXIT_SERVICES))
|
||||
|
||||
|
||||
def test_the_conftest_fails_every_test_after_which_the_world_was_asked():
|
||||
tree = ast.parse((TESTS / "conftest.py").read_text(encoding="utf-8"))
|
||||
found = {}
|
||||
for node in tree.body:
|
||||
if isinstance(node, ast.FunctionDef):
|
||||
for decorator in node.decorator_list:
|
||||
if isinstance(decorator, ast.Call) and getattr(decorator.func, "attr", "") == "fixture":
|
||||
found[node.name] = ({kw.arg: getattr(kw.value, "value", None) for kw in decorator.keywords}, ast.unparse(node))
|
||||
guard = found.get("_no_test_asks_the_world_where_it_leaves_from")
|
||||
assert guard is not None and guard[0] == {"autouse": True}, "an autouse fixture reads the questions of the world after every test: %r" % (guard and guard[0],)
|
||||
assert "nobody_asked_the_world" in guard[1] and "pytest.fail" in guard[1], "and fails the test when there are any"
|
||||
@@ -22,6 +22,7 @@ import pytest
|
||||
from invisible_playwright import InvisiblePlaywright
|
||||
|
||||
from _servers import LocalServer
|
||||
from _socks_servers import asks_the_world, declare_exit, forget_exit
|
||||
|
||||
_USER = "ferd_socks_user"
|
||||
_PASS = "ferd_socks_pw_42"
|
||||
@@ -37,10 +38,19 @@ class _Socks5AuthRecorder:
|
||||
self._srv.bind(("127.0.0.1", 0))
|
||||
self._srv.listen(16)
|
||||
self.port = self._srv.getsockname()[1]
|
||||
# It relays a CONNECT for real, so it declares its exit: the launch behind it is told the lab's, not the address of the machine
|
||||
# that runs the test (see tests/_lab_egress.py).
|
||||
from _lab_egress import LAB_EGRESS_IP
|
||||
|
||||
declare_exit(self.server, LAB_EGRESS_IP)
|
||||
self.seen_creds: list[tuple[str, str]] = []
|
||||
self._stop = False
|
||||
threading.Thread(target=self._serve, daemon=True).start()
|
||||
|
||||
@property
|
||||
def server(self) -> str:
|
||||
return f"socks5://127.0.0.1:{self.port}"
|
||||
|
||||
def _serve(self):
|
||||
while not self._stop:
|
||||
try:
|
||||
@@ -90,6 +100,8 @@ class _Socks5AuthRecorder:
|
||||
port = struct.unpack("!H", self._recv(conn, 2))[0]
|
||||
if cmd != 0x01: # only CONNECT
|
||||
conn.sendall(b"\x05\x07\x00\x01\x00\x00\x00\x00\x00\x00"); conn.close(); return
|
||||
if asks_the_world(self.server, addr, port): # the exit is declared above, not asked of the internet
|
||||
conn.sendall(b"\x05\x02\x00\x01\x00\x00\x00\x00\x00\x00"); conn.close(); return
|
||||
try:
|
||||
up = socket.create_connection((addr, port), timeout=30)
|
||||
except OSError:
|
||||
@@ -123,6 +135,7 @@ class _Socks5AuthRecorder:
|
||||
|
||||
def close(self):
|
||||
self._stop = True
|
||||
forget_exit(self.server)
|
||||
try:
|
||||
self._srv.close()
|
||||
except OSError:
|
||||
|
||||
Reference in new issue
Block a user