Skip to content

Commit 07f171b

Browse files
authored
Avoid using deprecated API in tests (#762)
This gets CI working again
1 parent 54d1006 commit 07f171b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Tests/AsyncHTTPClientTests/AsyncAwaitEndToEndTests.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,10 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
527527
/// openssl req -x509 -newkey rsa:4096 -keyout self_signed_key.pem -out self_signed_cert.pem -sha256 -days 99999 -nodes -subj '/CN=localhost'
528528
let certPath = Bundle.module.path(forResource: "self_signed_cert", ofType: "pem")!
529529
let keyPath = Bundle.module.path(forResource: "self_signed_key", ofType: "pem")!
530+
let key = try NIOSSLPrivateKey(file: keyPath, format: .pem)
530531
let configuration = TLSConfiguration.makeServerConfiguration(
531532
certificateChain: try NIOSSLCertificate.fromPEMFile(certPath).map { .certificate($0) },
532-
privateKey: .file(keyPath)
533+
privateKey: .privateKey(key)
533534
)
534535
let sslContext = try NIOSSLContext(configuration: configuration)
535536
let serverGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
@@ -597,10 +598,11 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
597598
/// ```
598599
let certPath = Bundle.module.path(forResource: "example.com.cert", ofType: "pem")!
599600
let keyPath = Bundle.module.path(forResource: "example.com.private-key", ofType: "pem")!
601+
let key = try NIOSSLPrivateKey(file: keyPath, format: .pem)
600602
let localhostCert = try NIOSSLCertificate.fromPEMFile(certPath)
601603
let configuration = TLSConfiguration.makeServerConfiguration(
602604
certificateChain: localhostCert.map { .certificate($0) },
603-
privateKey: .file(keyPath)
605+
privateKey: .privateKey(key)
604606
)
605607
let bin = HTTPBin(.http2(tlsConfiguration: configuration))
606608
defer { XCTAssertNoThrow(try bin.shutdown()) }

Tests/AsyncHTTPClientTests/HTTPClientTests.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,9 +1274,10 @@ final class HTTPClientTests: XCTestCaseHTTPClientTestsBaseClass {
12741274
/// openssl req -x509 -newkey rsa:4096 -keyout self_signed_key.pem -out self_signed_cert.pem -sha256 -days 99999 -nodes -subj '/CN=localhost'
12751275
let certPath = Bundle.module.path(forResource: "self_signed_cert", ofType: "pem")!
12761276
let keyPath = Bundle.module.path(forResource: "self_signed_key", ofType: "pem")!
1277+
let key = try NIOSSLPrivateKey(file: keyPath, format: .pem)
12771278
let configuration = try TLSConfiguration.makeServerConfiguration(
12781279
certificateChain: NIOSSLCertificate.fromPEMFile(certPath).map { .certificate($0) },
1279-
privateKey: .file(keyPath)
1280+
privateKey: .privateKey(key)
12801281
)
12811282
let sslContext = try NIOSSLContext(configuration: configuration)
12821283

@@ -1314,9 +1315,10 @@ final class HTTPClientTests: XCTestCaseHTTPClientTestsBaseClass {
13141315
/// openssl req -x509 -newkey rsa:4096 -keyout self_signed_key.pem -out self_signed_cert.pem -sha256 -days 99999 -nodes -subj '/CN=localhost'
13151316
let certPath = Bundle.module.path(forResource: "self_signed_cert", ofType: "pem")!
13161317
let keyPath = Bundle.module.path(forResource: "self_signed_key", ofType: "pem")!
1318+
let key = try NIOSSLPrivateKey(file: keyPath, format: .pem)
13171319
let configuration = try TLSConfiguration.makeServerConfiguration(
13181320
certificateChain: NIOSSLCertificate.fromPEMFile(certPath).map { .certificate($0) },
1319-
privateKey: .file(keyPath)
1321+
privateKey: .privateKey(key)
13201322
)
13211323
let sslContext = try NIOSSLContext(configuration: configuration)
13221324

0 commit comments

Comments
 (0)