From 8815c27cd37f568e7d8f4e69348f4a422698a258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boni=20Garc=C3=ADa?= Date: Mon, 30 Jan 2023 10:18:55 +0100 Subject: [PATCH] [rust] Support for web proxy in Selenium Manager (#11575) * [rust] Support for web proxy in Selenium Manager * [rust] Include CLI tests for web proxy * [rust] Include flag for network requests timeout (30 seconds by default) * [rust] Check parse error in fallback for chromedriver * [rust] Increase default request timeout to 60 seconds * [rust] Increase request timeout to 120 seconds * [rust] Improve proxy and timeout tests * [rust] Include --clear-cache and --debug in timeout test * [rust] Include test using mock proxy --- rust/Cargo.Bazel.lock | 1367 ++++++++++++++++++++++++++++++++++- rust/Cargo.lock | 257 ++++++- rust/Cargo.toml | 3 +- rust/README.md | 6 +- rust/src/chrome.rs | 14 +- rust/src/config.rs | 7 + rust/src/edge.rs | 4 + rust/src/files.rs | 3 +- rust/src/firefox.rs | 4 + rust/src/iexplorer.rs | 4 + rust/src/lib.rs | 80 +- rust/src/main.rs | 25 +- rust/tests/output_tests.rs | 2 +- rust/tests/proxy_tests.rs | 55 ++ rust/tests/timeout_tests.rs | 36 + 15 files changed, 1823 insertions(+), 44 deletions(-) create mode 100644 rust/tests/proxy_tests.rs create mode 100644 rust/tests/timeout_tests.rs diff --git a/rust/Cargo.Bazel.lock b/rust/Cargo.Bazel.lock index 209855e71e3d6..b2f43fedf5eaa 100644 --- a/rust/Cargo.Bazel.lock +++ b/rust/Cargo.Bazel.lock @@ -1,5 +1,5 @@ { - "checksum": "17a3d42d3eebdf25a24ac0e2ec7215f03a1f6c281abe8c491d0026247b1e6782", + "checksum": "cfb8c431183818c041b63dcfc880980393ff487769338055bc00a99b75ae4ffa", "crates": { "adler 1.0.2": { "name": "adler", @@ -137,6 +137,115 @@ }, "license": "Unlicense OR MIT" }, + "anyhow 1.0.68": { + "name": "anyhow", + "version": "1.0.68", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/anyhow/1.0.68/download", + "sha256": "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" + } + }, + "targets": [ + { + "Library": { + "crate_name": "anyhow", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "anyhow", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "default", + "std" + ], + "deps": { + "common": [ + { + "id": "anyhow 1.0.68", + "target": "build_script_build" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "1.0.68" + }, + "build_script_attrs": { + "data_glob": [ + "**" + ] + }, + "license": "MIT OR Apache-2.0" + }, + "assert-json-diff 2.0.2": { + "name": "assert-json-diff", + "version": "2.0.2", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/assert-json-diff/2.0.2/download", + "sha256": "47e4f2b81832e72834d7518d8487a0396a28cc408186a2e8854c0f98011faf12" + } + }, + "targets": [ + { + "Library": { + "crate_name": "assert_json_diff", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "assert_json_diff", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "serde 1.0.152", + "target": "serde" + }, + { + "id": "serde_json 1.0.91", + "target": "serde_json" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "2.0.2" + }, + "license": "MIT" + }, "assert_cmd 2.0.8": { "name": "assert_cmd", "version": "2.0.8", @@ -211,6 +320,127 @@ }, "license": "MIT OR Apache-2.0" }, + "async-channel 1.8.0": { + "name": "async-channel", + "version": "1.8.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/async-channel/1.8.0/download", + "sha256": "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" + } + }, + "targets": [ + { + "Library": { + "crate_name": "async_channel", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "async_channel", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "concurrent-queue 2.1.0", + "target": "concurrent_queue" + }, + { + "id": "event-listener 2.5.3", + "target": "event_listener" + }, + { + "id": "futures-core 0.3.25", + "target": "futures_core" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "1.8.0" + }, + "license": "Apache-2.0 OR MIT" + }, + "async-trait 0.1.63": { + "name": "async-trait", + "version": "0.1.63", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/async-trait/0.1.63/download", + "sha256": "eff18d764974428cf3a9328e23fc5c986f5fbed46e6cd4cdf42544df5d297ec1" + } + }, + "targets": [ + { + "ProcMacro": { + "crate_name": "async_trait", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "async_trait", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "async-trait 0.1.63", + "target": "build_script_build" + }, + { + "id": "proc-macro2 1.0.50", + "target": "proc_macro2" + }, + { + "id": "quote 1.0.23", + "target": "quote" + }, + { + "id": "syn 1.0.107", + "target": "syn" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "0.1.63" + }, + "build_script_attrs": { + "data_glob": [ + "**" + ] + }, + "license": "MIT OR Apache-2.0" + }, "autocfg 1.1.0": { "name": "autocfg", "version": "1.1.0", @@ -244,6 +474,43 @@ }, "license": "Apache-2.0 OR MIT" }, + "base64 0.13.1": { + "name": "base64", + "version": "0.13.1", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/base64/0.13.1/download", + "sha256": "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + } + }, + "targets": [ + { + "Library": { + "crate_name": "base64", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "base64", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "default", + "std" + ], + "edition": "2018", + "version": "0.13.1" + }, + "license": "MIT/Apache-2.0" + }, "base64 0.21.0": { "name": "base64", "version": "0.21.0", @@ -868,13 +1135,13 @@ }, "license": "MIT OR Apache-2.0" }, - "clap 4.1.1": { + "clap 4.1.3": { "name": "clap", - "version": "4.1.1", + "version": "4.1.3", "repository": { "Http": { - "url": "https://crates.io/api/v1/crates/clap/4.1.1/download", - "sha256": "4ec7a4128863c188deefe750ac1d1dfe66c236909f845af04beed823638dc1b2" + "url": "https://crates.io/api/v1/crates/clap/4.1.3/download", + "sha256": "d8d93d855ce6a0aa87b8473ef9169482f40abaa2e9e0993024c35c902cbd5920" } }, "targets": [ @@ -957,7 +1224,7 @@ ], "selects": {} }, - "version": "4.1.1" + "version": "4.1.3" }, "license": "MIT OR Apache-2.0" }, @@ -1064,6 +1331,52 @@ }, "license": "MIT OR Apache-2.0" }, + "concurrent-queue 2.1.0": { + "name": "concurrent-queue", + "version": "2.1.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/concurrent-queue/2.1.0/download", + "sha256": "c278839b831783b70278b14df4d45e1beb1aad306c07bb796637de9a0e323e8e" + } + }, + "targets": [ + { + "Library": { + "crate_name": "concurrent_queue", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "concurrent_queue", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "default", + "std" + ], + "deps": { + "common": [ + { + "id": "crossbeam-utils 0.8.14", + "target": "crossbeam_utils" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "2.1.0" + }, + "license": "Apache-2.0 OR MIT" + }, "constant_time_eq 0.1.5": { "name": "constant_time_eq", "version": "0.1.5", @@ -1332,9 +1645,111 @@ "selects": {} }, "edition": "2018", - "version": "0.1.6" + "version": "0.1.6" + }, + "license": "MIT OR Apache-2.0" + }, + "deadpool 0.9.5": { + "name": "deadpool", + "version": "0.9.5", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/deadpool/0.9.5/download", + "sha256": "421fe0f90f2ab22016f32a9881be5134fdd71c65298917084b0c7477cbc3856e" + } + }, + "targets": [ + { + "Library": { + "crate_name": "deadpool", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "deadpool", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "async-trait", + "default", + "managed", + "unmanaged" + ], + "deps": { + "common": [ + { + "id": "deadpool-runtime 0.1.2", + "target": "deadpool_runtime" + }, + { + "id": "num_cpus 1.15.0", + "target": "num_cpus" + }, + { + "id": "retain_mut 0.1.9", + "target": "retain_mut" + }, + { + "id": "tokio 1.24.2", + "target": "tokio" + } + ], + "selects": {} + }, + "edition": "2018", + "proc_macro_deps": { + "common": [ + { + "id": "async-trait 0.1.63", + "target": "async_trait" + } + ], + "selects": {} + }, + "version": "0.9.5" + }, + "license": "MIT/Apache-2.0" + }, + "deadpool-runtime 0.1.2": { + "name": "deadpool-runtime", + "version": "0.1.2", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/deadpool-runtime/0.1.2/download", + "sha256": "eaa37046cc0f6c3cc6090fbdbf73ef0b8ef4cfcc37f6befc0020f63e8cf121e1" + } + }, + "targets": [ + { + "Library": { + "crate_name": "deadpool_runtime", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "deadpool_runtime", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2018", + "version": "0.1.2" }, - "license": "MIT OR Apache-2.0" + "license": "MIT/Apache-2.0" }, "difflib 0.4.0": { "name": "difflib", @@ -1893,6 +2308,39 @@ }, "license": "MIT" }, + "event-listener 2.5.3": { + "name": "event-listener", + "version": "2.5.3", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/event-listener/2.5.3/download", + "sha256": "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + } + }, + "targets": [ + { + "Library": { + "crate_name": "event_listener", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "event_listener", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2018", + "version": "2.5.3" + }, + "license": "Apache-2.0 OR MIT" + }, "exitcode 1.1.2": { "name": "exitcode", "version": "1.1.2", @@ -2462,6 +2910,7 @@ "**" ], "crate_features": [ + "default", "std" ], "edition": "2018", @@ -2469,6 +2918,82 @@ }, "license": "MIT OR Apache-2.0" }, + "futures-lite 1.12.0": { + "name": "futures-lite", + "version": "1.12.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/futures-lite/1.12.0/download", + "sha256": "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" + } + }, + "targets": [ + { + "Library": { + "crate_name": "futures_lite", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "futures_lite", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "alloc", + "default", + "fastrand", + "futures-io", + "memchr", + "parking", + "std", + "waker-fn" + ], + "deps": { + "common": [ + { + "id": "fastrand 1.8.0", + "target": "fastrand" + }, + { + "id": "futures-core 0.3.25", + "target": "futures_core" + }, + { + "id": "futures-io 0.3.25", + "target": "futures_io" + }, + { + "id": "memchr 2.5.0", + "target": "memchr" + }, + { + "id": "parking 2.0.0", + "target": "parking" + }, + { + "id": "pin-project-lite 0.2.9", + "target": "pin_project_lite" + }, + { + "id": "waker-fn 1.1.0", + "target": "waker_fn" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "1.12.0" + }, + "license": "Apache-2.0 OR MIT" + }, "futures-macro 0.3.25": { "name": "futures-macro", "version": "0.3.25", @@ -2847,6 +3372,85 @@ }, "license": "MIT" }, + "getrandom 0.1.16": { + "name": "getrandom", + "version": "0.1.16", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/getrandom/0.1.16/download", + "sha256": "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" + } + }, + "targets": [ + { + "Library": { + "crate_name": "getrandom", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "getrandom", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "std" + ], + "deps": { + "common": [ + { + "id": "cfg-if 1.0.0", + "target": "cfg_if" + }, + { + "id": "getrandom 0.1.16", + "target": "build_script_build" + } + ], + "selects": { + "cfg(target_os = \"wasi\")": [ + { + "id": "wasi 0.9.0+wasi-snapshot-preview1", + "target": "wasi" + } + ], + "cfg(unix)": [ + { + "id": "libc 0.2.139", + "target": "libc" + } + ] + } + }, + "edition": "2018", + "version": "0.1.16" + }, + "build_script_attrs": { + "data_glob": [ + "**" + ] + }, + "license": "MIT OR Apache-2.0" + }, "getrandom 0.2.8": { "name": "getrandom", "version": "0.2.8", @@ -3247,7 +3851,122 @@ "edition": "2018", "version": "0.4.5" }, - "license": "MIT" + "license": "MIT" + }, + "http-types 2.12.0": { + "name": "http-types", + "version": "2.12.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/http-types/2.12.0/download", + "sha256": "6e9b187a72d63adbfba487f48095306ac823049cb504ee195541e91c7775f5ad" + } + }, + "targets": [ + { + "Library": { + "crate_name": "http_types", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "http_types", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "http", + "hyperium_http" + ], + "deps": { + "common": [ + { + "id": "anyhow 1.0.68", + "target": "anyhow" + }, + { + "id": "async-channel 1.8.0", + "target": "async_channel" + }, + { + "id": "base64 0.13.1", + "target": "base64" + }, + { + "id": "futures-lite 1.12.0", + "target": "futures_lite" + }, + { + "id": "http 0.2.8", + "target": "http" + }, + { + "id": "http-types 2.12.0", + "target": "build_script_build" + }, + { + "id": "infer 0.2.3", + "target": "infer" + }, + { + "id": "pin-project-lite 0.2.9", + "target": "pin_project_lite" + }, + { + "id": "rand 0.7.3", + "target": "rand" + }, + { + "id": "serde 1.0.152", + "target": "serde" + }, + { + "id": "serde_json 1.0.91", + "target": "serde_json" + }, + { + "id": "serde_qs 0.8.5", + "target": "serde_qs" + }, + { + "id": "serde_urlencoded 0.7.1", + "target": "serde_urlencoded" + }, + { + "id": "url 2.3.1", + "target": "url" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "2.12.0" + }, + "build_script_attrs": { + "data_glob": [ + "**" + ] + }, + "license": "MIT OR Apache-2.0" }, "httparse 1.8.0": { "name": "httparse", @@ -3408,11 +4127,15 @@ ], "crate_features": [ "client", + "default", + "full", "h2", "http1", "http2", "runtime", + "server", "socket2", + "stream", "tcp" ], "deps": { @@ -3716,6 +4439,39 @@ }, "license": "MIT" }, + "infer 0.2.3": { + "name": "infer", + "version": "0.2.3", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/infer/0.2.3/download", + "sha256": "64e9829a50b42bb782c1df523f78d332fe371b10c661e78b7a3c34b0198e9fac" + } + }, + "targets": [ + { + "Library": { + "crate_name": "infer", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "infer", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2018", + "version": "0.2.3" + }, + "license": "MIT" + }, "instant 0.1.12": { "name": "instant", "version": "0.1.12", @@ -4638,6 +5394,39 @@ }, "license": "MIT OR Apache-2.0" }, + "parking 2.0.0": { + "name": "parking", + "version": "2.0.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/parking/2.0.0/download", + "sha256": "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" + } + }, + "targets": [ + { + "Library": { + "crate_name": "parking", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "parking", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2018", + "version": "2.0.0" + }, + "license": "Apache-2.0 OR MIT" + }, "password-hash 0.4.2": { "name": "password-hash", "version": "0.4.2", @@ -4888,6 +5677,43 @@ }, "license": "MIT OR Apache-2.0" }, + "ppv-lite86 0.2.17": { + "name": "ppv-lite86", + "version": "0.2.17", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/ppv-lite86/0.2.17/download", + "sha256": "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + } + }, + "targets": [ + { + "Library": { + "crate_name": "ppv_lite86", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "ppv_lite86", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "simd", + "std" + ], + "edition": "2018", + "version": "0.2.17" + }, + "license": "MIT/Apache-2.0" + }, "predicates 2.1.5": { "name": "predicates", "version": "2.1.5", @@ -5324,6 +6150,176 @@ }, "license": "MIT OR Apache-2.0" }, + "rand 0.7.3": { + "name": "rand", + "version": "0.7.3", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/rand/0.7.3/download", + "sha256": "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" + } + }, + "targets": [ + { + "Library": { + "crate_name": "rand", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "rand", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "alloc", + "default", + "getrandom", + "getrandom_package", + "libc", + "std" + ], + "deps": { + "common": [ + { + "id": "getrandom 0.1.16", + "target": "getrandom", + "alias": "getrandom_package" + }, + { + "id": "rand_core 0.5.1", + "target": "rand_core" + } + ], + "selects": { + "cfg(not(target_os = \"emscripten\"))": [ + { + "id": "rand_chacha 0.2.2", + "target": "rand_chacha" + } + ], + "cfg(target_os = \"emscripten\")": [ + { + "id": "rand_hc 0.2.0", + "target": "rand_hc" + } + ], + "cfg(unix)": [ + { + "id": "libc 0.2.139", + "target": "libc" + } + ] + } + }, + "edition": "2018", + "version": "0.7.3" + }, + "license": "MIT OR Apache-2.0" + }, + "rand_chacha 0.2.2": { + "name": "rand_chacha", + "version": "0.2.2", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/rand_chacha/0.2.2/download", + "sha256": "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" + } + }, + "targets": [ + { + "Library": { + "crate_name": "rand_chacha", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "rand_chacha", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "std" + ], + "deps": { + "common": [ + { + "id": "ppv-lite86 0.2.17", + "target": "ppv_lite86" + }, + { + "id": "rand_core 0.5.1", + "target": "rand_core" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "0.2.2" + }, + "license": "MIT OR Apache-2.0" + }, + "rand_core 0.5.1": { + "name": "rand_core", + "version": "0.5.1", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/rand_core/0.5.1/download", + "sha256": "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" + } + }, + "targets": [ + { + "Library": { + "crate_name": "rand_core", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "rand_core", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "alloc", + "getrandom", + "std" + ], + "deps": { + "common": [ + { + "id": "getrandom 0.1.16", + "target": "getrandom" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "0.5.1" + }, + "license": "MIT OR Apache-2.0" + }, "rand_core 0.6.4": { "name": "rand_core", "version": "0.6.4", @@ -5353,9 +6349,51 @@ "**" ], "edition": "2018", - "version": "0.6.4" + "version": "0.6.4" + }, + "license": "MIT OR Apache-2.0" + }, + "rand_hc 0.2.0": { + "name": "rand_hc", + "version": "0.2.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/rand_hc/0.2.0/download", + "sha256": "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" + } + }, + "targets": [ + { + "Library": { + "crate_name": "rand_hc", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "rand_hc", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "rand_core 0.5.1", + "target": "rand_core" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "0.2.0" }, - "license": "MIT OR Apache-2.0" + "license": "MIT/Apache-2.0" }, "redox_syscall 0.2.16": { "name": "redox_syscall", @@ -5819,6 +6857,39 @@ }, "license": "MIT OR Apache-2.0" }, + "retain_mut 0.1.9": { + "name": "retain_mut", + "version": "0.1.9", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/retain_mut/0.1.9/download", + "sha256": "4389f1d5789befaf6029ebd9f7dac4af7f7e3d61b69d4f30e2ac02b57e7712b0" + } + }, + "targets": [ + { + "Library": { + "crate_name": "retain_mut", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "retain_mut", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2015", + "version": "0.1.9" + }, + "license": "MIT" + }, "ring 0.16.20": { "name": "ring", "version": "0.16.20", @@ -6437,9 +7508,9 @@ }, "license": "Apache-2.0/ISC/MIT" }, - "selenium-manager 1.0.0-M2": { + "selenium-manager 1.0.0-M3": { "name": "selenium-manager", - "version": "1.0.0-M2", + "version": "1.0.0-M3", "repository": null, "targets": [ { @@ -6475,7 +7546,7 @@ "deps": { "common": [ { - "id": "clap 4.1.1", + "id": "clap 4.1.3", "target": "clap" }, { @@ -6546,12 +7617,16 @@ { "id": "rstest 0.16.0", "target": "rstest" + }, + { + "id": "wiremock 0.5.17", + "target": "wiremock" } ], "selects": {} }, "edition": "2021", - "version": "1.0.0-M2" + "version": "1.0.0-M3" }, "license": "Apache-2.0" }, @@ -6842,6 +7917,59 @@ }, "license": "MIT OR Apache-2.0" }, + "serde_qs 0.8.5": { + "name": "serde_qs", + "version": "0.8.5", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/serde_qs/0.8.5/download", + "sha256": "c7715380eec75f029a4ef7de39a9200e0a63823176b759d055b613f5a87df6a6" + } + }, + "targets": [ + { + "Library": { + "crate_name": "serde_qs", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "serde_qs", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "default" + ], + "deps": { + "common": [ + { + "id": "percent-encoding 2.2.0", + "target": "percent_encoding" + }, + { + "id": "serde 1.0.152", + "target": "serde" + }, + { + "id": "thiserror 1.0.38", + "target": "thiserror" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "0.8.5" + }, + "license": "MIT/Apache-2.0" + }, "serde_urlencoded 0.7.1": { "name": "serde_urlencoded", "version": "0.7.1", @@ -8574,7 +9702,8 @@ "**" ], "crate_features": [ - "default" + "default", + "serde" ], "deps": { "common": [ @@ -8589,6 +9718,10 @@ { "id": "percent-encoding 2.2.0", "target": "percent_encoding" + }, + { + "id": "serde 1.0.152", + "target": "serde" } ], "selects": {} @@ -8748,6 +9881,39 @@ }, "license": "MIT/Apache-2.0" }, + "waker-fn 1.1.0": { + "name": "waker-fn", + "version": "1.1.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/waker-fn/1.1.0/download", + "sha256": "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" + } + }, + "targets": [ + { + "Library": { + "crate_name": "waker_fn", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "waker_fn", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2018", + "version": "1.1.0" + }, + "license": "Apache-2.0 OR MIT" + }, "want 0.3.0": { "name": "want", "version": "0.3.0", @@ -8831,6 +9997,43 @@ }, "license": "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT" }, + "wasi 0.9.0+wasi-snapshot-preview1": { + "name": "wasi", + "version": "0.9.0+wasi-snapshot-preview1", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/wasi/0.9.0+wasi-snapshot-preview1/download", + "sha256": "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + } + }, + "targets": [ + { + "Library": { + "crate_name": "wasi", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "wasi", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "default", + "std" + ], + "edition": "2018", + "version": "0.9.0+wasi-snapshot-preview1" + }, + "license": "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT" + }, "wasm-bindgen 0.2.83": { "name": "wasm-bindgen", "version": "0.2.83", @@ -10241,6 +11444,105 @@ }, "license": "MIT" }, + "wiremock 0.5.17": { + "name": "wiremock", + "version": "0.5.17", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/wiremock/0.5.17/download", + "sha256": "12316b50eb725e22b2f6b9c4cbede5b7b89984274d113a7440c86e5c3fc6f99b" + } + }, + "targets": [ + { + "Library": { + "crate_name": "wiremock", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "wiremock", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "assert-json-diff 2.0.2", + "target": "assert_json_diff" + }, + { + "id": "base64 0.13.1", + "target": "base64" + }, + { + "id": "deadpool 0.9.5", + "target": "deadpool" + }, + { + "id": "futures 0.3.25", + "target": "futures" + }, + { + "id": "futures-timer 3.0.2", + "target": "futures_timer" + }, + { + "id": "http-types 2.12.0", + "target": "http_types" + }, + { + "id": "hyper 0.14.23", + "target": "hyper" + }, + { + "id": "log 0.4.17", + "target": "log" + }, + { + "id": "once_cell 1.17.0", + "target": "once_cell" + }, + { + "id": "regex 1.7.1", + "target": "regex" + }, + { + "id": "serde 1.0.152", + "target": "serde" + }, + { + "id": "serde_json 1.0.91", + "target": "serde_json" + }, + { + "id": "tokio 1.24.2", + "target": "tokio" + } + ], + "selects": {} + }, + "edition": "2018", + "proc_macro_deps": { + "common": [ + { + "id": "async-trait 0.1.63", + "target": "async_trait" + } + ], + "selects": {} + }, + "version": "0.5.17" + }, + "license": "MIT/Apache-2.0" + }, "xattr 0.2.3": { "name": "xattr", "version": "0.2.3", @@ -10597,12 +11899,12 @@ "binary_crates": [ "assert_cmd 2.0.8", "cc 1.0.78", - "clap 4.1.1", + "clap 4.1.3", "wait-timeout 0.2.0", "webpki-roots 0.22.6" ], "workspace_members": { - "selenium-manager 1.0.0-M2": "rust" + "selenium-manager 1.0.0-M3": "rust" }, "conditions": { "aarch64-apple-darwin": [ @@ -10843,6 +12145,34 @@ "x86_64-unknown-freebsd", "x86_64-unknown-linux-gnu" ], + "cfg(not(target_os = \"emscripten\"))": [ + "aarch64-apple-darwin", + "aarch64-apple-ios", + "aarch64-apple-ios-sim", + "aarch64-linux-android", + "aarch64-pc-windows-msvc", + "aarch64-unknown-linux-gnu", + "arm-unknown-linux-gnueabi", + "armv7-linux-androideabi", + "armv7-unknown-linux-gnueabi", + "i686-apple-darwin", + "i686-linux-android", + "i686-pc-windows-msvc", + "i686-unknown-freebsd", + "i686-unknown-linux-gnu", + "powerpc-unknown-linux-gnu", + "riscv32imc-unknown-none-elf", + "riscv64gc-unknown-none-elf", + "s390x-unknown-linux-gnu", + "wasm32-unknown-unknown", + "wasm32-wasi", + "x86_64-apple-darwin", + "x86_64-apple-ios", + "x86_64-linux-android", + "x86_64-pc-windows-msvc", + "x86_64-unknown-freebsd", + "x86_64-unknown-linux-gnu" + ], "cfg(not(windows))": [ "aarch64-apple-darwin", "aarch64-apple-ios", @@ -10874,6 +12204,7 @@ ], "cfg(target_feature = \"atomics\")": [], "cfg(target_os = \"dragonfly\")": [], + "cfg(target_os = \"emscripten\")": [], "cfg(target_os = \"hermit\")": [], "cfg(target_os = \"redox\")": [], "cfg(target_os = \"wasi\")": [ diff --git a/rust/Cargo.lock b/rust/Cargo.lock index d82ba8c35e998..00e7a92ab63e6 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -29,6 +29,22 @@ dependencies = [ "memchr", ] +[[package]] +name = "anyhow" +version = "1.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" + +[[package]] +name = "assert-json-diff" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e4f2b81832e72834d7518d8487a0396a28cc408186a2e8854c0f98011faf12" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "assert_cmd" version = "2.0.8" @@ -43,12 +59,40 @@ dependencies = [ "wait-timeout", ] +[[package]] +name = "async-channel" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" +dependencies = [ + "concurrent-queue", + "event-listener", + "futures-core", +] + +[[package]] +name = "async-trait" +version = "0.1.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eff18d764974428cf3a9328e23fc5c986f5fbed46e6cd4cdf42544df5d297ec1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + [[package]] name = "base64" version = "0.21.0" @@ -164,9 +208,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.1" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec7a4128863c188deefe750ac1d1dfe66c236909f845af04beed823638dc1b2" +checksum = "d8d93d855ce6a0aa87b8473ef9169482f40abaa2e9e0993024c35c902cbd5920" dependencies = [ "bitflags", "clap_derive", @@ -199,6 +243,15 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "concurrent-queue" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c278839b831783b70278b14df4d45e1beb1aad306c07bb796637de9a0e323e8e" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "constant_time_eq" version = "0.1.5" @@ -242,6 +295,25 @@ dependencies = [ "typenum", ] +[[package]] +name = "deadpool" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "421fe0f90f2ab22016f32a9881be5134fdd71c65298917084b0c7477cbc3856e" +dependencies = [ + "async-trait", + "deadpool-runtime", + "num_cpus", + "retain_mut", + "tokio", +] + +[[package]] +name = "deadpool-runtime" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaa37046cc0f6c3cc6090fbdbf73ef0b8ef4cfcc37f6befc0020f63e8cf121e1" + [[package]] name = "difflib" version = "0.4.0" @@ -334,6 +406,12 @@ dependencies = [ "libc", ] +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + [[package]] name = "exitcode" version = "1.1.2" @@ -434,6 +512,21 @@ version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" +[[package]] +name = "futures-lite" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + [[package]] name = "futures-macro" version = "0.3.25" @@ -491,6 +584,17 @@ dependencies = [ "version_check", ] +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + [[package]] name = "getrandom" version = "0.2.8" @@ -499,7 +603,7 @@ checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] @@ -573,6 +677,27 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "http-types" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e9b187a72d63adbfba487f48095306ac823049cb504ee195541e91c7775f5ad" +dependencies = [ + "anyhow", + "async-channel", + "base64 0.13.1", + "futures-lite", + "http", + "infer 0.2.3", + "pin-project-lite", + "rand", + "serde", + "serde_json", + "serde_qs", + "serde_urlencoded", + "url", +] + [[package]] name = "httparse" version = "1.8.0" @@ -648,6 +773,12 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "infer" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64e9829a50b42bb782c1df523f78d332fe371b10c661e78b7a3c34b0198e9fac" + [[package]] name = "infer" version = "0.12.0" @@ -777,7 +908,7 @@ checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys", ] @@ -809,6 +940,12 @@ version = "6.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" +[[package]] +name = "parking" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" + [[package]] name = "password-hash" version = "0.4.2" @@ -816,7 +953,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" dependencies = [ "base64ct", - "rand_core", + "rand_core 0.6.4", "subtle", ] @@ -856,6 +993,12 @@ version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "predicates" version = "2.1.5" @@ -925,12 +1068,53 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha", + "rand_core 0.5.1", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + [[package]] name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + [[package]] name = "redox_syscall" version = "0.2.16" @@ -946,7 +1130,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom", + "getrandom 0.2.8", "redox_syscall", "thiserror", ] @@ -989,7 +1173,7 @@ version = "0.11.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9" dependencies = [ - "base64", + "base64 0.21.0", "bytes", "encoding_rs", "futures-core", @@ -1022,6 +1206,12 @@ dependencies = [ "winreg", ] +[[package]] +name = "retain_mut" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4389f1d5789befaf6029ebd9f7dac4af7f7e3d61b69d4f30e2ac02b57e7712b0" + [[package]] name = "ring" version = "0.16.20" @@ -1104,7 +1294,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" dependencies = [ - "base64", + "base64 0.21.0", ] [[package]] @@ -1125,7 +1315,7 @@ dependencies = [ [[package]] name = "selenium-manager" -version = "1.0.0-M2" +version = "1.0.0-M3" dependencies = [ "assert_cmd", "clap", @@ -1133,7 +1323,7 @@ dependencies = [ "env_logger", "exitcode", "flate2", - "infer", + "infer 0.12.0", "log", "regex", "reqwest", @@ -1143,6 +1333,7 @@ dependencies = [ "tar", "tempfile", "tokio", + "wiremock", "zip", ] @@ -1183,6 +1374,17 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_qs" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7715380eec75f029a4ef7de39a9200e0a63823176b759d055b613f5a87df6a6" +dependencies = [ + "percent-encoding", + "serde", + "thiserror", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -1495,6 +1697,7 @@ dependencies = [ "form_urlencoded", "idna", "percent-encoding", + "serde", ] [[package]] @@ -1518,6 +1721,12 @@ dependencies = [ "libc", ] +[[package]] +name = "waker-fn" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" + [[package]] name = "want" version = "0.3.0" @@ -1528,6 +1737,12 @@ dependencies = [ "try-lock", ] +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1726,6 +1941,28 @@ dependencies = [ "winapi", ] +[[package]] +name = "wiremock" +version = "0.5.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12316b50eb725e22b2f6b9c4cbede5b7b89984274d113a7440c86e5c3fc6f99b" +dependencies = [ + "assert-json-diff", + "async-trait", + "base64 0.13.1", + "deadpool", + "futures", + "futures-timer", + "http-types", + "hyper", + "log", + "once_cell", + "regex", + "serde", + "serde_json", + "tokio", +] + [[package]] name = "xattr" version = "0.2.3" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 2a22605001818..54237feb28b00 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "selenium-manager" -version = "1.0.0-M2" +version = "1.0.0-M3" edition = "2021" authors = ["Selenium Browser path (absolute) for browser version detection (e.g., /usr/bin/google-chrome, "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome", "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe") + -p, --proxy + HTTP proxy for network connection (e.g., https://myproxy.net:8080) + -t, --timeout + Timeout for network requests (in seconds) [default: 120] -D, --debug Display DEBUG messages -T, --trace diff --git a/rust/src/chrome.rs b/rust/src/chrome.rs index 0775f52a308a6..db3d7971dff4c 100644 --- a/rust/src/chrome.rs +++ b/rust/src/chrome.rs @@ -24,7 +24,7 @@ use std::path::PathBuf; use crate::config::ARCH::ARM64; use crate::config::OS::{LINUX, MACOS, WINDOWS}; use crate::downloads::read_content_from_link; -use crate::files::{compose_driver_path_in_cache, BrowserPath}; +use crate::files::{compose_driver_path_in_cache, BrowserPath, PARSE_ERROR}; use crate::logger::Logger; use crate::metadata::{ create_driver_metadata, get_driver_version_from_metadata, get_metadata, write_metadata, @@ -69,6 +69,10 @@ impl SeleniumManager for ChromeManager { &self.http_client } + fn set_http_client(&mut self, http_client: Client) { + self.http_client = http_client; + } + fn get_browser_path_map(&self) -> HashMap { HashMap::from([ ( @@ -180,13 +184,15 @@ impl SeleniumManager for ChromeManager { "Reading {} version from {}", &self.driver_name, driver_url )); - let content = read_content_from_link(self.get_http_client(), driver_url); - match content { + match read_content_from_link(self.get_http_client(), driver_url) { Ok(version) => { driver_version = version; break; } - _ => { + Err(err) => { + if !err.to_string().eq(PARSE_ERROR) { + return Err(err); + } self.log.warn(format!( "Error getting version of {} {}. Retrying with {} {} (attempt {}/{})", &self.driver_name, diff --git a/rust/src/config.rs b/rust/src/config.rs index 3785f060489a7..afdf103c305fd 100644 --- a/rust/src/config.rs +++ b/rust/src/config.rs @@ -16,6 +16,7 @@ // under the License. use crate::config::OS::{LINUX, MACOS, WINDOWS}; +use crate::REQUEST_TIMEOUT_SEC; use std::env::consts::{ARCH, OS}; pub struct ManagerConfig { @@ -24,6 +25,8 @@ pub struct ManagerConfig { pub os: String, pub arch: String, pub browser_path: String, + pub proxy: String, + pub timeout: u64, } impl ManagerConfig { @@ -34,6 +37,8 @@ impl ManagerConfig { os: OS.to_string(), arch: ARCH.to_string(), browser_path: "".to_string(), + proxy: "".to_string(), + timeout: REQUEST_TIMEOUT_SEC, } } @@ -45,6 +50,8 @@ impl ManagerConfig { os: config.os.as_str().to_string(), arch: config.arch.as_str().to_string(), browser_path: config.browser_path.as_str().to_string(), + proxy: config.proxy.as_str().to_string(), + timeout: config.timeout, } } } diff --git a/rust/src/edge.rs b/rust/src/edge.rs index 65c5e93c849fb..25a9022f80887 100644 --- a/rust/src/edge.rs +++ b/rust/src/edge.rs @@ -69,6 +69,10 @@ impl SeleniumManager for EdgeManager { &self.http_client } + fn set_http_client(&mut self, http_client: Client) { + self.http_client = http_client; + } + fn get_browser_path_map(&self) -> HashMap { HashMap::from([ ( diff --git a/rust/src/files.rs b/rust/src/files.rs index b8dfe9cd07b6e..b25b75470a25b 100644 --- a/rust/src/files.rs +++ b/rust/src/files.rs @@ -32,6 +32,7 @@ use zip::ZipArchive; use crate::config::OS::WINDOWS; use crate::Logger; +pub const PARSE_ERROR: &str = "Wrong browser/driver version"; const CACHE_FOLDER: &str = ".cache/selenium"; const ZIP: &str = "zip"; const GZ: &str = "gz"; @@ -180,7 +181,7 @@ pub fn get_binary_extension(os: &str) -> &str { pub fn parse_version(version_text: String) -> Result> { if version_text.to_ascii_lowercase().contains("error") { - return Err("Wrong browser/driver version".into()); + return Err(PARSE_ERROR.into()); } let re = Regex::new(r"[^\d^.]").unwrap(); Ok(re.replace_all(&version_text, "").to_string()) diff --git a/rust/src/firefox.rs b/rust/src/firefox.rs index b6dbdb9a9c6a7..11d38a1d53da5 100644 --- a/rust/src/firefox.rs +++ b/rust/src/firefox.rs @@ -67,6 +67,10 @@ impl SeleniumManager for FirefoxManager { &self.http_client } + fn set_http_client(&mut self, http_client: Client) { + self.http_client = http_client; + } + fn get_browser_path_map(&self) -> HashMap { HashMap::from([ ( diff --git a/rust/src/iexplorer.rs b/rust/src/iexplorer.rs index d9320962948ac..85c301f77af62 100644 --- a/rust/src/iexplorer.rs +++ b/rust/src/iexplorer.rs @@ -64,6 +64,10 @@ impl SeleniumManager for IExplorerManager { &self.http_client } + fn set_http_client(&mut self, http_client: Client) { + self.http_client = http_client; + } + fn get_browser_path_map(&self) -> HashMap { HashMap::new() } diff --git a/rust/src/lib.rs b/rust/src/lib.rs index a04f75f46305f..de3db9c653ab2 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -23,11 +23,12 @@ use crate::iexplorer::IExplorerManager; use std::fs; use crate::config::{str_to_os, ManagerConfig}; -use reqwest::Client; +use reqwest::{Client, ClientBuilder, Proxy}; use std::collections::HashMap; use std::error::Error; use std::path::PathBuf; use std::process::Command; +use std::time::Duration; use crate::downloads::download_driver_to_tmp_folder; use crate::files::{parse_version, uncompress, BrowserPath}; @@ -46,6 +47,7 @@ pub mod iexplorer; pub mod logger; pub mod metadata; +pub const REQUEST_TIMEOUT_SEC: u64 = 120; // The timeout is applied from when the request starts connecting until the response body has finished pub const STABLE: &str = "stable"; pub const BETA: &str = "beta"; pub const DEV: &str = "dev"; @@ -70,6 +72,8 @@ pub trait SeleniumManager { fn get_http_client(&self) -> &Client; + fn set_http_client(&mut self, http_client: Client); + fn get_browser_path_map(&self) -> HashMap; fn discover_browser_version(&self) -> Option; @@ -191,9 +195,20 @@ pub trait SeleniumManager { } } } - let driver_version = self - .request_driver_version() - .unwrap_or_else(|err| err.to_string()); + let driver_version = match self.request_driver_version() { + Ok(version) => { + if version.is_empty() { + return Err(format!( + "The {} version cannot be discovered", + self.get_driver_name() + )); + } + version + } + Err(err) => { + return Err(err.to_string()); + } + }; self.get_logger().debug(format!( "Required driver: {} {}", self.get_driver_name(), @@ -312,6 +327,52 @@ pub trait SeleniumManager { config.browser_path = browser_path; self.set_config(config); } + + fn get_proxy(&self) -> &str { + self.get_config().proxy.as_str() + } + + fn set_proxy(&mut self, proxy: String) -> Result<(), Box> { + let mut config = ManagerConfig::clone(self.get_config()); + config.proxy = proxy.to_string(); + self.set_config(config); + + if !proxy.is_empty() { + self.get_logger().debug(format!("Using proxy: {}", &proxy)); + self.update_http_proxy()?; + } + Ok(()) + } + + fn get_timeout(&self) -> u64 { + self.get_config().timeout + } + + fn set_timeout(&mut self, timeout: u64) -> Result<(), Box> { + let mut config = ManagerConfig::clone(self.get_config()); + config.timeout = timeout; + self.set_config(config); + + if timeout != REQUEST_TIMEOUT_SEC { + self.get_logger() + .debug(format!("Using timeout of {} seconds", timeout)); + self.update_http_proxy()?; + } + Ok(()) + } + + fn update_http_proxy(&mut self) -> Result<(), Box> { + let proxy = self.get_proxy(); + let timeout = self.get_timeout(); + + let mut builder = http_client_builder().timeout(Duration::from_secs(timeout)); + if !proxy.is_empty() { + builder = builder.proxy(Proxy::all(proxy)?); + } + let http_client = builder.build()?; + self.set_http_client(http_client); + Ok(()) + } } // ---------------------------------------------------------- @@ -370,9 +431,8 @@ pub fn clear_cache(log: &Logger) { } pub fn create_default_http_client() -> Client { - Client::builder() - .danger_accept_invalid_certs(true) - .use_rustls_tls() + http_client_builder() + .timeout(Duration::from_secs(REQUEST_TIMEOUT_SEC)) .build() .unwrap_or_default() } @@ -388,3 +448,9 @@ fn get_index_version(full_version: &str, index: usize) -> Result ClientBuilder { + Client::builder() + .danger_accept_invalid_certs(true) + .use_rustls_tls() +} diff --git a/rust/src/main.rs b/rust/src/main.rs index a39a7b55ac378..763d26c6965f4 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -21,9 +21,10 @@ use std::process::exit; use clap::Parser; -use exitcode::DATAERR; +use exitcode::{DATAERR, UNAVAILABLE}; use selenium_manager::logger::Logger; +use selenium_manager::REQUEST_TIMEOUT_SEC; use selenium_manager::{ clear_cache, get_manager_by_browser, get_manager_by_driver, SeleniumManager, }; @@ -62,6 +63,14 @@ struct Cli { #[clap(short = 'O', long, value_parser, default_value = "LOGGER")] output: String, + /// HTTP proxy for network connection (e.g., https://myproxy.net:8080) + #[clap(short = 'p', long, value_parser)] + proxy: Option, + + /// Timeout for network requests (in seconds) + #[clap(short = 't', long, value_parser, default_value_t = REQUEST_TIMEOUT_SEC)] + timeout: u64, + /// Display DEBUG messages #[clap(short = 'D', long)] debug: bool, @@ -108,6 +117,20 @@ fn main() -> Result<(), Box> { selenium_manager.set_browser_version(cli.browser_version.unwrap_or_default()); selenium_manager.set_driver_version(cli.driver_version.unwrap_or_default()); selenium_manager.set_browser_path(cli.browser_path.unwrap_or_default()); + match selenium_manager.set_timeout(cli.timeout) { + Ok(_) => {} + Err(err) => { + selenium_manager.get_logger().error(err.to_string()); + flush_and_exit(UNAVAILABLE, selenium_manager.get_logger()); + } + } + match selenium_manager.set_proxy(cli.proxy.unwrap_or_default()) { + Ok(_) => {} + Err(err) => { + selenium_manager.get_logger().error(err.to_string()); + flush_and_exit(UNAVAILABLE, selenium_manager.get_logger()); + } + } match selenium_manager.resolve_driver() { Ok(driver_path) => { diff --git a/rust/tests/output_tests.rs b/rust/tests/output_tests.rs index 517a846ab41e9..9ce0829bd1fef 100644 --- a/rust/tests/output_tests.rs +++ b/rust/tests/output_tests.rs @@ -57,4 +57,4 @@ fn shell_output_test() { let driver = Path::new(output); assert!(driver.exists()); -} \ No newline at end of file +} diff --git a/rust/tests/proxy_tests.rs b/rust/tests/proxy_tests.rs new file mode 100644 index 0000000000000..cabc42d3d53e8 --- /dev/null +++ b/rust/tests/proxy_tests.rs @@ -0,0 +1,55 @@ +// Licensed to the Software Freedom Conservancy (SFC) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The SFC licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use assert_cmd::Command; + +use exitcode::UNAVAILABLE; + +use wiremock::MockServer; + +#[tokio::test] +async fn ok_proxy_test() { + let mock_server = MockServer::start().await; + let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); + cmd.args(["--browser", "chrome", "--proxy", &mock_server.uri()]) + .assert() + .success() + .code(0); +} + +#[test] +fn wrong_protocol_proxy_test() { + let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); + cmd.args(["--browser", "chrome", "--proxy", "wrong:://proxy"]) + .assert() + .failure() + .code(UNAVAILABLE); +} + +#[test] +fn wrong_port_proxy_test() { + let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); + cmd.args([ + "--browser", + "chrome", + "--proxy", + "https:://localhost:1234567", + ]) + .assert() + .failure() + .code(UNAVAILABLE); +} diff --git a/rust/tests/timeout_tests.rs b/rust/tests/timeout_tests.rs new file mode 100644 index 0000000000000..2e7834a534c68 --- /dev/null +++ b/rust/tests/timeout_tests.rs @@ -0,0 +1,36 @@ +// Licensed to the Software Freedom Conservancy (SFC) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The SFC licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use assert_cmd::Command; + +use exitcode::DATAERR; + +#[test] +fn timeout_proxy_test() { + let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); + cmd.args([ + "--clear-cache", + "--debug", + "--browser", + "edge", + "--timeout", + "0", + ]) + .assert() + .failure() + .code(DATAERR); +}