Skip to content

Commit 023a51d

Browse files
committed
Add ensure_logged_in test helper function
1 parent 189b1a8 commit 023a51d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/test-manager/src/tests/helpers.rs

+15
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,21 @@ pub async fn login_with_retries(
249249
}
250250
}
251251

252+
/// Ensure that the test runner is logged in to an account.
253+
///
254+
/// This will first check whether we are logged in. If not, it will also try to login
255+
/// on your behalf. If this function returns without any errors, we are logged in to a valid
256+
/// account.
257+
pub async fn ensure_logged_in(
258+
mullvad_client: &mut MullvadProxyClient,
259+
) -> Result<(), mullvad_management_interface::Error> {
260+
if mullvad_client.get_device().await?.is_logged_in() {
261+
return Ok(());
262+
}
263+
// We are apparently not logged in already.. Try to log in.
264+
login_with_retries(mullvad_client).await
265+
}
266+
252267
/// Try to connect to a Mullvad Tunnel.
253268
///
254269
/// # Returns

0 commit comments

Comments
 (0)