Skip to content

Commit d66e8fe

Browse files
committed
Split OpenVPN tunnel-state tests to separate file
1 parent f278ba3 commit d66e8fe

File tree

3 files changed

+98
-55
lines changed

3 files changed

+98
-55
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { expect, test } from '@playwright/test';
2+
import { exec as execAsync } from 'child_process';
3+
import { Page } from 'playwright';
4+
import { promisify } from 'util';
5+
6+
import { expectConnected } from '../../shared/tunnel-state';
7+
import { startInstalledApp } from '../installed-utils';
8+
9+
const exec = promisify(execAsync);
10+
11+
// This test expects the daemon to be logged into an account that has time left, have OpenVPN
12+
// selected and to be disconnected.
13+
14+
let page: Page;
15+
16+
test.beforeAll(async () => {
17+
({ page } = await startInstalledApp());
18+
});
19+
20+
test.afterAll(async () => {
21+
await page.close();
22+
});
23+
24+
test('App should show correct tunnel protocol', async () => {
25+
await page.getByText('Connect', { exact: true }).click();
26+
await expectConnected(page);
27+
await page.getByTestId('connection-panel-chevron').click();
28+
29+
const tunnelProtocol = page.getByTestId('tunnel-protocol');
30+
await expect(tunnelProtocol).toHaveText('OpenVPN');
31+
});
32+
33+
test('App should show correct OpenVPN transport protocol and port', async () => {
34+
const inData = page.getByTestId('in-ip');
35+
36+
await expect(inData).toContainText(new RegExp(':[0-9]+'));
37+
await expect(inData).toContainText(new RegExp('(TCP|UDP)$'));
38+
await exec('mullvad relay set tunnel openvpn --transport-protocol udp --port 1195');
39+
await expectConnected(page);
40+
await page.getByTestId('connection-panel-chevron').click();
41+
await expect(inData).toContainText(new RegExp(':1195'));
42+
43+
await exec('mullvad relay set tunnel openvpn --transport-protocol udp --port 1300');
44+
await expectConnected(page);
45+
await page.getByTestId('connection-panel-chevron').click();
46+
await expect(inData).toContainText(new RegExp(':1300'));
47+
48+
await exec('mullvad relay set tunnel openvpn --transport-protocol tcp --port any');
49+
await expectConnected(page);
50+
await page.getByTestId('connection-panel-chevron').click();
51+
await expect(inData).toContainText(new RegExp(':[0-9]+'));
52+
await expect(inData).toContainText(new RegExp('TCP$'));
53+
54+
await exec('mullvad relay set tunnel openvpn --transport-protocol tcp --port 80');
55+
await expectConnected(page);
56+
await page.getByTestId('connection-panel-chevron').click();
57+
await expect(inData).toContainText(new RegExp(':80'));
58+
59+
await exec('mullvad relay set tunnel openvpn --transport-protocol tcp --port 443');
60+
await expectConnected(page);
61+
await page.getByTestId('connection-panel-chevron').click();
62+
await expect(inData).toContainText(new RegExp(':443'));
63+
64+
await exec('mullvad relay set tunnel openvpn --transport-protocol any');
65+
});
66+
67+
test('App should show bridge mode', async () => {
68+
await exec('mullvad bridge set state on');
69+
await expectConnected(page);
70+
const relay = page.getByTestId('hostname-line');
71+
await expect(relay).toHaveText(new RegExp(' via ', 'i'));
72+
});

desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/tunnel-state.spec.ts

-55
Original file line numberDiff line numberDiff line change
@@ -95,61 +95,6 @@ test('App should connect with Shadowsocks', async () => {
9595
await expectConnected(page);
9696
});
9797

98-
test('App should show correct tunnel protocol', async () => {
99-
const tunnelProtocol = page.getByTestId('tunnel-protocol');
100-
await expect(tunnelProtocol).toHaveText('WireGuard');
101-
102-
await exec('mullvad relay set tunnel-protocol openvpn');
103-
await exec('mullvad relay set location se');
104-
await expectConnected(page);
105-
await page.getByTestId('connection-panel-chevron').click();
106-
await expect(tunnelProtocol).toHaveText('OpenVPN');
107-
});
108-
109-
test('App should show correct OpenVPN transport protocol and port', async () => {
110-
const inData = page.getByTestId('in-ip');
111-
112-
await expect(inData).toContainText(new RegExp(':[0-9]+'));
113-
await expect(inData).toContainText(new RegExp('(TCP|UDP)$'));
114-
await exec('mullvad relay set tunnel openvpn --transport-protocol udp --port 1195');
115-
await expectConnected(page);
116-
await page.getByTestId('connection-panel-chevron').click();
117-
await expect(inData).toContainText(new RegExp(':1195'));
118-
119-
await exec('mullvad relay set tunnel openvpn --transport-protocol udp --port 1300');
120-
await expectConnected(page);
121-
await page.getByTestId('connection-panel-chevron').click();
122-
await expect(inData).toContainText(new RegExp(':1300'));
123-
124-
await exec('mullvad relay set tunnel openvpn --transport-protocol tcp --port any');
125-
await expectConnected(page);
126-
await page.getByTestId('connection-panel-chevron').click();
127-
await expect(inData).toContainText(new RegExp(':[0-9]+'));
128-
await expect(inData).toContainText(new RegExp('TCP$'));
129-
130-
await exec('mullvad relay set tunnel openvpn --transport-protocol tcp --port 80');
131-
await expectConnected(page);
132-
await page.getByTestId('connection-panel-chevron').click();
133-
await expect(inData).toContainText(new RegExp(':80'));
134-
135-
await exec('mullvad relay set tunnel openvpn --transport-protocol tcp --port 443');
136-
await expectConnected(page);
137-
await page.getByTestId('connection-panel-chevron').click();
138-
await expect(inData).toContainText(new RegExp(':443'));
139-
140-
await exec('mullvad relay set tunnel openvpn --transport-protocol any');
141-
});
142-
143-
test('App should show bridge mode', async () => {
144-
await exec('mullvad bridge set state on');
145-
await expectConnected(page);
146-
const relay = page.getByTestId('hostname-line');
147-
await expect(relay).toHaveText(new RegExp(' via ', 'i'));
148-
await exec('mullvad bridge set state off');
149-
150-
await exec('mullvad relay set tunnel-protocol wireguard');
151-
});
152-
15398
test('App should enter blocked state', async () => {
15499
await exec('mullvad debug block-connection');
155100
await expectError(page);

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

+26
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
use super::{config::TEST_CONFIG, helpers, Error, TestContext};
22
use mullvad_management_interface::MullvadProxyClient;
33
use mullvad_relay_selector::query::builder::RelayQueryBuilder;
4+
use mullvad_types::{
5+
constraints::Constraint,
6+
relay_constraints::{RelayConstraints, RelaySettings},
7+
};
48
use std::{
59
collections::BTreeMap,
610
fmt::Debug,
711
path::{Path, PathBuf},
812
};
13+
use talpid_types::net::TunnelType;
914
use test_macro::test_function;
1015
use test_rpc::{meta::Os, ExecResult, ServiceClient};
1116

@@ -118,6 +123,27 @@ pub async fn test_ui_tunnel_settings(
118123
Ok(())
119124
}
120125

126+
/// Test how various tunnel settings for OpenVPN are handled and displayed by the GUI
127+
#[test_function]
128+
pub async fn test_ui_openvpn_tunnel_settings(
129+
_: TestContext,
130+
rpc: ServiceClient,
131+
mut mullvad_client: MullvadProxyClient,
132+
) -> anyhow::Result<()> {
133+
// openvpn-tunnel-state.spec precondition: OpenVPN needs to be selected
134+
let relay_settings = RelaySettings::Normal(RelayConstraints {
135+
tunnel_protocol: Constraint::Only(TunnelType::OpenVpn),
136+
..Default::default()
137+
});
138+
set_relay_settings(&mut mullvad_client, relay_settings)
139+
.await
140+
.expect("failed to update relay settings");
141+
142+
let ui_result = run_test(&rpc, &["openvpn-tunnel-state.spec"]).await?;
143+
assert!(ui_result.success());
144+
Ok(())
145+
}
146+
121147
/// Test whether logging in and logging out work in the GUI
122148
#[test_function(priority = 500)]
123149
pub async fn test_ui_login(

0 commit comments

Comments
 (0)