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 15, 2024
1 parent 7be178c commit 096994a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/test-manager/src/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1199,12 +1199,16 @@ fn parse_am_i_mullvad(result: String) -> anyhow::Result<bool> {

pub mod custom_lists {
use super::*;
use mullvad_relay_selector::query::builder::RelayQueryBuilder;
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 @@ -1308,6 +1312,32 @@ pub mod custom_lists {
Ok(())
}

/// Set the default location to the custom list specified by `DEFAULT_LIST`. This includes entry
/// location for multihop and bridge location for OpenVPN.
pub async fn set_default_location(
mullvad_client: &mut MullvadProxyClient,
) -> anyhow::Result<()> {
let mut query = RelayQueryBuilder::new()
.location(DEFAULT_LIST)
.wireguard()
.multihop()
.entry(DEFAULT_LIST)
.build();

// The typestate query builder cannot express openVPN bridge locations while specifying
// wireguard options, like multihop. So we need to create a new query for openVPN, and
// insert the OpenVPN constraints into the existing query.
let openvpn_constraints = RelayQueryBuilder::new()
.openvpn()
.bridge()
.bridge_location(DEFAULT_LIST)
.build()
.into_openvpn_constraints();
query.set_openvpn_constraints(openvpn_constraints)?;

apply_settings_from_relay_query(mullvad_client, query).await?;
Ok(())
}
/// 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 @@ -122,6 +122,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 096994a

Please sign in to comment.