Skip to content

Commit

Permalink
Set the default location for tests to "Nordic"
Browse files Browse the repository at this point in the history
Add to `prepare_daemon` a step where the default location,
including for multihop and bridges, is set to the `Nordic`
custom list.
  • Loading branch information
Serock3 committed Nov 18, 2024
1 parent 1c4fd9c commit eeff5bb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/test-manager/src/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1201,12 +1201,16 @@ fn parse_am_i_mullvad(result: String) -> anyhow::Result<bool> {

pub mod custom_lists {
use super::*;

use mullvad_types::custom_list::{CustomList, Id};
use std::sync::{LazyLock, Mutex};

// Expose all custom list variants as a shorthand.
pub use List::*;

/// The default custom list to use as location for all tests.
pub const DEFAULT_LIST: List = List::Nordic;

/// Mapping between [List] to daemon custom lists. Since custom list ids are assigned by the
/// daemon at the creation of the custom list settings object, we can't map a custom list
/// name to a specific list before runtime.
Expand Down Expand Up @@ -1310,6 +1314,34 @@ pub mod custom_lists {
Ok(())
}

/// Set the default location to the custom list specified by `DEFAULT_LIST`. This also includes
/// entry location for multihop. It does not, however, affect bridge location for OpenVPN.
/// This is for simplify, as bridges default to using the server closest to the exit anyway, and
/// OpenVPN is slated for removal.
pub async fn set_default_location(
mullvad_client: &mut MullvadProxyClient,
) -> anyhow::Result<()> {
let constraints = dbg!(get_custom_list_location_relay_constraints(DEFAULT_LIST));

mullvad_client
.set_relay_settings(constraints.into())
.await
.context("Failed to set relay settings")
}

fn get_custom_list_location_relay_constraints(custom_list: List) -> RelayConstraints {
let wireguard_constraints = mullvad_types::relay_constraints::WireguardConstraints {
entry_location: Constraint::Only(custom_list.into()),
..Default::default()
};

RelayConstraints {
location: Constraint::Only(custom_list.into()),
wireguard_constraints,
..Default::default()
}
}

/// Dig out a custom list from the daemon settings based on the custom list's name.
/// There should be an rpc for this.
async fn find_custom_list(
Expand Down
1 change: 1 addition & 0 deletions test/test-manager/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ pub async fn prepare_daemon(
.context("Failed to disconnect daemon after test")?;
helpers::ensure_logged_in(&mut mullvad_client).await?;
helpers::custom_lists::add_default_lists(&mut mullvad_client).await?;
helpers::custom_lists::set_default_location(&mut mullvad_client).await?;

Ok(())
}
Expand Down

0 comments on commit eeff5bb

Please sign in to comment.