@@ -183,24 +183,63 @@ class RelayTests: LoggedInWithTimeUITestCase {
183
183
184
184
try Networking . verifyCanAccessInternet ( )
185
185
186
- let targetIPAddress = Networking . getAlwaysReachableIPAddress ( )
187
- let trafficGenerator = TrafficGenerator ( destinationHost: targetIPAddress, port: 80 )
188
- trafficGenerator. startGeneratingUDPTraffic ( interval: 0.1 )
186
+ try generateTraffic ( to: connectedToIPAddress, on: 80 , assertProtocol: . TCP)
187
+ }
189
188
190
- RunLoop . current. run ( until: . now + 1 )
191
- trafficGenerator. stopGeneratingUDPTraffic ( )
189
+ func testWireGuardOverShadowsocksCustomPort( ) throws {
190
+ addTeardownBlock {
191
+ HeaderBar ( self . app)
192
+ . tapSettingsButton ( )
193
+
194
+ SettingsPage ( self . app)
195
+ . tapVPNSettingsCell ( )
196
+
197
+ VPNSettingsPage ( self . app)
198
+ . tapWireGuardObfuscationExpandButton ( )
199
+ . tapWireGuardObfuscationOffCell ( )
200
+ }
201
+
202
+ HeaderBar ( app)
203
+ . tapSettingsButton ( )
204
+
205
+ SettingsPage ( app)
206
+ . tapVPNSettingsCell ( )
207
+
208
+ VPNSettingsPage ( app)
209
+ . tapWireGuardObfuscationExpandButton ( )
210
+ . tapWireGuardObfuscationShadowsocksCell ( )
211
+ . tapShadowsocksPortSelectorButton ( )
212
+
213
+ ShadowsocksObfuscationSettingsPage ( app)
214
+ . tapCustomCell ( )
215
+ . typeTextIntoCustomField ( " 51900 " )
216
+ . tapBackButton ( )
217
+
218
+ VPNSettingsPage ( app)
219
+ . tapBackButton ( )
220
+
221
+ SettingsPage ( app)
222
+ . tapDoneButton ( )
223
+
224
+ // The packet capture has to start before the tunnel is up,
225
+ // otherwise the device cannot reach the in-house router anymore
226
+ startPacketCapture ( )
192
227
193
228
TunnelControlPage ( app)
194
- . tapDisconnectButton ( )
195
- let capturedStreams = stopPacketCapture ( )
229
+ . tapConnectButton ( )
196
230
197
- // The capture will contain several streams where `other_addr` contains the IP the device connected to
198
- // One stream will be for the source port, the other for the destination port
199
- let streamFromPeeerToRelay = try XCTUnwrap (
200
- capturedStreams. filter { $0. destinationAddress == connectedToIPAddress && $0. destinationPort == 80 } . first
201
- )
231
+ allowAddVPNConfigurationsIfAsked ( )
232
+
233
+ TunnelControlPage ( app)
234
+ . waitForConnectedLabel ( )
235
+
236
+ let connectedToIPAddress = TunnelControlPage ( app)
237
+ . tapRelayStatusExpandCollapseButton ( )
238
+ . getInIPv4AddressLabel ( )
239
+
240
+ try Networking . verifyCanAccessInternet ( )
202
241
203
- XCTAssertTrue ( streamFromPeeerToRelay . transportProtocol == . TCP )
242
+ try generateTraffic ( to : connectedToIPAddress , on : 51900 , assertProtocol : . UDP )
204
243
}
205
244
206
245
func testWireGuardOverTCPManually( ) throws {
@@ -508,4 +547,29 @@ extension RelayTests {
508
547
509
548
return RelayInfo ( name: relayName, ipAddress: relayIPAddress)
510
549
}
550
+
551
+ private func generateTraffic(
552
+ to connectedToIPAddress: String ,
553
+ on port: Int ,
554
+ assertProtocol transportProtocol: NetworkTransportProtocol
555
+ ) throws {
556
+ let targetIPAddress = Networking . getAlwaysReachableIPAddress ( )
557
+ let trafficGenerator = TrafficGenerator ( destinationHost: targetIPAddress, port: 80 )
558
+ trafficGenerator. startGeneratingUDPTraffic ( interval: 0.1 )
559
+
560
+ RunLoop . current. run ( until: . now + 1 )
561
+ trafficGenerator. stopGeneratingUDPTraffic ( )
562
+
563
+ TunnelControlPage ( app)
564
+ . tapDisconnectButton ( )
565
+ let capturedStreams = stopPacketCapture ( )
566
+
567
+ // The capture will contain several streams where `other_addr` contains the IP the device connected to
568
+ // One stream will be for the source port, the other for the destination port
569
+ let streamFromPeeerToRelay = try XCTUnwrap (
570
+ capturedStreams. filter { $0. destinationAddress == connectedToIPAddress && $0. destinationPort == port } . first
571
+ )
572
+
573
+ XCTAssertTrue ( streamFromPeeerToRelay. transportProtocol == transportProtocol)
574
+ }
511
575
} // swiftlint:disable:this file_length
0 commit comments