diff options
| author | Oskar <oskar@mullvad.net> | 2025-02-14 16:40:33 +0100 |
|---|---|---|
| committer | Oskar <oskar@mullvad.net> | 2025-02-14 16:40:33 +0100 |
| commit | 083d06db318ebdcb670d5b1ad5662a4c9df417c2 (patch) | |
| tree | a1345edac65a600d3f6ed34edb61ac7c6457bad1 | |
| parent | c029561136bac007ba5dd350f5e3b60e703a2e42 (diff) | |
| parent | 8e721e69dee35ef90a6b5b4b9d6caa0ae33a8256 (diff) | |
| download | mullvadvpn-083d06db318ebdcb670d5b1ad5662a4c9df417c2.tar.xz mullvadvpn-083d06db318ebdcb670d5b1ad5662a4c9df417c2.zip | |
Merge branch 'improve-tunnel-state-test'
4 files changed, 89 insertions, 58 deletions
diff --git a/.github/workflows/git-commit-message-style.yml b/.github/workflows/git-commit-message-style.yml index 622c2c093f..04816d30c8 100644 --- a/.github/workflows/git-commit-message-style.yml +++ b/.github/workflows/git-commit-message-style.yml @@ -34,4 +34,4 @@ jobs: # This action defaults to 50 char subjects, but 72 is fine. max-subject-line-length: '72' # The action's wordlist is a bit short. Add more accepted verbs - additional-verbs: 'tidy, wrap, obfuscate, bias, prohibit, forbid, revert' + additional-verbs: 'tidy, wrap, obfuscate, bias, prohibit, forbid, revert, slim' diff --git a/desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/openvpn-tunnel-state.spec.ts b/desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/openvpn-tunnel-state.spec.ts new file mode 100644 index 0000000000..d8334f4aeb --- /dev/null +++ b/desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/openvpn-tunnel-state.spec.ts @@ -0,0 +1,63 @@ +import { expect, test } from '@playwright/test'; +import { exec as execAsync } from 'child_process'; +import { Page } from 'playwright'; +import { promisify } from 'util'; + +import { expectConnected } from '../../shared/tunnel-state'; +import { startInstalledApp } from '../installed-utils'; + +const exec = promisify(execAsync); + +// This test expects the daemon to be logged into an account that has time left, have OpenVPN +// selected and to be disconnected. + +let page: Page; + +test.beforeAll(async () => { + ({ page } = await startInstalledApp()); +}); + +test.afterAll(async () => { + await page.close(); +}); + +test('App should show correct tunnel protocol', async () => { + await page.getByText('Connect', { exact: true }).click(); + await expectConnected(page); + await page.getByTestId('connection-panel-chevron').click(); + + const tunnelProtocol = page.getByTestId('tunnel-protocol'); + await expect(tunnelProtocol).toHaveText('OpenVPN'); +}); + +test('App should show correct OpenVPN transport protocol and port', async () => { + const inData = page.getByTestId('in-ip'); + + await expect(inData).toContainText(new RegExp(':[0-9]+')); + await expect(inData).toContainText(new RegExp('(TCP|UDP)$')); + + await exec('mullvad relay set tunnel openvpn --transport-protocol udp --port 1300'); + await expectConnected(page); + await page.getByTestId('connection-panel-chevron').click(); + await expect(inData).toContainText(new RegExp(':1300')); + + await exec('mullvad relay set tunnel openvpn --transport-protocol tcp --port any'); + await expectConnected(page); + await page.getByTestId('connection-panel-chevron').click(); + await expect(inData).toContainText(new RegExp(':[0-9]+')); + await expect(inData).toContainText(new RegExp('TCP$')); + + await exec('mullvad relay set tunnel openvpn --transport-protocol tcp --port 80'); + await expectConnected(page); + await page.getByTestId('connection-panel-chevron').click(); + await expect(inData).toContainText(new RegExp(':80')); + + await exec('mullvad relay set tunnel openvpn --transport-protocol any'); +}); + +test('App should show bridge mode', async () => { + await exec('mullvad bridge set state on'); + await expectConnected(page); + const relay = page.getByTestId('hostname-line'); + await expect(relay).toHaveText(new RegExp(' via ', 'i')); +}); diff --git a/desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/tunnel-state.spec.ts b/desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/tunnel-state.spec.ts index 3f767a8ffa..b3f5df0ad6 100644 --- a/desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/tunnel-state.spec.ts +++ b/desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/tunnel-state.spec.ts @@ -34,7 +34,7 @@ test('App should connect', async () => { await expectConnected(page); const relay = page.getByTestId('hostname-line'); - const inIp = page.locator(':text("In") + span'); + const inIp = page.getByText('In', { exact: true }).locator('+ span'); // If IPv6 is enabled, there will be two "Out" IPs, one for IPv4 and one for IPv6 // Selecting the first resolves to the IPv4 address regardless of the IP setting const outIp = page.locator(':text("Out") + div > span').first(); @@ -95,61 +95,6 @@ test('App should connect with Shadowsocks', async () => { await expectConnected(page); }); -test('App should show correct tunnel protocol', async () => { - const tunnelProtocol = page.getByTestId('tunnel-protocol'); - await expect(tunnelProtocol).toHaveText('WireGuard'); - - await exec('mullvad relay set tunnel-protocol openvpn'); - await exec('mullvad relay set location se'); - await expectConnected(page); - await page.getByTestId('connection-panel-chevron').click(); - await expect(tunnelProtocol).toHaveText('OpenVPN'); -}); - -test('App should show correct OpenVPN transport protocol and port', async () => { - const inData = page.getByTestId('in-ip'); - - await expect(inData).toContainText(new RegExp(':[0-9]+')); - await expect(inData).toContainText(new RegExp('(TCP|UDP)$')); - await exec('mullvad relay set tunnel openvpn --transport-protocol udp --port 1195'); - await expectConnected(page); - await page.getByTestId('connection-panel-chevron').click(); - await expect(inData).toContainText(new RegExp(':1195')); - - await exec('mullvad relay set tunnel openvpn --transport-protocol udp --port 1300'); - await expectConnected(page); - await page.getByTestId('connection-panel-chevron').click(); - await expect(inData).toContainText(new RegExp(':1300')); - - await exec('mullvad relay set tunnel openvpn --transport-protocol tcp --port any'); - await expectConnected(page); - await page.getByTestId('connection-panel-chevron').click(); - await expect(inData).toContainText(new RegExp(':[0-9]+')); - await expect(inData).toContainText(new RegExp('TCP$')); - - await exec('mullvad relay set tunnel openvpn --transport-protocol tcp --port 80'); - await expectConnected(page); - await page.getByTestId('connection-panel-chevron').click(); - await expect(inData).toContainText(new RegExp(':80')); - - await exec('mullvad relay set tunnel openvpn --transport-protocol tcp --port 443'); - await expectConnected(page); - await page.getByTestId('connection-panel-chevron').click(); - await expect(inData).toContainText(new RegExp(':443')); - - await exec('mullvad relay set tunnel openvpn --transport-protocol any'); -}); - -test('App should show bridge mode', async () => { - await exec('mullvad bridge set state on'); - await expectConnected(page); - const relay = page.getByTestId('hostname-line'); - await expect(relay).toHaveText(new RegExp(' via ', 'i')); - await exec('mullvad bridge set state off'); - - await exec('mullvad relay set tunnel-protocol wireguard'); -}); - test('App should enter blocked state', async () => { await exec('mullvad debug block-connection'); await expectError(page); diff --git a/test/test-manager/src/tests/ui.rs b/test/test-manager/src/tests/ui.rs index 088fd1e55d..84d84d9af1 100644 --- a/test/test-manager/src/tests/ui.rs +++ b/test/test-manager/src/tests/ui.rs @@ -1,6 +1,7 @@ use super::{config::TEST_CONFIG, helpers, Error, TestContext}; use mullvad_management_interface::MullvadProxyClient; use mullvad_relay_selector::query::builder::RelayQueryBuilder; +use mullvad_types::{constraints::Constraint, relay_constraints::RelaySettings}; use std::{ collections::BTreeMap, fmt::Debug, @@ -101,7 +102,7 @@ pub async fn test_ui_tunnel_settings( let ui_result = run_test_env( &rpc, - &["tunnel-state.spec"], + &["state-dependent/tunnel-state.spec"], [ ("HOSTNAME", entry.hostname.as_str()), ("IN_IP", &entry.ipv4_addr_in.to_string()), @@ -118,6 +119,28 @@ pub async fn test_ui_tunnel_settings( Ok(()) } +/// Test how various tunnel settings for OpenVPN are handled and displayed by the GUI +#[test_function] +pub async fn test_ui_openvpn_tunnel_settings( + _: TestContext, + rpc: ServiceClient, + mut mullvad_client: MullvadProxyClient, +) -> anyhow::Result<()> { + // openvpn-tunnel-state.spec precondition: OpenVPN needs to be selected + let relay_settings = mullvad_client.get_settings().await?.get_relay_settings(); + let RelaySettings::Normal(mut constraints) = relay_settings else { + unimplemented!() + }; + constraints.tunnel_protocol = Constraint::Only(talpid_types::net::TunnelType::OpenVpn); + mullvad_client + .set_relay_settings(RelaySettings::Normal(constraints)) + .await?; + + let ui_result = run_test(&rpc, &["openvpn-tunnel-state.spec"]).await?; + assert!(ui_result.success()); + Ok(()) +} + /// Test whether logging in and logging out work in the GUI #[test_function(priority = 500)] pub async fn test_ui_login( |
