summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBug Magnet <marco.nikic@mullvad.net>2024-11-20 13:35:05 +0100
committerBug Magnet <marco.nikic@mullvad.net>2024-11-27 10:45:06 +0100
commitc5609e572daca5a036864cd032f9ca3e030bccf6 (patch)
treed9073c104e0eb29250b25f5354c9d49677497ee3
parent5a335d860c5be4901915a452aec9e6a25fa09309 (diff)
downloadmullvadvpn-c5609e572daca5a036864cd032f9ca3e030bccf6.tar.xz
mullvadvpn-c5609e572daca5a036864cd032f9ca3e030bccf6.zip
Fix UITests about Obufscation and add support for Shadowsocks
-rw-r--r--ios/MullvadVPNUITests/Pages/TunnelControlPage.swift60
-rw-r--r--ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift8
-rw-r--r--ios/MullvadVPNUITests/RelayTests.swift43
-rw-r--r--ios/MullvadVPNUITests/SettingsMigrationTests.swift2
4 files changed, 75 insertions, 38 deletions
diff --git a/ios/MullvadVPNUITests/Pages/TunnelControlPage.swift b/ios/MullvadVPNUITests/Pages/TunnelControlPage.swift
index cf90555e5a..0cf0b64d88 100644
--- a/ios/MullvadVPNUITests/Pages/TunnelControlPage.swift
+++ b/ios/MullvadVPNUITests/Pages/TunnelControlPage.swift
@@ -127,31 +127,31 @@ class TunnelControlPage: Page {
/// Verify that the app attempts to connect over UDP before switching to TCP. For testing blocked UDP traffic.
@discardableResult func verifyConnectingOverTCPAfterUDPAttempts() -> Self {
- let connectionAttempts = waitForConnectionAttempts(3, timeout: 15)
+ let connectionAttempts = waitForConnectionAttempts(4, timeout: 30)
- // Should do three connection attempts but due to UI bug sometimes only two are displayed, sometimes all three
- if connectionAttempts.count == 3 { // Expected retries flow
+ // Should do four connection attempts but due to UI bug sometimes only two are displayed, sometimes all four
+ if connectionAttempts.count == 4 { // Expected retries flow
for (attemptIndex, attempt) in connectionAttempts.enumerated() {
- if attemptIndex == 0 || attemptIndex == 1 {
+ if attemptIndex == 0 || attemptIndex == 1 || attemptIndex == 2 {
XCTAssertEqual(attempt.protocolName, "UDP")
- } else if attemptIndex == 2 {
+ } else if attemptIndex == 3 {
XCTAssertEqual(attempt.protocolName, "TCP")
} else {
XCTFail("Unexpected connection attempt")
}
}
- } else if connectionAttempts.count == 2 { // Most of the times this incorrect flow is shown
+ } else if connectionAttempts.count == 3 { // Most of the times this incorrect flow is shown
for (attemptIndex, attempt) in connectionAttempts.enumerated() {
- if attemptIndex == 0 {
+ if attemptIndex == 0 || attemptIndex == 1 {
XCTAssertEqual(attempt.protocolName, "UDP")
- } else if attemptIndex == 1 {
+ } else if attemptIndex == 2 {
XCTAssertEqual(attempt.protocolName, "TCP")
} else {
XCTFail("Unexpected connection attempt")
}
}
} else {
- XCTFail("Unexpected number of connection attempts")
+ XCTFail("Unexpected number of connection attempts, expected 3~4, got \(connectionAttempts.count)")
}
return self
@@ -159,35 +159,25 @@ class TunnelControlPage: Page {
/// Verify that connection attempts are made in the correct order
@discardableResult func verifyConnectionAttemptsOrder() -> Self {
- let connectionAttempts = waitForConnectionAttempts(4, timeout: 50)
+ var connectionAttempts = waitForConnectionAttempts(4, timeout: 70)
+ var totalAttemptsOffset = 0
XCTAssertEqual(connectionAttempts.count, 4)
+ /// Sometimes, the UI will only show an IP address for the first connection attempt, which gets skipped by
+ /// `waitForConnectionAttempts`, and offsets expected attempts count by 1, but still counts towards
+ /// total connection attempts. Remove that last attempt which would be the first one of a new series
+ /// of connection attempts.
if connectionAttempts.last?.protocolName == "UDP" {
- // If last attempt is over UDP it means we have encountered the UI bug where only one UDP attempt is shown and then the two TCP attempts
- for (attemptIndex, attempt) in connectionAttempts.enumerated() {
- if attemptIndex == 0 {
- XCTAssertEqual(attempt.protocolName, "UDP")
- } else if attemptIndex == 1 {
- XCTAssertEqual(attempt.protocolName, "TCP")
- XCTAssertEqual(attempt.port, "80")
- } else if attemptIndex == 2 {
- XCTAssertEqual(attempt.protocolName, "TCP")
- XCTAssertEqual(attempt.port, "5001")
- } // Ignore the 4th attempt which is the first attempt of new attempt cycle
- }
- } else {
- for (attemptIndex, attempt) in connectionAttempts.enumerated() {
- if attemptIndex == 0 {
- XCTAssertEqual(attempt.protocolName, "UDP")
- } else if attemptIndex == 1 {
- XCTAssertEqual(attempt.protocolName, "UDP")
- } else if attemptIndex == 2 {
- XCTAssertEqual(attempt.protocolName, "TCP")
- XCTAssertEqual(attempt.port, "80")
- } else if attemptIndex == 3 {
- XCTAssertEqual(attempt.protocolName, "TCP")
- XCTAssertEqual(attempt.port, "5001")
- }
+ connectionAttempts.removeLast()
+ totalAttemptsOffset = -1
+ }
+ for (attemptIndex, attempt) in connectionAttempts.enumerated() {
+ if attemptIndex < 3 - totalAttemptsOffset {
+ XCTAssertEqual(attempt.protocolName, "UDP")
+ } else {
+ XCTAssertEqual(attempt.protocolName, "TCP")
+ let validPorts = ["80", "5001"]
+ XCTAssertTrue(validPorts.contains(attempt.port))
}
}
diff --git a/ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift b/ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift
index 570f32ab08..7f463069b8 100644
--- a/ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift
+++ b/ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift
@@ -102,12 +102,18 @@ class VPNSettingsPage: Page {
return self
}
- @discardableResult func tapWireGuardObfuscationOnCell() -> Self {
+ @discardableResult func tapWireGuardObfuscationUdpOverTcpCell() -> Self {
app.cells[AccessibilityIdentifier.wireGuardObfuscationUdpOverTcp].tap()
return self
}
+ @discardableResult func tapWireGuardObfuscationShadowsocksCell() -> Self {
+ app.cells[AccessibilityIdentifier.wireGuardObfuscationShadowsocks].tap()
+
+ return self
+ }
+
@discardableResult func tapWireGuardObfuscationOffCell() -> Self {
app.cells[AccessibilityIdentifier.wireGuardObfuscationOff].tap()
diff --git a/ios/MullvadVPNUITests/RelayTests.swift b/ios/MullvadVPNUITests/RelayTests.swift
index b000d2fe50..319a1b0a23 100644
--- a/ios/MullvadVPNUITests/RelayTests.swift
+++ b/ios/MullvadVPNUITests/RelayTests.swift
@@ -151,7 +151,48 @@ class RelayTests: LoggedInWithTimeUITestCase {
VPNSettingsPage(app)
.tapWireGuardObfuscationExpandButton()
- .tapWireGuardObfuscationOnCell()
+ .tapWireGuardObfuscationUdpOverTcpCell()
+ .tapBackButton()
+
+ SettingsPage(app)
+ .tapDoneButton()
+
+ TunnelControlPage(app)
+ .tapSecureConnectionButton()
+
+ allowAddVPNConfigurationsIfAsked()
+
+ TunnelControlPage(app)
+ .waitForSecureConnectionLabel()
+
+ try Networking.verifyCanAccessInternet()
+
+ TunnelControlPage(app)
+ .tapDisconnectButton()
+ }
+
+ func testWireGuardOverShadowsocksManually() throws {
+ addTeardownBlock {
+ HeaderBar(self.app)
+ .tapSettingsButton()
+
+ SettingsPage(self.app)
+ .tapVPNSettingsCell()
+
+ VPNSettingsPage(self.app)
+ .tapWireGuardObfuscationExpandButton()
+ .tapWireGuardObfuscationOffCell()
+ }
+
+ HeaderBar(app)
+ .tapSettingsButton()
+
+ SettingsPage(app)
+ .tapVPNSettingsCell()
+
+ VPNSettingsPage(app)
+ .tapWireGuardObfuscationExpandButton()
+ .tapWireGuardObfuscationShadowsocksCell()
.tapBackButton()
SettingsPage(app)
diff --git a/ios/MullvadVPNUITests/SettingsMigrationTests.swift b/ios/MullvadVPNUITests/SettingsMigrationTests.swift
index 85ab71bafa..0de0e59319 100644
--- a/ios/MullvadVPNUITests/SettingsMigrationTests.swift
+++ b/ios/MullvadVPNUITests/SettingsMigrationTests.swift
@@ -116,7 +116,7 @@ class SettingsMigrationTests: BaseUITestCase {
.enterText(wireGuardPort)
.dismissKeyboard()
.tapWireGuardObfuscationExpandButton()
- .tapWireGuardObfuscationOnCell()
+ .tapWireGuardObfuscationUdpOverTcpCell()
.tapUDPOverTCPPortExpandButton()
.tapUDPOverTCPPort80Cell()
.tapQuantumResistantTunnelExpandButton()