Tweak testConnectingInvolvesWaiting to avoid invoking Private Relay (#146)

Motivation:

Private Relay kicks in to secure unencrypted data transfers, and
connections to port 80 are a good signal. As a result, the current
construction of this test will invoke Private Relay and attempt to route
over it.

While Private Relay is in beta this is a bad outcome, as it risks
causing bugs in unusual network scenarios. So let's tell Private Relay
we don't need it.

Modifications:

Pretend we're gonna connect to 443 instead.

Result:

More reliable test.
This commit is contained in:
Cory Benfield 2022-05-25 15:41:33 +01:00 committed by GitHub
parent 936bc0487a
commit 5a7a9b7875
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -766,7 +766,8 @@ class NIOTSConnectionChannelTests: XCTestCase {
.channelInitializer { channel in channel.pipeline.addHandler(eventRecordingHandler) }
.connectTimeout(.seconds(5)) // This is the worst-case test time: normally it'll be faster as we don't wait for this.
let target = NWEndpoint.hostPort(host: "example.invalid", port: 80)
// We choose 443 here to avoid triggering Private Relay, which can do all kinds of weird stuff to this test.
let target = NWEndpoint.hostPort(host: "example.invalid", port: 443)
// We don't wait here, as the connect attempt should timeout. If it doesn't, we'll close it.
connectBootstrap.connect(endpoint: target).whenSuccess { conn in