Skip to content

Commit 58157b9

Browse files
committed
Add an end to end test for UDP-over-TCP on port 80
1 parent 334a24e commit 58157b9

File tree

5 files changed

+86
-31
lines changed

5 files changed

+86
-31
lines changed

ios/MullvadVPN/View controllers/Tunnel/ConnectionView/DetailsView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ extension ConnectionView {
4242
connectionDetailRow(
4343
title: LocalizedStringKey("Out IPv6"),
4444
value: outAddressIpv6,
45-
accessibilityId: .connectionPanelOutAddressRow
45+
accessibilityId: .connectionPanelOutIpv6AddressRow
4646
)
4747
}
4848
}

ios/MullvadVPNUITests/Networking/TrafficGenerator.swift

+8-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class TrafficGenerator {
2727
port: NWEndpoint.Port(integerLiteral: UInt16(port)),
2828
using: params
2929
)
30-
setupConnection()
3130
setupOtherHandlers()
3231
}
3332

@@ -100,7 +99,13 @@ class TrafficGenerator {
10099
XCTWaiter().wait(for: [doneAttemptingConnectExpecation], timeout: 10.0)
101100
}
102101

102+
func stopConnection() {
103+
connection.stateUpdateHandler = { @Sendable _ in }
104+
connection.cancel()
105+
}
106+
103107
public func startGeneratingUDPTraffic(interval: TimeInterval) {
108+
setupConnection()
104109
sendDataTimer.schedule(deadline: .now(), repeating: interval)
105110

106111
sendDataTimer.setEventHandler {
@@ -125,7 +130,9 @@ class TrafficGenerator {
125130
}
126131

127132
public func stopGeneratingUDPTraffic() {
133+
sendDataTimer.setEventHandler(handler: {})
128134
sendDataTimer.cancel()
135+
stopConnection()
129136
}
130137
}
131138

ios/MullvadVPNUITests/Pages/TunnelControlPage.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ class TunnelControlPage: Page {
7171
return connectionAttempts
7272
}
7373

74+
func getInIPv4AddressLabel() -> String {
75+
app.staticTexts[AccessibilityIdentifier.connectionPanelInAddressRow].label.components(separatedBy: ":")[0]
76+
}
77+
7478
@discardableResult override init(_ app: XCUIApplication) {
7579
super.init(app)
7680

@@ -121,7 +125,7 @@ class TunnelControlPage: Page {
121125
}
122126

123127
@discardableResult func tapRelayStatusExpandCollapseButton() -> Self {
124-
app.images[AccessibilityIdentifier.relayStatusCollapseButton].press(forDuration: .leastNonzeroMagnitude)
128+
app.buttons[AccessibilityIdentifier.relayStatusCollapseButton].tap()
125129
return self
126130
}
127131

ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift

-28
Original file line numberDiff line numberDiff line change
@@ -76,34 +76,6 @@ class VPNSettingsPage: Page {
7676
return self
7777
}
7878

79-
// this button no longer exists
80-
@discardableResult func tapUDPOverTCPPortExpandButton() -> Self {
81-
cellExpandButton(AccessibilityIdentifier.udpOverTCPPortCell).tap()
82-
83-
return self
84-
}
85-
86-
// this button no longer exists
87-
@discardableResult func tapUDPOverTCPPortAutomaticCell() -> Self {
88-
app.cells["\(AccessibilityIdentifier.wireGuardObfuscationPort)Automatic"]
89-
.tap()
90-
return self
91-
}
92-
93-
// this button no longer exists
94-
@discardableResult func tapUDPOverTCPPort80Cell() -> Self {
95-
app.cells["\(AccessibilityIdentifier.wireGuardObfuscationPort)80"]
96-
.tap()
97-
return self
98-
}
99-
100-
// this button no longer exists
101-
@discardableResult func tapUDPOverTCPPort5001Cell() -> Self {
102-
app.cells["\(AccessibilityIdentifier.wireGuardObfuscationPort)5001"]
103-
.tap()
104-
return self
105-
}
106-
10779
@discardableResult func tapQuantumResistantTunnelExpandButton() -> Self {
10880
cellExpandButton(AccessibilityIdentifier.quantumResistantTunnelCell).tap()
10981

ios/MullvadVPNUITests/RelayTests.swift

+72
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,78 @@ class RelayTests: LoggedInWithTimeUITestCase {
131131
.tapCancelButton()
132132
}
133133

134+
func testWireGuardOverTCPCustomPort80() throws {
135+
addTeardownBlock {
136+
HeaderBar(self.app)
137+
.tapSettingsButton()
138+
139+
SettingsPage(self.app)
140+
.tapVPNSettingsCell()
141+
142+
VPNSettingsPage(self.app)
143+
.tapWireGuardObfuscationExpandButton()
144+
.tapWireGuardObfuscationOffCell()
145+
}
146+
147+
HeaderBar(app)
148+
.tapSettingsButton()
149+
150+
SettingsPage(app)
151+
.tapVPNSettingsCell()
152+
153+
VPNSettingsPage(app)
154+
.tapWireGuardObfuscationExpandButton()
155+
.tapWireGuardObfuscationUdpOverTcpCell()
156+
.tapUDPOverTCPPortSelectorButton()
157+
158+
UDPOverTCPObfuscationSettingsPage(app)
159+
.tapPort80Cell()
160+
.tapBackButton()
161+
162+
VPNSettingsPage(app)
163+
.tapBackButton()
164+
165+
SettingsPage(app)
166+
.tapDoneButton()
167+
168+
// The packet capture has to start before the tunnel is up,
169+
// otherwise the device cannot reach the in-house router anymore
170+
startPacketCapture()
171+
172+
TunnelControlPage(app)
173+
.tapConnectButton()
174+
175+
allowAddVPNConfigurationsIfAsked()
176+
177+
TunnelControlPage(app)
178+
.waitForConnectedLabel()
179+
180+
let connectedToIPAddress = TunnelControlPage(app)
181+
.tapRelayStatusExpandCollapseButton()
182+
.getInIPv4AddressLabel()
183+
184+
try Networking.verifyCanAccessInternet()
185+
186+
let targetIPAddress = Networking.getAlwaysReachableIPAddress()
187+
let trafficGenerator = TrafficGenerator(destinationHost: targetIPAddress, port: 80)
188+
trafficGenerator.startGeneratingUDPTraffic(interval: 0.1)
189+
190+
RunLoop.current.run(until: .now + 1)
191+
trafficGenerator.stopGeneratingUDPTraffic()
192+
193+
TunnelControlPage(app)
194+
.tapDisconnectButton()
195+
let capturedStreams = stopPacketCapture()
196+
197+
let streamFromPeeerToRelay = try XCTUnwrap(
198+
capturedStreams
199+
.filter { $0.destinationAddress == connectedToIPAddress }.first
200+
)
201+
202+
XCTAssertTrue(streamFromPeeerToRelay.destinationPort == 80)
203+
XCTAssertTrue(streamFromPeeerToRelay.transportProtocol == .TCP)
204+
}
205+
134206
func testWireGuardOverTCPManually() throws {
135207
addTeardownBlock {
136208
HeaderBar(self.app)

0 commit comments

Comments
 (0)