summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2024-04-08 17:03:20 +0200
committerDavid Lönnhager <david.l@mullvad.net>2024-04-30 16:22:52 +0200
commit876f9cb5d5abf3e4d56cce5aee3597fdb5ad14e3 (patch)
treeb9fb86ea0c1eca3be9bc6fccfd31b45c4c175ea9
parentbd5aebe29f246cec84c4174a03151b53bf3a9945 (diff)
downloadmullvadvpn-876f9cb5d5abf3e4d56cce5aee3597fdb5ad14e3.tar.xz
mullvadvpn-876f9cb5d5abf3e4d56cce5aee3597fdb5ad14e3.zip
Enable integration tests for macOS split tunneling
-rw-r--r--test/test-manager/src/tests/helpers.rs10
-rw-r--r--test/test-manager/src/tests/mod.rs2
-rw-r--r--test/test-manager/src/tests/split_tunnel.rs14
3 files changed, 21 insertions, 5 deletions
diff --git a/test/test-manager/src/tests/helpers.rs b/test/test-manager/src/tests/helpers.rs
index b733939da0..fbf447df5d 100644
--- a/test/test-manager/src/tests/helpers.rs
+++ b/test/test-manager/src/tests/helpers.rs
@@ -828,6 +828,10 @@ impl ConnChecker {
.await?;
}
+ // TODO: The ST process monitor is a bit racy on macOS, such that processes aren't
+ // immediately recognized. This is a workaround until fixed.
+ tokio::time::sleep(std::time::Duration::from_secs(1)).await;
+
Ok(ConnCheckerHandle { pid, checker: self })
}
@@ -838,13 +842,12 @@ impl ConnChecker {
match TEST_CONFIG.os {
Os::Linux => { /* linux programs can't be split until they are spawned */ }
- Os::Windows => {
+ Os::Macos | Os::Windows => {
self.mullvad_client
.add_split_tunnel_app(&self.executable_path)
.await?;
self.mullvad_client.set_split_tunnel_state(true).await?;
}
- Os::Macos => unimplemented!("MacOS"),
}
Ok(())
@@ -857,13 +860,12 @@ impl ConnChecker {
match TEST_CONFIG.os {
Os::Linux => {}
- Os::Windows => {
+ Os::Macos | Os::Windows => {
self.mullvad_client.set_split_tunnel_state(false).await?;
self.mullvad_client
.remove_split_tunnel_app(&self.executable_path)
.await?;
}
- Os::Macos => unimplemented!("MacOS"),
}
Ok(())
diff --git a/test/test-manager/src/tests/mod.rs b/test/test-manager/src/tests/mod.rs
index ce38308b0d..8db87e4eae 100644
--- a/test/test-manager/src/tests/mod.rs
+++ b/test/test-manager/src/tests/mod.rs
@@ -96,6 +96,8 @@ pub async fn cleanup_after_test(
tunnel_options,
relay_overrides,
show_beta_releases,
+ #[cfg(target_os = "macos")]
+ split_tunnel: _,
settings_version: _, // N/A
} = Default::default();
diff --git a/test/test-manager/src/tests/split_tunnel.rs b/test/test-manager/src/tests/split_tunnel.rs
index 609acf7ac8..3823e285f7 100644
--- a/test/test-manager/src/tests/split_tunnel.rs
+++ b/test/test-manager/src/tests/split_tunnel.rs
@@ -2,6 +2,7 @@ use anyhow::Context;
use mullvad_management_interface::MullvadProxyClient;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use test_macro::test_function;
+use test_rpc::meta::OsVersion;
use test_rpc::ServiceClient;
use super::{
@@ -15,12 +16,22 @@ const LEAK_DESTINATION: SocketAddr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(1,
/// - Splitting a process shouldn't do anything if tunnel is not connected.
/// - A split process should never push traffic through the tunnel.
/// - Splitting/unsplitting should work regardless if process is running.
-#[test_function(target_os = "linux", target_os = "windows")]
+#[test_function]
pub async fn test_split_tunnel(
_ctx: TestContext,
rpc: ServiceClient,
mut mullvad_client: MullvadProxyClient,
) -> anyhow::Result<()> {
+ // Skip test on macOS 12, since the feature is unsupported
+ match rpc.get_os_version().await.context("Detect OS version")? {
+ OsVersion::Macos(version) if version.major <= 12 => {
+ // TODO: Skip test cleanly, e.g. by returning a result `Pass | Skip`
+ log::info!("Skipping test on macOS 12");
+ return Ok(());
+ }
+ _ => (),
+ }
+
let mut checker = ConnChecker::new(rpc.clone(), mullvad_client.clone(), LEAK_DESTINATION);
// Test that program is behaving when we are disconnected
@@ -53,6 +64,7 @@ pub async fn test_split_tunnel(
// Test running a split program
checker.split().await?;
+
checker
.spawn()
.await?