diff --git a/ios/MullvadVPNUITests/Pages/TunnelControlPage.swift b/ios/MullvadVPNUITests/Pages/TunnelControlPage.swift index cf90555e5a5e..f5e59b12e870 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,16 @@ class TunnelControlPage: Page { /// Verify that connection attempts are made in the correct order @discardableResult func verifyConnectionAttemptsOrder() -> Self { - let connectionAttempts = waitForConnectionAttempts(4, timeout: 50) + let connectionAttempts = waitForConnectionAttempts(4, timeout: 70) XCTAssertEqual(connectionAttempts.count, 4) - 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") - } + for (attemptIndex, attempt) in connectionAttempts.enumerated() { + if attemptIndex < 3 { + 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 570f32ab080f..7f463069b8a5 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 b000d2fe50a5..319a1b0a2370 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 85ab71bafa34..0de0e5931938 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()