summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorJoakim Hulthe <joakim@hulthe.net>2024-03-06 14:02:55 +0100
committerJoakim Hulthe <joakim@hulthe.net>2024-03-20 16:50:15 +0100
commit17814ac1ecd589aaaff66be816bf375c8f707b09 (patch)
treecbf4659121fa2ec116e1d26fe25718f197fc9335 /test
parent69d2c506d34cf944812ef65d695bb7c882e764ab (diff)
downloadmullvadvpn-17814ac1ecd589aaaff66be816bf375c8f707b09.tar.xz
mullvadvpn-17814ac1ecd589aaaff66be816bf375c8f707b09.zip
Add am-i-mullvad cli for testing split tunneling
Diffstat (limited to 'test')
-rw-r--r--test/Cargo.lock168
-rw-r--r--test/Cargo.toml8
-rw-r--r--test/am-i-mullvad/Cargo.toml17
-rw-r--r--test/am-i-mullvad/src/main.rs33
-rwxr-xr-xtest/build.sh5
-rwxr-xr-xtest/scripts/build-runner-image.sh1
6 files changed, 225 insertions, 7 deletions
diff --git a/test/Cargo.lock b/test/Cargo.lock
index 60ab48547b..09ec93e782 100644
--- a/test/Cargo.lock
+++ b/test/Cargo.lock
@@ -62,6 +62,16 @@ dependencies = [
]
[[package]]
+name = "am-i-mullvad"
+version = "0.0.0"
+dependencies = [
+ "color-eyre",
+ "eyre",
+ "reqwest",
+ "serde",
+]
+
+[[package]]
name = "android-tzdata"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -464,6 +474,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961"
[[package]]
+name = "color-eyre"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a667583cca8c4f8436db8de46ea8233c42a7d9ae424a82d338f2e4675229204"
+dependencies = [
+ "backtrace",
+ "color-spantrace",
+ "eyre",
+ "indenter",
+ "once_cell",
+ "owo-colors",
+ "tracing-error",
+]
+
+[[package]]
+name = "color-spantrace"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2"
+dependencies = [
+ "once_cell",
+ "owo-colors",
+ "tracing-core",
+ "tracing-error",
+]
+
+[[package]]
name = "colorchoice"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -746,6 +783,15 @@ dependencies = [
]
[[package]]
+name = "encoding_rs"
+version = "0.8.33"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1"
+dependencies = [
+ "cfg-if",
+]
+
+[[package]]
name = "enum-as-inner"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -822,6 +868,16 @@ dependencies = [
]
[[package]]
+name = "eyre"
+version = "0.6.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec"
+dependencies = [
+ "indenter",
+ "once_cell",
+]
+
+[[package]]
name = "fast-socks5"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1197,7 +1253,7 @@ dependencies = [
"rustls-native-certs",
"tokio",
"tokio-rustls",
- "webpki-roots",
+ "webpki-roots 0.23.1",
]
[[package]]
@@ -1246,6 +1302,12 @@ dependencies = [
]
[[package]]
+name = "indenter"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
+
+[[package]]
name = "indexmap"
version = "1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1944,6 +2006,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
[[package]]
+name = "owo-colors"
+version = "3.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
+
+[[package]]
name = "p256"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2465,6 +2533,47 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
[[package]]
+name = "reqwest"
+version = "0.11.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251"
+dependencies = [
+ "base64 0.21.4",
+ "bytes",
+ "encoding_rs",
+ "futures-core",
+ "futures-util",
+ "h2",
+ "http",
+ "http-body",
+ "hyper",
+ "hyper-rustls",
+ "ipnet",
+ "js-sys",
+ "log",
+ "mime",
+ "once_cell",
+ "percent-encoding",
+ "pin-project-lite",
+ "rustls",
+ "rustls-pemfile 1.0.3",
+ "serde",
+ "serde_json",
+ "serde_urlencoded",
+ "sync_wrapper",
+ "system-configuration",
+ "tokio",
+ "tokio-rustls",
+ "tower-service",
+ "url",
+ "wasm-bindgen",
+ "wasm-bindgen-futures",
+ "web-sys",
+ "webpki-roots 0.25.4",
+ "winreg",
+]
+
+[[package]]
name = "resolv-conf"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2710,18 +2819,18 @@ dependencies = [
[[package]]
name = "serde"
-version = "1.0.188"
+version = "1.0.197"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e"
+checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.188"
+version = "1.0.197"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
+checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
dependencies = [
"proc-macro2",
"quote",
@@ -3007,6 +3116,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
[[package]]
+name = "system-configuration"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7"
+dependencies = [
+ "bitflags 1.3.2",
+ "core-foundation",
+ "system-configuration-sys",
+]
+
+[[package]]
+name = "system-configuration-sys"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
+
+[[package]]
name = "talpid-dbus"
version = "0.0.0"
dependencies = [
@@ -3554,6 +3684,16 @@ dependencies = [
]
[[package]]
+name = "tracing-error"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e"
+dependencies = [
+ "tracing",
+ "tracing-subscriber",
+]
+
+[[package]]
name = "tracing-opentelemetry"
version = "0.17.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3794,6 +3934,18 @@ dependencies = [
]
[[package]]
+name = "wasm-bindgen-futures"
+version = "0.4.37"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03"
+dependencies = [
+ "cfg-if",
+ "js-sys",
+ "wasm-bindgen",
+ "web-sys",
+]
+
+[[package]]
name = "wasm-bindgen-macro"
version = "0.2.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3842,6 +3994,12 @@ dependencies = [
]
[[package]]
+name = "webpki-roots"
+version = "0.25.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1"
+
+[[package]]
name = "which"
version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/test/Cargo.toml b/test/Cargo.toml
index 977f9082d8..4c23a55eb0 100644
--- a/test/Cargo.toml
+++ b/test/Cargo.toml
@@ -7,7 +7,13 @@ rust-version = "1.75.0"
[workspace]
resolver = "2"
-members = ["test-manager", "test-runner", "test-rpc", "socks-server"]
+members = [
+ "test-manager",
+ "test-runner",
+ "test-rpc",
+ "socks-server",
+ "am-i-mullvad",
+]
[workspace.lints.rust]
rust_2018_idioms = "deny"
diff --git a/test/am-i-mullvad/Cargo.toml b/test/am-i-mullvad/Cargo.toml
new file mode 100644
index 0000000000..c3bda1b1cb
--- /dev/null
+++ b/test/am-i-mullvad/Cargo.toml
@@ -0,0 +1,17 @@
+[package]
+name = "am-i-mullvad"
+description = "Simple cli for testing Mullvad VPN connections"
+authors.workspace = true
+repository.workspace = true
+license.workspace = true
+edition.workspace = true
+rust-version.workspace = true
+
+[lints]
+workspace = true
+
+[dependencies]
+color-eyre = "0.6.2"
+eyre = "0.6.12"
+reqwest = { version = "0.11.24", default-features = false, features = ["blocking", "rustls-tls", "json"] }
+serde = { version = "1.0.197", features = ["derive"] }
diff --git a/test/am-i-mullvad/src/main.rs b/test/am-i-mullvad/src/main.rs
new file mode 100644
index 0000000000..c6cc272d30
--- /dev/null
+++ b/test/am-i-mullvad/src/main.rs
@@ -0,0 +1,33 @@
+use eyre::{eyre, Context};
+use reqwest::blocking::get;
+use serde::Deserialize;
+use std::process;
+
+#[derive(Debug, Deserialize)]
+struct Response {
+ ip: String,
+ mullvad_exit_ip_hostname: Option<String>,
+}
+
+fn main() -> eyre::Result<()> {
+ color_eyre::install()?;
+
+ let url = "https://am.i.mullvad.net/json";
+ let response: Response = get(url)
+ .and_then(|r| r.json())
+ .wrap_err_with(|| eyre!("Failed to GET {url}"))?;
+
+ if let Some(server) = &response.mullvad_exit_ip_hostname {
+ println!(
+ "You are connected to Mullvad (server {}). Your IP address is {}",
+ server, response.ip
+ );
+ Ok(())
+ } else {
+ println!(
+ "You are not connected to Mullvad. Your IP address is {}",
+ response.ip
+ );
+ process::exit(1)
+ }
+}
diff --git a/test/build.sh b/test/build.sh
index 2a8f7c7063..1f0099ccf4 100755
--- a/test/build.sh
+++ b/test/build.sh
@@ -19,7 +19,10 @@ if [[ $TARGET == x86_64-unknown-linux-gnu ]]; then
mullvadvpn-app-tests \
/bin/bash -c "cd /src/test/; cargo build --bin test-runner --release --target ${TARGET}"
else
- cargo build --bin test-runner --release --target "${TARGET}"
+ cargo build \
+ --bin test-runner \
+ --bin am-i-mullvad \
+ --release --target "${TARGET}"
fi
# Only build runner image for Windows
diff --git a/test/scripts/build-runner-image.sh b/test/scripts/build-runner-image.sh
index fe8077b337..be0d637323 100755
--- a/test/scripts/build-runner-image.sh
+++ b/test/scripts/build-runner-image.sh
@@ -33,6 +33,7 @@ case $TARGET in
mcopy \
-i "${TEST_RUNNER_IMAGE_PATH}" \
"${SCRIPT_DIR}/../target/$TARGET/release/test-runner.exe" \
+ "${SCRIPT_DIR}/../target/$TARGET/release/am-i-mullvad.exe" \
"${PACKAGES_DIR}/"*.exe \
"${SCRIPT_DIR}/../openvpn.ca.crt" \
"::"