Skip to content

Commit 76326cc

Browse files
authored
fix: testing and tls negotiation on linux (#306)
1 parent 7c40712 commit 76326cc

File tree

10 files changed

+19
-607
lines changed

10 files changed

+19
-607
lines changed

Packages/ClientRuntime/LinuxMain.swift

Lines changed: 0 additions & 10 deletions
This file was deleted.

Packages/ClientRuntime/Sources/Networking/Http/CRT/CRTClientEngine.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public class CRTClientEngine: HttpClientEngine {
2323
private let maxConnectionsPerEndpoint: Int
2424

2525
init(config: CRTClientEngineConfig = CRTClientEngineConfig()) {
26-
AwsCommonRuntimeKit.initialize()
2726
self.maxConnectionsPerEndpoint = config.maxConnectionsPerEndpoint
2827
self.windowSize = config.windowSize
2928
self.logger = SwiftLogger(label: "CRTClientEngine")
@@ -32,6 +31,14 @@ public class CRTClientEngine: HttpClientEngine {
3231

3332
private func createConnectionPool(endpoint: Endpoint) -> HttpClientConnectionManager {
3433
let tlsConnectionOptions = SDKDefaultIO.shared.tlsContext.newConnectionOptions()
34+
#if os(Linux)
35+
do {
36+
try tlsConnectionOptions.setServerName(endpoint.host)
37+
} catch let err {
38+
logger.error("Server name was not able to be set in TLS Connection Options. TLS Negotiation will fail.")
39+
logger.error("Error: \(err.localizedDescription)")
40+
}
41+
#endif
3542
let socketOptions = SocketOptions(socketType: .stream)
3643
let options = HttpClientConnectionOptions(clientBootstrap: SDKDefaultIO.shared.clientBootstrap,
3744
hostName: endpoint.host,

Packages/ClientRuntime/Tests/ClientRuntimeTests/SerializationTests/SerializationUtilsTests/DataObjectSerializationTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class DataObjectSerializationTests: XCTestCase {
8282
// encoded length is not a multiple of 4
8383
"Zm9vY=",
8484
// invalid padding
85+
// TODO: this does not pass on Linux, it is unclear of this is in fact an invalid amount of padding.
8586
"Zm9vY==="
8687
]
8788

Packages/ClientRuntime/Tests/MiddlewareTests/MiddlewareStackTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class MiddlewareStackTests: XCTestCase {
8080

8181
func testFullBlownOperationRequestWithClientHandler() {
8282
let httpClientConfiguration = HttpClientConfiguration()
83-
let clientEngine = try! CRTClientEngine()
83+
let clientEngine = CRTClientEngine()
8484
let httpClient = SdkHttpClient(engine: clientEngine, config: httpClientConfiguration)
8585

8686
let builtContext = HttpContextBuilder()

Packages/ClientRuntime/Tests/NetworkingTests/CRTClientEngineIntegrationTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class CRTClientEngineIntegrationTests: NetworkingTestUtils {
1414
override func setUp() {
1515
super.setUp()
1616
let httpClientConfiguration = HttpClientConfiguration()
17-
let crtEngine = try! CRTClientEngine()
17+
let crtEngine = CRTClientEngine()
1818
httpClient = SdkHttpClient(engine: crtEngine, config: httpClientConfiguration)
1919
}
2020

@@ -44,15 +44,15 @@ class CRTClientEngineIntegrationTests: NetworkingTestUtils {
4444
wait(for: [expectation], timeout: 10.0)
4545
}
4646

47-
func testMakeHttpPostRequest() {
47+
func testMakeHttpPostRequest() throws {
4848
//used https://httpbin.org
4949
let expectation = XCTestExpectation(description: "Request has been completed")
5050
var headers = Headers()
5151
headers.add(name: "Content-type", value: "application/json")
5252
headers.add(name: "Host", value: "httpbin.org")
5353
let body = TestBody(test: "testval")
5454
let encoder = JSONEncoder()
55-
let encodedData = try! encoder.encode(body)
55+
let encodedData = try encoder.encode(body)
5656
let request = SdkHttpRequest(method: .post,
5757
endpoint: Endpoint(host: "httpbin.org", path: "/post"),
5858
headers: headers,
@@ -196,15 +196,15 @@ class CRTClientEngineIntegrationTests: NetworkingTestUtils {
196196
wait(for: [expectation], timeout: 20.0)
197197
}
198198

199-
func testMakeHttpStreamRequestFromData() {
199+
func testMakeHttpStreamRequestFromData() throws {
200200
//used https://httpbin.org
201201
let expectation = XCTestExpectation(description: "Request has been completed")
202202
var headers = Headers()
203203
headers.add(name: "Content-type", value: "application/json")
204204
headers.add(name: "Host", value: "httpbin.org")
205205
let body = TestBody(test: "testval")
206206
let encoder = JSONEncoder()
207-
let encodedData = try! encoder.encode(body)
207+
let encodedData = try encoder.encode(body)
208208

209209
let request = SdkHttpRequest(method: .post,
210210
endpoint: Endpoint(host: "httpbin.org", path: "/post"),

Packages/ClientRuntime/Tests/NetworkingTests/MockURLProtocol.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
*/
55

66
import Foundation
7+
#if os(Linux)
8+
import FoundationNetworking
9+
#endif
710
@testable import ClientRuntime
811

912
class MockURLProtocol: URLProtocol {

0 commit comments

Comments
 (0)