summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2024-04-19 11:42:12 +0200
committerOskar Nyberg <oskar@mullvad.net>2024-04-19 11:42:12 +0200
commiteced1187524fb2d56341fa17749002cf9ed0df1c (patch)
tree7b4513be33bb6b037584a104ba4ec4a13a57a390 /test
parentf9e4201c906f1591ba8ae56eabacd69bbe9a0652 (diff)
parent9931f2c602ac9028bba7a05f52b86d707d77043f (diff)
downloadmullvadvpn-eced1187524fb2d56341fa17749002cf9ed0df1c.tar.xz
mullvadvpn-eced1187524fb2d56341fa17749002cf9ed0df1c.zip
Merge branch 'add-custom-bridge-test-des-820'
Diffstat (limited to 'test')
-rw-r--r--test/test-manager/src/tests/helpers.rs15
-rw-r--r--test/test-manager/src/tests/ui.rs74
2 files changed, 82 insertions, 7 deletions
diff --git a/test/test-manager/src/tests/helpers.rs b/test/test-manager/src/tests/helpers.rs
index da50679a26..b733939da0 100644
--- a/test/test-manager/src/tests/helpers.rs
+++ b/test/test-manager/src/tests/helpers.rs
@@ -249,6 +249,21 @@ pub async fn login_with_retries(
}
}
+/// Ensure that the test runner is logged in to an account.
+///
+/// This will first check whether we are logged in. If not, it will also try to login
+/// on your behalf. If this function returns without any errors, we are logged in to a valid
+/// account.
+pub async fn ensure_logged_in(
+ mullvad_client: &mut MullvadProxyClient,
+) -> Result<(), mullvad_management_interface::Error> {
+ if mullvad_client.get_device().await?.is_logged_in() {
+ return Ok(());
+ }
+ // We are apparently not logged in already.. Try to log in.
+ login_with_retries(mullvad_client).await
+}
+
/// Try to connect to a Mullvad Tunnel.
///
/// # Returns
diff --git a/test/test-manager/src/tests/ui.rs b/test/test-manager/src/tests/ui.rs
index cce7cdd990..7adaf432af 100644
--- a/test/test-manager/src/tests/ui.rs
+++ b/test/test-manager/src/tests/ui.rs
@@ -1,4 +1,8 @@
-use super::{config::TEST_CONFIG, helpers, Error, TestContext};
+use super::{
+ config::TEST_CONFIG,
+ helpers::{self, ensure_logged_in},
+ Error, TestContext,
+};
use mullvad_management_interface::MullvadProxyClient;
use mullvad_relay_selector::query::builder::RelayQueryBuilder;
use std::{
@@ -125,7 +129,7 @@ pub async fn test_ui_login(_: TestContext, rpc: ServiceClient) -> Result<(), Err
Ok(())
}
-#[test_function(priority = 1000, must_succeed = true)]
+#[test_function(priority = 1000)]
async fn test_custom_access_methods_gui(
_: TestContext,
rpc: ServiceClient,
@@ -196,13 +200,69 @@ async fn test_custom_access_methods_gui(
assert!(ui_result.success());
- // Reset the `api-override` feature.
- tokio::time::timeout(
- std::time::Duration::from_secs(60),
- rpc.set_daemon_environment(helpers::get_app_env()),
+ Ok(())
+}
+
+#[test_function(priority = 1000)]
+async fn test_custom_bridge_gui(
+ _: TestContext,
+ rpc: ServiceClient,
+ mut mullvad_client: MullvadProxyClient,
+) -> Result<(), Error> {
+ use mullvad_relay_selector::{RelaySelector, SelectorConfig};
+ use talpid_types::net::proxy::CustomProxy;
+ // For this test to work, we need to supply the following env-variables:
+ //
+ // * SHADOWSOCKS_SERVER_IP
+ // * SHADOWSOCKS_SERVER_PORT
+ // * SHADOWSOCKS_SERVER_CIPHER
+ // * SHADOWSOCKS_SERVER_PASSWORD
+ //
+ // See `gui/test/e2e/installed/state-dependent/custom-bridge.spec.ts`
+ // for details. The setup should be the same as in
+ // `test_manager::tests::access_methods::test_shadowsocks`.
+ //
+ // # Note
+ // The test requires the app to already be logged in.
+
+ ensure_logged_in(&mut mullvad_client)
+ .await
+ .expect("ensure_logged_in failed");
+
+ let gui_test = "custom-bridge.spec";
+ let relay_list = mullvad_client.get_relay_locations().await.unwrap();
+ let relay_selector = RelaySelector::from_list(SelectorConfig::default(), relay_list);
+ let custom_proxy = relay_selector
+ .get_bridge_forced()
+ .and_then(|proxy| match proxy {
+ CustomProxy::Shadowsocks(s) => Some(s),
+ _ => None
+ })
+ .expect("`test_shadowsocks` needs at least one shadowsocks relay to execute. Found none in relay list.");
+
+ let ui_result = run_test_env(
+ &rpc,
+ &[gui_test],
+ [
+ (
+ "SHADOWSOCKS_SERVER_IP",
+ custom_proxy.endpoint.ip().to_string().as_ref(),
+ ),
+ (
+ "SHADOWSOCKS_SERVER_PORT",
+ custom_proxy.endpoint.port().to_string().as_ref(),
+ ),
+ ("SHADOWSOCKS_SERVER_CIPHER", custom_proxy.cipher.as_ref()),
+ (
+ "SHADOWSOCKS_SERVER_PASSWORD",
+ custom_proxy.password.as_ref(),
+ ),
+ ],
)
.await
- .map_err(|_| Error::DaemonNotRunning)??;
+ .unwrap();
+
+ assert!(ui_result.success());
Ok(())
}