Skip to content

Commit

Permalink
Update some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gjcairo committed Dec 6, 2024
1 parent 75435de commit 2127ad6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ final class HTTP2TransportNIOTransportServicesTests: XCTestCase {
func testGetListeningAddress_IPv4() async throws {
let transport = GRPCNIOTransportCore.HTTP2ServerTransport.TransportServices(
address: .ipv4(host: "0.0.0.0", port: 0),
transportSecurity: .plaintext
transportSecurity: .plaintext,
config: .defaults
)

try await withThrowingDiscardingTaskGroup { group in
Expand Down Expand Up @@ -195,10 +196,8 @@ final class HTTP2TransportNIOTransportServicesTests: XCTestCase {
}

func testClientConfig_Defaults() throws {
let grpcTLSConfig = HTTP2ClientTransport.TransportServices.Config.TLS.defaults
let grpcConfig = HTTP2ClientTransport.TransportServices.Config.defaults(
transportSecurity: .tls(grpcTLSConfig)
)
let grpcTLSConfig = HTTP2ClientTransport.TransportServices.TLS.defaults
let grpcConfig = HTTP2ClientTransport.TransportServices.Config.defaults

XCTAssertEqual(grpcConfig.compression, HTTP2ClientTransport.Config.Compression.defaults)
XCTAssertEqual(grpcConfig.connection, HTTP2ClientTransport.Config.Connection.defaults)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ struct HTTP2TransportTLSEnabledTests {
let certificateKeyPairs = try SelfSignedCertificateKeyPairs()
let clientTransportConfig = self.makeDefaultTLSClientConfig(
for: clientTransport,
certificateKeyPairs: certificateKeyPairs
certificateKeyPairs: certificateKeyPairs,
authority: nil
)
let serverTransportConfig = self.makeDefaultTLSServerConfig(
for: serverTransport,
Expand Down Expand Up @@ -273,7 +274,8 @@ struct HTTP2TransportTLSEnabledTests {

private func makeDefaultTLSClientConfig(
for transportSecurity: TransportKind,
certificateKeyPairs: SelfSignedCertificateKeyPairs
certificateKeyPairs: SelfSignedCertificateKeyPairs,
authority: String? = "localhost"
) -> ClientConfig {
switch transportSecurity {
case .posix:
Expand All @@ -283,16 +285,17 @@ struct HTTP2TransportTLSEnabledTests {
.bytes(certificateKeyPairs.server.certificate, format: .der)
])
}
config.transport.http2.authority = "localhost"
config.transport.http2.authority = authority
return .posix(config)

case .transportServices:
var config = self.makeDefaultPlaintextTransportServicesClientConfig()
config.security = .tls {
$0.trustRoots = .certificates([
.bytes(certificateKeyPairs.server.certificate, format: .der)
])
}
config.transport.http2.authority = "localhost"
config.transport.http2.authority = authority
return .transportServices(config)
}
}
Expand All @@ -304,7 +307,7 @@ struct HTTP2TransportTLSEnabledTests {
let password = "somepassword"
let bundle = NIOSSLPKCS12Bundle(
certificateChain: [try NIOSSLCertificate(bytes: certificateBytes, format: .der)],
privateKey: try NIOSSLPrivateKey(bytes: certificateBytes, format: .der)
privateKey: try NIOSSLPrivateKey(bytes: privateKeyBytes, format: .der)
)
let pkcs12Bytes = try bundle.serialize(passphrase: password.utf8)
let options = [kSecImportExportPassphrase as String: password]
Expand Down

0 comments on commit 2127ad6

Please sign in to comment.