@@ -7,19 +7,23 @@ import XCTest
77class HTTP2ClientConnectionTests : XCBaseTestCase {
88
99 let expectedVersion = HTTPVersion . version_2
10- let host = " postman-echo.com "
10+ let host = " localhost "
11+ let port : Int = 3443
1112
1213 func testGetHTTP2RequestVersion( ) async throws {
14+ try skipIfLocalhostUnavailable ( )
15+ try ? Logger . initialize ( target: LogTarget . standardOutput, level: LogLevel . trace)
1316 let connectionManager = try await HTTPClientTestFixture . getHttpConnectionManager (
14- endpoint: host, alpnList: [ " h2 " , " http/1.1 " ] )
17+ endpoint: host, port : port , alpnList: [ " h2 " , " http/1.1 " ] )
1518 let connection = try await connectionManager. acquireConnection ( )
1619 XCTAssertEqual ( connection. httpVersion, HTTPVersion . version_2)
1720 }
1821
1922 // Test that the binding works not the actual functionality. C part has tests for functionality
2023 func testHTTP2UpdateSetting( ) async throws {
24+ try skipIfLocalhostUnavailable ( )
2125 let connectionManager = try await HTTPClientTestFixture . getHttpConnectionManager (
22- endpoint: host, alpnList: [ " h2 " , " http/1.1 " ] )
26+ endpoint: host, port : port , alpnList: [ " h2 " , " http/1.1 " ] )
2327 let connection = try await connectionManager. acquireConnection ( )
2428 if let connection = connection as? HTTP2ClientConnection {
2529 try await connection. updateSetting ( setting: HTTP2Settings ( enablePush: false ) )
@@ -30,8 +34,9 @@ class HTTP2ClientConnectionTests: XCBaseTestCase {
3034
3135 // Test that the binding works not the actual functionality. C part has tests for functionality
3236 func testHTTP2UpdateSettingEmpty( ) async throws {
37+ try skipIfLocalhostUnavailable ( )
3338 let connectionManager = try await HTTPClientTestFixture . getHttpConnectionManager (
34- endpoint: host, alpnList: [ " h2 " , " http/1.1 " ] )
39+ endpoint: host, port : port , alpnList: [ " h2 " , " http/1.1 " ] )
3540 let connection = try await connectionManager. acquireConnection ( )
3641 if let connection = connection as? HTTP2ClientConnection {
3742 try await connection. updateSetting ( setting: HTTP2Settings ( ) )
@@ -42,8 +47,9 @@ class HTTP2ClientConnectionTests: XCBaseTestCase {
4247
4348 // Test that the binding works not the actual functionality. C part has tests for functionality
4449 func testHTTP2SendPing( ) async throws {
50+ try skipIfLocalhostUnavailable ( )
4551 let connectionManager = try await HTTPClientTestFixture . getHttpConnectionManager (
46- endpoint: host, alpnList: [ " h2 " , " http/1.1 " ] )
52+ endpoint: host, port : port , alpnList: [ " h2 " , " http/1.1 " ] )
4753 let connection = try await connectionManager. acquireConnection ( )
4854 if let connection = connection as? HTTP2ClientConnection {
4955 var time = try await connection. sendPing ( )
@@ -57,8 +63,9 @@ class HTTP2ClientConnectionTests: XCBaseTestCase {
5763
5864 // Test that the binding works not the actual functionality. C part has tests for functionality
5965 func testHTTP2SendGoAway( ) async throws {
66+ try skipIfLocalhostUnavailable ( )
6067 let connectionManager = try await HTTPClientTestFixture . getHttpConnectionManager (
61- endpoint: host, alpnList: [ " h2 " , " http/1.1 " ] )
68+ endpoint: host, port : port , alpnList: [ " h2 " , " http/1.1 " ] )
6269 let connection = try await connectionManager. acquireConnection ( )
6370 if let connection = connection as? HTTP2ClientConnection {
6471 connection. sendGoAway ( error: . internalError, allowMoreStreams: false )
@@ -68,12 +75,13 @@ class HTTP2ClientConnectionTests: XCBaseTestCase {
6875 }
6976
7077 func testGetHttpsRequest( ) async throws {
78+ try skipIfLocalhostUnavailable ( )
7179 let connectionManager = try await HTTPClientTestFixture . getHttpConnectionManager (
72- endpoint: host, alpnList: [ " h2 " , " http/1.1 " ] )
80+ endpoint: host, port : port , alpnList: [ " h2 " , " http/1.1 " ] )
7381 let response = try await HTTPClientTestFixture . sendHTTPRequest (
7482 method: " GET " ,
7583 endpoint: host,
76- path: " /get " ,
84+ path: " /echo " ,
7785 connectionManager: connectionManager,
7886 expectedVersion: expectedVersion,
7987 requestVersion: . version_2)
@@ -91,12 +99,13 @@ class HTTP2ClientConnectionTests: XCBaseTestCase {
9199 }
92100
93101 func testGetHttpsRequestWithHTTP1_1Request( ) async throws {
102+ try skipIfLocalhostUnavailable ( )
94103 let connectionManager = try await HTTPClientTestFixture . getHttpConnectionManager (
95- endpoint: host, alpnList: [ " h2 " , " http/1.1 " ] )
104+ endpoint: host, port : port , alpnList: [ " h2 " , " http/1.1 " ] )
96105 let response = try await HTTPClientTestFixture . sendHTTPRequest (
97106 method: " GET " ,
98107 endpoint: host,
99- path: " /get " ,
108+ path: " /echo " ,
100109 connectionManager: connectionManager,
101110 expectedVersion: expectedVersion,
102111 requestVersion: . version_1_1)
0 commit comments