From c60bb86d56e992da7fa5d158b09564d7131d761f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20L=C3=B6nnhager?= Date: Sun, 24 Sep 2023 12:52:46 +0200 Subject: [PATCH] Use CLI for old management interface to simplify dependency tree --- Cargo.lock | 311 ++++---------------- test/test-manager/Cargo.toml | 1 - test/test-manager/api-addrs.txt | 34 +++ test/test-manager/generate-api-endpoints.sh | 9 + test/test-manager/src/main.rs | 2 +- test/test-manager/src/mullvad_daemon.rs | 16 - test/test-manager/src/tests/helpers.rs | 63 ---- test/test-manager/src/tests/install.rs | 61 +--- test/test-manager/test_macro/src/lib.rs | 20 -- test/test-rpc/src/client.rs | 4 +- test/test-rpc/src/mullvad_daemon.rs | 1 - 11 files changed, 122 insertions(+), 400 deletions(-) create mode 100644 test/test-manager/api-addrs.txt create mode 100755 test/test-manager/generate-api-endpoints.sh diff --git a/Cargo.lock b/Cargo.lock index 06931fde9c50..32cd431867ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -453,10 +453,8 @@ checksum = "defd4e7873dbddba6c7c91e199c7fcb946abc4a6a4ac3195400bcfb01b5de877" dependencies = [ "android-tzdata", "iana-time-zone", - "js-sys", "num-traits", "serde", - "wasm-bindgen", "windows-targets 0.48.5", ] @@ -2054,14 +2052,14 @@ dependencies = [ "ipnetwork 0.16.0", "log", "mullvad-fs", - "mullvad-types 0.0.0", + "mullvad-types", "once_cell", "rustls-pemfile 1.0.3", "serde", "serde_json", "shadowsocks", "talpid-time", - "talpid-types 0.0.0", + "talpid-types", "tokio", "tokio-rustls 0.24.1", ] @@ -2077,11 +2075,11 @@ dependencies = [ "env_logger 0.10.0", "futures", "itertools", - "mullvad-management-interface 0.0.0", - "mullvad-types 0.0.0", + "mullvad-management-interface", + "mullvad-types", "mullvad-version", "natord", - "talpid-types 0.0.0", + "talpid-types", "tokio", "windows-sys 0.48.0", "winres", @@ -2104,10 +2102,10 @@ dependencies = [ "log-panics", "mullvad-api", "mullvad-fs", - "mullvad-management-interface 0.0.0", - "mullvad-paths 0.0.0", + "mullvad-management-interface", + "mullvad-paths", "mullvad-relay-selector", - "mullvad-types 0.0.0", + "mullvad-types", "mullvad-version", "nix 0.23.2", "objc", @@ -2120,7 +2118,7 @@ dependencies = [ "talpid-dbus", "talpid-platform-metadata", "talpid-time", - "talpid-types 0.0.0", + "talpid-types", "tokio", "tokio-stream", "winapi", @@ -2135,7 +2133,7 @@ version = "0.0.0" dependencies = [ "err-derive", "nix 0.23.2", - "talpid-types 0.0.0", + "talpid-types", ] [[package]] @@ -2143,7 +2141,7 @@ name = "mullvad-fs" version = "0.0.0" dependencies = [ "log", - "talpid-types 0.0.0", + "talpid-types", "tokio", "uuid", ] @@ -2161,11 +2159,11 @@ dependencies = [ "mullvad-api", "mullvad-daemon", "mullvad-problem-report", - "mullvad-types 0.0.0", + "mullvad-types", "nix 0.23.2", "rand 0.8.5", "talpid-tunnel", - "talpid-types 0.0.0", + "talpid-types", ] [[package]] @@ -2176,40 +2174,17 @@ dependencies = [ "err-derive", "futures", "log", - "mullvad-paths 0.0.0", - "mullvad-types 0.0.0", + "mullvad-paths", + "mullvad-types", "nix 0.23.2", "once_cell", "parity-tokio-ipc", - "prost 0.12.0", - "prost-types 0.12.0", - "talpid-types 0.0.0", + "prost", + "prost-types", + "talpid-types", "tokio", - "tonic 0.10.0", - "tonic-build 0.10.0", - "tower", -] - -[[package]] -name = "mullvad-management-interface" -version = "0.0.0" -source = "git+https://github.com/mullvad/mullvadvpn-app?rev=2023.3#52bb628c9ef30e68789e02902cc91a40ea8824b5" -dependencies = [ - "chrono", - "err-derive", - "futures", - "lazy_static", - "log", - "mullvad-paths 0.0.0 (git+https://github.com/mullvad/mullvadvpn-app?rev=2023.3)", - "mullvad-types 0.0.0 (git+https://github.com/mullvad/mullvadvpn-app?rev=2023.3)", - "nix 0.23.2", - "parity-tokio-ipc", - "prost 0.11.9", - "prost-types 0.11.9", - "talpid-types 0.0.0 (git+https://github.com/mullvad/mullvadvpn-app?rev=2023.3)", - "tokio", - "tonic 0.8.3", - "tonic-build 0.8.4", + "tonic", + "tonic-build", "tower", ] @@ -2218,7 +2193,7 @@ name = "mullvad-nsis" version = "0.0.0" dependencies = [ "cbindgen", - "mullvad-paths 0.0.0", + "mullvad-paths", ] [[package]] @@ -2232,18 +2207,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "mullvad-paths" -version = "0.0.0" -source = "git+https://github.com/mullvad/mullvadvpn-app?rev=2023.3#52bb628c9ef30e68789e02902cc91a40ea8824b5" -dependencies = [ - "err-derive", - "log", - "once_cell", - "widestring", - "windows-sys 0.45.0", -] - [[package]] name = "mullvad-problem-report" version = "0.0.0" @@ -2255,12 +2218,12 @@ dependencies = [ "err-derive", "log", "mullvad-api", - "mullvad-paths 0.0.0", + "mullvad-paths", "mullvad-version", "once_cell", "regex", "talpid-platform-metadata", - "talpid-types 0.0.0", + "talpid-types", "tokio", "uuid", "windows-sys 0.48.0", @@ -2277,13 +2240,13 @@ dependencies = [ "ipnetwork 0.16.0", "log", "mullvad-api", - "mullvad-types 0.0.0", + "mullvad-types", "once_cell", "parking_lot 0.12.1", "rand 0.8.5", "serde_json", "talpid-core", - "talpid-types 0.0.0", + "talpid-types", "tokio", ] @@ -2296,13 +2259,13 @@ dependencies = [ "err-derive", "mullvad-api", "mullvad-daemon", - "mullvad-management-interface 0.0.0", - "mullvad-paths 0.0.0", - "mullvad-types 0.0.0", + "mullvad-management-interface", + "mullvad-paths", + "mullvad-types", "mullvad-version", "once_cell", "talpid-core", - "talpid-types 0.0.0", + "talpid-types", "tokio", ] @@ -2319,27 +2282,10 @@ dependencies = [ "once_cell", "regex", "serde", - "talpid-types 0.0.0", + "talpid-types", "uuid", ] -[[package]] -name = "mullvad-types" -version = "0.0.0" -source = "git+https://github.com/mullvad/mullvadvpn-app?rev=2023.3#52bb628c9ef30e68789e02902cc91a40ea8824b5" -dependencies = [ - "chrono", - "err-derive", - "ipnetwork 0.16.0", - "jnix", - "lazy_static", - "log", - "rand 0.8.5", - "regex", - "serde", - "talpid-types 0.0.0 (git+https://github.com/mullvad/mullvadvpn-app?rev=2023.3)", -] - [[package]] name = "mullvad-version" version = "0.0.0" @@ -3069,16 +3015,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "prettyplease" -version = "0.1.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" -dependencies = [ - "proc-macro2", - "syn 1.0.109", -] - [[package]] name = "prettyplease" version = "0.2.15" @@ -3122,16 +3058,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "prost" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" -dependencies = [ - "bytes", - "prost-derive 0.11.9", -] - [[package]] name = "prost" version = "0.12.0" @@ -3139,29 +3065,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa8473a65b88506c106c28ae905ca4a2b83a2993640467a41bb3080627ddfd2c" dependencies = [ "bytes", - "prost-derive 0.12.0", -] - -[[package]] -name = "prost-build" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" -dependencies = [ - "bytes", - "heck", - "itertools", - "lazy_static", - "log", - "multimap", - "petgraph", - "prettyplease 0.1.25", - "prost 0.11.9", - "prost-types 0.11.9", - "regex", - "syn 1.0.109", - "tempfile", - "which", + "prost-derive", ] [[package]] @@ -3177,28 +3081,15 @@ dependencies = [ "multimap", "once_cell", "petgraph", - "prettyplease 0.2.15", - "prost 0.12.0", - "prost-types 0.12.0", + "prettyplease", + "prost", + "prost-types", "regex", "syn 2.0.31", "tempfile", "which", ] -[[package]] -name = "prost-derive" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "prost-derive" version = "0.12.0" @@ -3212,22 +3103,13 @@ dependencies = [ "syn 2.0.31", ] -[[package]] -name = "prost-types" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" -dependencies = [ - "prost 0.11.9", -] - [[package]] name = "prost-types" version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cebe0a918c97f86c217b0f76fd754e966f8b9f41595095cf7d74cb4e59d730f6" dependencies = [ - "prost 0.12.0", + "prost", ] [[package]] @@ -4133,11 +4015,11 @@ dependencies = [ "talpid-time", "talpid-tunnel", "talpid-tunnel-config-client", - "talpid-types 0.0.0", + "talpid-types", "talpid-windows-net", "talpid-wireguard", "tokio", - "tonic-build 0.10.0", + "tonic-build", "triggered", "trust-dns-proto", "trust-dns-server", @@ -4174,16 +4056,16 @@ dependencies = [ "os_pipe", "parity-tokio-ipc", "parking_lot 0.12.1", - "prost 0.12.0", + "prost", "shadowsocks-service", "shell-escape", "talpid-routing", "talpid-tunnel", - "talpid-types 0.0.0", + "talpid-types", "talpid-windows-net", "tokio", - "tonic 0.10.0", - "tonic-build 0.10.0", + "tonic", + "tonic-build", "triggered", "uuid", "widestring", @@ -4201,11 +4083,11 @@ dependencies = [ "mullvad-version", "openvpn-plugin", "parity-tokio-ipc", - "prost 0.12.0", - "talpid-types 0.0.0", + "prost", + "talpid-types", "tokio", - "tonic 0.10.0", - "tonic-build 0.10.0", + "tonic", + "tonic-build", "tower", "windows-sys 0.48.0", "winres", @@ -4236,7 +4118,7 @@ dependencies = [ "once_cell", "rtnetlink", "system-configuration", - "talpid-types 0.0.0", + "talpid-types", "talpid-windows-net", "tokio", "widestring", @@ -4264,7 +4146,7 @@ dependencies = [ "log", "nix 0.23.2", "talpid-routing", - "talpid-types 0.0.0", + "talpid-types", "talpid-windows-net", "tokio", "tun", @@ -4279,12 +4161,12 @@ dependencies = [ "libc", "log", "pqc_kyber", - "prost 0.12.0", + "prost", "rand 0.8.5", - "talpid-types 0.0.0", + "talpid-types", "tokio", - "tonic 0.10.0", - "tonic-build 0.10.0", + "tonic", + "tonic-build", "tower", "windows-sys 0.48.0", "zeroize", @@ -4303,21 +4185,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "talpid-types" -version = "0.0.0" -source = "git+https://github.com/mullvad/mullvadvpn-app?rev=2023.3#52bb628c9ef30e68789e02902cc91a40ea8824b5" -dependencies = [ - "base64 0.13.1", - "err-derive", - "ipnetwork 0.16.0", - "jnix", - "rand 0.8.5", - "serde", - "x25519-dalek", - "zeroize", -] - [[package]] name = "talpid-windows-net" version = "0.0.0" @@ -4325,7 +4192,7 @@ dependencies = [ "err-derive", "futures", "socket2 0.5.3", - "talpid-types 0.0.0", + "talpid-types", "windows-sys 0.48.0", ] @@ -4358,7 +4225,7 @@ dependencies = [ "talpid-routing", "talpid-tunnel", "talpid-tunnel-config-client", - "talpid-types 0.0.0", + "talpid-types", "talpid-windows-net", "tokio", "tokio-stream", @@ -4446,9 +4313,8 @@ dependencies = [ "libc", "log", "mullvad-api", - "mullvad-management-interface 0.0.0", - "mullvad-management-interface 0.0.0 (git+https://github.com/mullvad/mullvadvpn-app?rev=2023.3)", - "mullvad-types 0.0.0", + "mullvad-management-interface", + "mullvad-types", "nix 0.25.1", "once_cell", "pcap", @@ -4457,7 +4323,7 @@ dependencies = [ "serde", "serde_json", "ssh2", - "talpid-types 0.0.0", + "talpid-types", "tarpc", "test-rpc", "test_macro", @@ -4465,7 +4331,7 @@ dependencies = [ "tokio-serde", "tokio-serial", "tokio-util", - "tonic 0.10.0", + "tonic", "tower", "tun", "uuid", @@ -4505,7 +4371,7 @@ dependencies = [ "lazy_static", "libc", "log", - "mullvad-paths 0.0.0", + "mullvad-paths", "nix 0.25.1", "once_cell", "parity-tokio-ipc", @@ -4784,38 +4650,6 @@ dependencies = [ "winnow", ] -[[package]] -name = "tonic" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f219fad3b929bef19b1f86fbc0358d35daed8f2cac972037ac0dc10bbb8d5fb" -dependencies = [ - "async-stream", - "async-trait", - "axum", - "base64 0.13.1", - "bytes", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "hyper", - "hyper-timeout", - "percent-encoding", - "pin-project", - "prost 0.11.9", - "prost-derive 0.11.9", - "tokio", - "tokio-stream", - "tokio-util", - "tower", - "tower-layer", - "tower-service", - "tracing", - "tracing-futures", -] - [[package]] name = "tonic" version = "0.10.0" @@ -4834,7 +4668,7 @@ dependencies = [ "hyper-timeout", "percent-encoding", "pin-project", - "prost 0.12.0", + "prost", "tokio", "tokio-stream", "tower", @@ -4843,28 +4677,15 @@ dependencies = [ "tracing", ] -[[package]] -name = "tonic-build" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf5e9b9c0f7e0a7c027dcfaba7b2c60816c7049171f679d99ee2ff65d0de8c4" -dependencies = [ - "prettyplease 0.1.25", - "proc-macro2", - "prost-build 0.11.9", - "quote", - "syn 1.0.109", -] - [[package]] name = "tonic-build" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b477abbe1d18c0b08f56cd01d1bc288668c5b5cfd19b2ae1886bbf599c546f1" dependencies = [ - "prettyplease 0.2.15", + "prettyplease", "proc-macro2", - "prost-build 0.12.0", + "prost-build", "quote", "syn 2.0.31", ] @@ -4935,16 +4756,6 @@ dependencies = [ "valuable", ] -[[package]] -name = "tracing-futures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" -dependencies = [ - "pin-project", - "tracing", -] - [[package]] name = "tracing-opentelemetry" version = "0.17.4" diff --git a/test/test-manager/Cargo.toml b/test/test-manager/Cargo.toml index eb7837ac8194..83237bb02043 100644 --- a/test/test-manager/Cargo.toml +++ b/test/test-manager/Cargo.toml @@ -42,7 +42,6 @@ tower = { workspace = true } colored = "2.0.0" mullvad-management-interface = { path = "../../mullvad-management-interface" } -old-mullvad-management-interface = { git = "https://github.com/mullvad/mullvadvpn-app", rev = "2023.3", package = "mullvad-management-interface" } talpid-types = { path = "../../talpid-types" } mullvad-types = { path = "../../mullvad-types" } # FIXME: does this always enable override? diff --git a/test/test-manager/api-addrs.txt b/test/test-manager/api-addrs.txt new file mode 100644 index 000000000000..22e9604dd6bf --- /dev/null +++ b/test/test-manager/api-addrs.txt @@ -0,0 +1,34 @@ +45.83.223.193 +185.217.116.1 +185.217.116.129 +45.83.223.196 +146.70.141.154 +37.120.218.170 +217.138.213.18 +198.44.140.226 +193.32.127.117 +91.193.4.210 +217.138.199.106 +185.213.155.117 +193.138.7.132 +193.32.126.117 +141.98.252.66 +89.238.134.58 +103.125.233.210 +185.242.4.34 +185.65.134.116 +91.90.44.10 +194.127.199.245 +5.253.206.194 +185.213.154.117 +193.138.218.71 +146.70.192.34 +66.115.180.241 +68.235.44.130 +174.127.113.18 +62.133.44.202 +146.70.183.34 +212.103.48.226 +38.132.121.146 +198.54.130.178 +69.4.234.146 diff --git a/test/test-manager/generate-api-endpoints.sh b/test/test-manager/generate-api-endpoints.sh new file mode 100755 index 000000000000..ab857fbce1c0 --- /dev/null +++ b/test/test-manager/generate-api-endpoints.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# Output known API IPs and bridge relay IPs + +dig +short api.mullvad.net +dig +short api.devmole.eu +dig +short api.stagemole.eu +echo "45.83.223.196" # old prod +curl -s https://api.mullvad.net/app/v1/relays | jq -r '.bridge.relays[] | .ipv4_addr_in' diff --git a/test/test-manager/src/main.rs b/test/test-manager/src/main.rs index 3dc962422e80..b458f7ce9c42 100644 --- a/test/test-manager/src/main.rs +++ b/test/test-manager/src/main.rs @@ -88,7 +88,7 @@ enum Commands { /// /// # Note /// - /// The gRPC interface must be compatible with the version specified for `old-mullvad-management-interface` in Cargo.toml. + /// The CLI interface must be compatible with the upgrade test. #[arg(long, short)] previous_app: String, diff --git a/test/test-manager/src/mullvad_daemon.rs b/test/test-manager/src/mullvad_daemon.rs index 1f8facdf9fd5..2bfff38ddeba 100644 --- a/test/test-manager/src/mullvad_daemon.rs +++ b/test/test-manager/src/mullvad_daemon.rs @@ -8,7 +8,6 @@ use test_rpc::{ }; use tokio::io::{AsyncReadExt, AsyncWriteExt, DuplexStream}; use tokio_util::codec::{Decoder, LengthDelimitedCodec}; -use tonic::transport::Uri; use tower::Service; const GRPC_REQUEST_TIMEOUT: Duration = Duration::from_secs(10); @@ -58,7 +57,6 @@ impl RpcClientProvider { ) -> Box { match client_type { MullvadClientVersion::New => Box::new(self.new_client().await), - MullvadClientVersion::Previous => Box::new(self.old_client().await), MullvadClientVersion::None => Box::new(()), } } @@ -76,20 +74,6 @@ impl RpcClientProvider { ManagementServiceClient::new(channel) } - - async fn old_client(&self) -> old_mullvad_management_interface::ManagementServiceClient { - tokio::time::sleep(std::time::Duration::from_millis(500)).await; - log::debug!("Mullvad daemon (old): connecting"); - let channel = old_mullvad_management_interface::Channel::builder(Uri::from_static( - "serial://placeholder", - )) - .timeout(GRPC_REQUEST_TIMEOUT) - .connect_with_connector(self.service.clone()) - .await - .unwrap(); - - old_mullvad_management_interface::ManagementServiceClient::new(channel) - } } pub async fn new_rpc_client( diff --git a/test/test-manager/src/tests/helpers.rs b/test/test-manager/src/tests/helpers.rs index 2f789c3c1949..cfea60dadcd3 100644 --- a/test/test-manager/src/tests/helpers.rs +++ b/test/test-manager/src/tests/helpers.rs @@ -27,69 +27,6 @@ macro_rules! assert_tunnel_state { }}; } -/// Return all possible API endpoints. Note that this includes all bridge IPs. Ideally, -/// we'd keep track of the current API IP, not exonerate all bridges from being considered -/// leaky. -#[macro_export] -macro_rules! get_possible_api_endpoints { - ($mullvad_client:expr) => {{ - use std::net::ToSocketAddrs; - - let mut api_endpoints = vec![ - "api.devmole.eu:0" - .to_socket_addrs() - .expect("failed to resolve api.devmole.eu") - .next() - .unwrap() - .ip(), - "api.stagemole.eu:0" - .to_socket_addrs() - .expect("failed to resolve api.stagemole.eu") - .next() - .unwrap() - .ip(), - "api.mullvad.net:0" - .to_socket_addrs() - .expect("failed to resolve api.mullvad.net") - .next() - .unwrap() - .ip(), - IpAddr::V4(Ipv4Addr::new(45, 83, 223, 196)), - ]; - - let relay_list = $mullvad_client - .get_relay_locations(()) - .await - .map_err(|error| Error::DaemonError(format!("Failed to obtain relay list: {}", error)))? - .into_inner(); - - api_endpoints.extend( - relay_list - .countries - .into_iter() - .flat_map(|country| country.cities) - .filter_map(|mut city| { - city.relays.retain(|relay| { - relay.active - && relay.endpoint_type == (types::relay::RelayType::Bridge as i32) - }); - if !city.relays.is_empty() { - Some(city) - } else { - None - } - }) - .flat_map(|city| { - city.relays - .into_iter() - .map(|relay| IpAddr::V4(relay.ipv4_addr_in.parse().expect("invalid IP"))) - }), - ); - - Ok::, Error>(api_endpoints) - }}; -} - pub fn get_package_desc(name: &str) -> Result { Ok(Package { path: Path::new(&TEST_CONFIG.artifacts_dir).join(name), diff --git a/test/test-manager/src/tests/install.rs b/test/test-manager/src/tests/install.rs index 25c58e389bc3..3b282e764861 100644 --- a/test/test-manager/src/tests/install.rs +++ b/test/test-manager/src/tests/install.rs @@ -1,14 +1,14 @@ use super::helpers::{get_package_desc, ping_with_timeout, AbortOnDrop}; use super::{Error, TestContext}; -use crate::get_possible_api_endpoints; use super::config::TEST_CONFIG; use crate::network_monitor::{start_packet_monitor, MonitorOptions}; use mullvad_management_interface::types; +use once_cell::sync::Lazy; use std::collections::HashMap; use std::net::ToSocketAddrs; use std::{ - net::{IpAddr, Ipv4Addr, SocketAddr}, + net::{IpAddr, SocketAddr}, time::Duration, }; use test_macro::test_function; @@ -53,8 +53,13 @@ pub async fn test_install_previous_app(_: TestContext, rpc: ServiceClient) -> Re pub async fn test_upgrade_app( ctx: TestContext, rpc: ServiceClient, - mut mullvad_client: old_mullvad_management_interface::ManagementServiceClient, ) -> Result<(), Error> { + // Parse api-addrs.txt + const API_ADDRS: Lazy> = Lazy::new(|| { + const API_ADDRS: &str = std::include_str!("../../api-addrs.txt"); + API_ADDRS.split('\n').map(|addr| addr.parse().unwrap()).collect() + }); + let inet_destination: SocketAddr = "1.1.1.1:1337".parse().unwrap(); let bind_addr: SocketAddr = "0.0.0.0:0".parse().unwrap(); @@ -79,48 +84,15 @@ pub async fn test_upgrade_app( // log::debug!("Entering blocking error state"); - mullvad_client - .update_relay_settings( - old_mullvad_management_interface::types::RelaySettingsUpdate { - r#type: Some( - old_mullvad_management_interface::types::relay_settings_update::Type::Normal( - old_mullvad_management_interface::types::NormalRelaySettingsUpdate { - location: Some( - old_mullvad_management_interface::types::RelayLocation { - country: "xx".to_string(), - city: "".to_string(), - hostname: "".to_string(), - }, - ), - ..Default::default() - }, - ), - ), - }, - ) - .await - .map_err(|error| Error::DaemonError(format!("Failed to set relay settings: {}", error)))?; + rpc.exec("mullvad", ["relay", "set", "location", "xx"]).await.expect("Failed to set relay location"); + rpc.exec("mullvad", ["connect"]).await.expect("Failed to begin connecting"); - // cannot use the event listener due since the proto file is incompatible - mullvad_client - .connect_tunnel(()) - .await - .expect("failed to begin connecting"); tokio::time::timeout(super::WAIT_FOR_TUNNEL_STATE_TIMEOUT, async { + // use polling for sake of simplicity loop { - // use polling for sake of simplicity - if matches!( - mullvad_client - .get_tunnel_state(()) - .await - .expect("RPC error") - .into_inner(), - old_mullvad_management_interface::types::TunnelState { - state: Some( - old_mullvad_management_interface::types::tunnel_state::State::Error { .. } - ), - } - ) { + const FIND_SLICE: &[u8] = b"Blocked:"; + let result = rpc.exec("mullvad", ["status"]).await.expect("Failed to poll tunnel status"); + if result.stdout.windows(FIND_SLICE.len()).any(|subslice| subslice == FIND_SLICE) { break; } tokio::time::sleep(Duration::from_secs(1)).await; @@ -139,13 +111,11 @@ pub async fn test_upgrade_app( .expect("failed to obtain tunnel IP"); log::debug!("Guest IP: {guest_ip}"); - let api_endpoints = get_possible_api_endpoints!(&mut mullvad_client)?; - log::debug!("Monitoring outgoing traffic"); let monitor = start_packet_monitor( move |packet| { - packet.source.ip() == guest_ip && !api_endpoints.contains(&packet.destination.ip()) + packet.source.ip() == guest_ip && !API_ADDRS.contains(&packet.destination.ip()) }, MonitorOptions::default(), ) @@ -185,7 +155,6 @@ pub async fn test_upgrade_app( "observed unexpected packets from {guest_ip}" ); - drop(mullvad_client); let mut mullvad_client = ctx.rpc_provider.new_client().await; // check if settings were (partially) preserved diff --git a/test/test-manager/test_macro/src/lib.rs b/test/test-manager/test_macro/src/lib.rs index fd8e957d4807..461840469594 100644 --- a/test/test-manager/test_macro/src/lib.rs +++ b/test/test-manager/test_macro/src/lib.rs @@ -4,7 +4,6 @@ //! rpc: ServiceClient, //! mut mullvad_client: mullvad_management_interface::ManagementServiceClient, //! ) -> Result<(), Error> { -//! The `mullvad_client` argument can be removed or replaced with the `old_mullvad_management_interface` version. //! The `test_function` macro takes 4 optional arguments //! #[test_function(priority = -1337, cleanup = false, must_succeed = true, always_run = true)] //! @@ -118,10 +117,6 @@ fn create_test(test_function: TestFunction) -> proc_macro2::TokenStream { MullvadClient::New { mullvad_client_type, .. - } - | MullvadClient::Old { - mullvad_client_type, - .. } => { let mullvad_client_type = *mullvad_client_type; quote! { @@ -185,10 +180,6 @@ enum MullvadClient { mullvad_client_type: Box, mullvad_client_version: proc_macro2::TokenStream, }, - Old { - mullvad_client_type: Box, - mullvad_client_version: proc_macro2::TokenStream, - }, } impl MullvadClient { @@ -201,10 +192,6 @@ impl MullvadClient { mullvad_client_version, .. } => mullvad_client_version.clone(), - MullvadClient::Old { - mullvad_client_version, - .. - } => mullvad_client_version.clone(), } } } @@ -230,13 +217,6 @@ fn get_test_function_parameters( mullvad_client_version, } } - "old_mullvad_management_interface" => { - let mullvad_client_version = quote! { test_rpc::mullvad_daemon::MullvadClientVersion::Previous }; - MullvadClient::Old { - mullvad_client_type: pat_type.ty, - mullvad_client_version, - } - } _ => panic!("cannot infer mullvad client type"), } } diff --git a/test/test-rpc/src/client.rs b/test/test-rpc/src/client.rs index 4b763ce167ff..387d0a2435d1 100644 --- a/test/test-rpc/src/client.rs +++ b/test/test-rpc/src/client.rs @@ -55,7 +55,7 @@ impl ServiceClient { /// Execute a program. pub async fn exec_env< - I: Iterator, + I: IntoIterator, M: IntoIterator, T: AsRef, K: AsRef, @@ -80,7 +80,7 @@ impl ServiceClient { } /// Execute a program. - pub async fn exec, T: AsRef>( + pub async fn exec, T: AsRef>( &self, path: T, args: I, diff --git a/test/test-rpc/src/mullvad_daemon.rs b/test/test-rpc/src/mullvad_daemon.rs index 3c98fdf2937b..10cc00c3fc96 100644 --- a/test/test-rpc/src/mullvad_daemon.rs +++ b/test/test-rpc/src/mullvad_daemon.rs @@ -31,5 +31,4 @@ pub enum Verbosity { pub enum MullvadClientVersion { None, New, - Previous, }