diff options
| author | Bug Magnet <marco.nikic@mullvad.net> | 2025-01-29 11:52:38 +0100 |
|---|---|---|
| committer | Bug Magnet <marco.nikic@mullvad.net> | 2025-02-18 11:23:32 +0100 |
| commit | 58157b9660e73406d2cc3fdaa2d512cd1275d075 (patch) | |
| tree | 8c2da842a9a75cef54a61fadbb9f62e1c0677bef /ios | |
| parent | 334a24ee77798308591a74c66b7bb44dcf20f712 (diff) | |
| download | mullvadvpn-58157b9660e73406d2cc3fdaa2d512cd1275d075.tar.xz mullvadvpn-58157b9660e73406d2cc3fdaa2d512cd1275d075.zip | |
Add an end to end test for UDP-over-TCP on port 80
Diffstat (limited to 'ios')
5 files changed, 86 insertions, 31 deletions
diff --git a/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/DetailsView.swift b/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/DetailsView.swift index 4e26307914..deeb382386 100644 --- a/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/DetailsView.swift +++ b/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/DetailsView.swift @@ -42,7 +42,7 @@ extension ConnectionView { connectionDetailRow( title: LocalizedStringKey("Out IPv6"), value: outAddressIpv6, - accessibilityId: .connectionPanelOutAddressRow + accessibilityId: .connectionPanelOutIpv6AddressRow ) } } diff --git a/ios/MullvadVPNUITests/Networking/TrafficGenerator.swift b/ios/MullvadVPNUITests/Networking/TrafficGenerator.swift index 8a911837f5..590246c5cc 100644 --- a/ios/MullvadVPNUITests/Networking/TrafficGenerator.swift +++ b/ios/MullvadVPNUITests/Networking/TrafficGenerator.swift @@ -27,7 +27,6 @@ class TrafficGenerator { port: NWEndpoint.Port(integerLiteral: UInt16(port)), using: params ) - setupConnection() setupOtherHandlers() } @@ -100,7 +99,13 @@ class TrafficGenerator { XCTWaiter().wait(for: [doneAttemptingConnectExpecation], timeout: 10.0) } + func stopConnection() { + connection.stateUpdateHandler = { @Sendable _ in } + connection.cancel() + } + public func startGeneratingUDPTraffic(interval: TimeInterval) { + setupConnection() sendDataTimer.schedule(deadline: .now(), repeating: interval) sendDataTimer.setEventHandler { @@ -125,7 +130,9 @@ class TrafficGenerator { } public func stopGeneratingUDPTraffic() { + sendDataTimer.setEventHandler(handler: {}) sendDataTimer.cancel() + stopConnection() } } diff --git a/ios/MullvadVPNUITests/Pages/TunnelControlPage.swift b/ios/MullvadVPNUITests/Pages/TunnelControlPage.swift index ff050570ab..85854163b7 100644 --- a/ios/MullvadVPNUITests/Pages/TunnelControlPage.swift +++ b/ios/MullvadVPNUITests/Pages/TunnelControlPage.swift @@ -71,6 +71,10 @@ class TunnelControlPage: Page { return connectionAttempts } + func getInIPv4AddressLabel() -> String { + app.staticTexts[AccessibilityIdentifier.connectionPanelInAddressRow].label.components(separatedBy: ":")[0] + } + @discardableResult override init(_ app: XCUIApplication) { super.init(app) @@ -121,7 +125,7 @@ class TunnelControlPage: Page { } @discardableResult func tapRelayStatusExpandCollapseButton() -> Self { - app.images[AccessibilityIdentifier.relayStatusCollapseButton].press(forDuration: .leastNonzeroMagnitude) + app.buttons[AccessibilityIdentifier.relayStatusCollapseButton].tap() return self } diff --git a/ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift b/ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift index aa6ac65555..79f1e58a0d 100644 --- a/ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift +++ b/ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift @@ -76,34 +76,6 @@ class VPNSettingsPage: Page { return self } - // this button no longer exists - @discardableResult func tapUDPOverTCPPortExpandButton() -> Self { - cellExpandButton(AccessibilityIdentifier.udpOverTCPPortCell).tap() - - return self - } - - // this button no longer exists - @discardableResult func tapUDPOverTCPPortAutomaticCell() -> Self { - app.cells["\(AccessibilityIdentifier.wireGuardObfuscationPort)Automatic"] - .tap() - return self - } - - // this button no longer exists - @discardableResult func tapUDPOverTCPPort80Cell() -> Self { - app.cells["\(AccessibilityIdentifier.wireGuardObfuscationPort)80"] - .tap() - return self - } - - // this button no longer exists - @discardableResult func tapUDPOverTCPPort5001Cell() -> Self { - app.cells["\(AccessibilityIdentifier.wireGuardObfuscationPort)5001"] - .tap() - return self - } - @discardableResult func tapQuantumResistantTunnelExpandButton() -> Self { cellExpandButton(AccessibilityIdentifier.quantumResistantTunnelCell).tap() diff --git a/ios/MullvadVPNUITests/RelayTests.swift b/ios/MullvadVPNUITests/RelayTests.swift index d6b896215c..a8fe69c349 100644 --- a/ios/MullvadVPNUITests/RelayTests.swift +++ b/ios/MullvadVPNUITests/RelayTests.swift @@ -131,6 +131,78 @@ class RelayTests: LoggedInWithTimeUITestCase { .tapCancelButton() } + func testWireGuardOverTCPCustomPort80() throws { + addTeardownBlock { + HeaderBar(self.app) + .tapSettingsButton() + + SettingsPage(self.app) + .tapVPNSettingsCell() + + VPNSettingsPage(self.app) + .tapWireGuardObfuscationExpandButton() + .tapWireGuardObfuscationOffCell() + } + + HeaderBar(app) + .tapSettingsButton() + + SettingsPage(app) + .tapVPNSettingsCell() + + VPNSettingsPage(app) + .tapWireGuardObfuscationExpandButton() + .tapWireGuardObfuscationUdpOverTcpCell() + .tapUDPOverTCPPortSelectorButton() + + UDPOverTCPObfuscationSettingsPage(app) + .tapPort80Cell() + .tapBackButton() + + VPNSettingsPage(app) + .tapBackButton() + + SettingsPage(app) + .tapDoneButton() + + // The packet capture has to start before the tunnel is up, + // otherwise the device cannot reach the in-house router anymore + startPacketCapture() + + TunnelControlPage(app) + .tapConnectButton() + + allowAddVPNConfigurationsIfAsked() + + TunnelControlPage(app) + .waitForConnectedLabel() + + let connectedToIPAddress = TunnelControlPage(app) + .tapRelayStatusExpandCollapseButton() + .getInIPv4AddressLabel() + + try Networking.verifyCanAccessInternet() + + let targetIPAddress = Networking.getAlwaysReachableIPAddress() + let trafficGenerator = TrafficGenerator(destinationHost: targetIPAddress, port: 80) + trafficGenerator.startGeneratingUDPTraffic(interval: 0.1) + + RunLoop.current.run(until: .now + 1) + trafficGenerator.stopGeneratingUDPTraffic() + + TunnelControlPage(app) + .tapDisconnectButton() + let capturedStreams = stopPacketCapture() + + let streamFromPeeerToRelay = try XCTUnwrap( + capturedStreams + .filter { $0.destinationAddress == connectedToIPAddress }.first + ) + + XCTAssertTrue(streamFromPeeerToRelay.destinationPort == 80) + XCTAssertTrue(streamFromPeeerToRelay.transportProtocol == .TCP) + } + func testWireGuardOverTCPManually() throws { addTeardownBlock { HeaderBar(self.app) |
