From 6e121e1fe3440a08fa7d8ab243541c3af570a549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20L=C3=B6nnhager?= Date: Wed, 17 Jan 2024 09:56:38 +0100 Subject: [PATCH 1/3] Make changelog link static in test --- test/test-manager/src/tests/install.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-manager/src/tests/install.rs b/test/test-manager/src/tests/install.rs index c6d362825ee9..f086385f2119 100644 --- a/test/test-manager/src/tests/install.rs +++ b/test/test-manager/src/tests/install.rs @@ -277,7 +277,7 @@ pub async fn test_install_new_app(_: TestContext, rpc: ServiceClient) -> Result< /// /// This test is supposed to guard against regressions to this fix included in /// the 2021.3-beta1 release: -/// https://github.com/mullvad/mullvadvpn-app/blob/main/CHANGELOG.md#security-10 +/// https://github.com/mullvad/mullvadvpn-app/blob/2021.3-beta1/CHANGELOG.md#security #[test_function(priority = -150)] pub async fn test_installation_idempotency( _: TestContext, From 56fb54f6407bed6b53d8abb47f8772fb01e33ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20L=C3=B6nnhager?= Date: Wed, 17 Jan 2024 10:45:41 +0100 Subject: [PATCH 2/3] Return specific error when connect_and_wait fails due to entering the error state --- test/test-manager/src/tests/helpers.rs | 9 +++++---- test/test-manager/src/tests/mod.rs | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test/test-manager/src/tests/helpers.rs b/test/test-manager/src/tests/helpers.rs index 30f89267ccf9..3956aa2c158f 100644 --- a/test/test-manager/src/tests/helpers.rs +++ b/test/test-manager/src/tests/helpers.rs @@ -191,8 +191,9 @@ pub async fn ping_with_timeout( /// Try to connect to a Mullvad Tunnel. /// -/// If that fails for whatever reason, the Mullvad daemon ends up in the -/// [`TunnelState::Error`] state & [`Error::DaemonError`] is returned. +/// If that fails to begin to connect, [`Error::DaemonError`] is returned. If it fails to connect +/// after that, the daemon ends up in the [`TunnelState::Error`] state, and +/// [`Error::UnexpectedErrorState`] is returned. pub async fn connect_and_wait(mullvad_client: &mut MullvadProxyClient) -> Result<(), Error> { log::info!("Connecting"); @@ -209,8 +210,8 @@ pub async fn connect_and_wait(mullvad_client: &mut MullvadProxyClient) -> Result }) .await?; - if matches!(new_state, TunnelState::Error(..)) { - return Err(Error::Daemon("daemon entered error state".to_string())); + if let TunnelState::Error(error_state) = new_state { + return Err(Error::UnexpectedErrorState(error_state)); } log::info!("Connected"); diff --git a/test/test-manager/src/tests/mod.rs b/test/test-manager/src/tests/mod.rs index 8bebfe13dfa6..c79c0318e085 100644 --- a/test/test-manager/src/tests/mod.rs +++ b/test/test-manager/src/tests/mod.rs @@ -58,6 +58,9 @@ pub enum Error { #[error(display = "The daemon returned an error: {}", _0)] Daemon(String), + #[error(display = "The daemon ended up in the error state")] + UnexpectedErrorState(talpid_types::tunnel::ErrorState), + #[error(display = "The gRPC client ran into an error: {}", _0)] ManagementInterface(#[source] mullvad_management_interface::Error), From 303c8d26864c3de555f3053e41070cda27cb4982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20L=C3=B6nnhager?= Date: Wed, 17 Jan 2024 09:57:02 +0100 Subject: [PATCH 3/3] Make test_installation_idempotency succeed when there is no account --- test/test-manager/src/tests/install.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/test-manager/src/tests/install.rs b/test/test-manager/src/tests/install.rs index f086385f2119..614b9d9bb93d 100644 --- a/test/test-manager/src/tests/install.rs +++ b/test/test-manager/src/tests/install.rs @@ -284,8 +284,13 @@ pub async fn test_installation_idempotency( rpc: ServiceClient, mut mullvad_client: MullvadProxyClient, ) -> Result<(), Error> { - // Connect to any relay - connect_and_wait(&mut mullvad_client).await?; + // Connect to any relay. This forces the daemon to enter a secured target state + connect_and_wait(&mut mullvad_client) + .await + .or_else(|error| match error { + Error::UnexpectedErrorState(_) => Ok(()), + err => Err(err), + })?; // Disable auto-connect mullvad_client .set_auto_connect(false) @@ -302,8 +307,8 @@ pub async fn test_installation_idempotency( log::debug!("Installing new app"); rpc.install_app(get_package_desc(&TEST_CONFIG.current_app_filename)?) .await?; - // verify that daemon is running - wait_for_tunnel_state(mullvad_client.clone(), |state| state.is_connected()) + // verify that the daemon starts in a non-disconnected state + wait_for_tunnel_state(mullvad_client.clone(), |state| !state.is_disconnected()) .await .map_err(|err| { log::error!(