2
0
Эх сурвалжийг харах

Fix the SSL-enabled tests.

Daniel Alm 7 жил өмнө
parent
commit
cacd605004

+ 4 - 5
Tests/SwiftGRPCTests/EchoTests.swift

@@ -61,6 +61,7 @@ class EchoTests: XCTestCase {
                                provider: provider)
       server.start(queue: DispatchQueue.global())
       client = Echo_EchoServiceClient(address: address, certificates: certificateString, host: "example.com")
+      client.host = "example.com"
     } else {
       server = Echo_EchoServer(address: address, provider: provider)
       server.start(queue: DispatchQueue.global())
@@ -80,11 +81,9 @@ class EchoTests: XCTestCase {
   }
 }
 
-// Currently broken and thus commented out.
-// TODO(danielalm): Fix these.
-//class EchoTestsSecure: EchoTests {
-//  override var secure: Bool { return true }
-//}
+class EchoTestsSecure: EchoTests {
+  override var secure: Bool { return true }
+}
 
 extension EchoTests {
   func testUnary() {

+ 2 - 12
Tests/SwiftGRPCTests/GRPCTests.swift

@@ -89,18 +89,9 @@ func runTest(useSSL: Bool) {
   // create the server
   let server: Server
   if useSSL {
-    let certificateURL = URL(fileURLWithPath: "Tests/ssl.crt")
-    let keyURL = URL(fileURLWithPath: "Tests/ssl.key")
-    guard
-      let certificate = try? String(contentsOf: certificateURL, encoding: .utf8),
-      let key = try? String(contentsOf: keyURL, encoding: .utf8)
-      else {
-        // FIXME: We don't want tests to silently pass just because the certificates can't be loaded.
-        return
-    }
     server = Server(address: address,
-                    key: key,
-                    certs: certificate)
+                    key: String(data: keyForTests, encoding: .utf8)!,
+                    certs: String(data: certificateForTests, encoding: .utf8)!)
   } else {
     server = Server(address: address)
   }
@@ -151,7 +142,6 @@ func runClient(useSSL: Bool) throws {
       else {
         return
     }
-    let host = "example.com"
     channel = Channel(address: address, certificates: certificates, host: host)
   } else {
     channel = Channel(address: address, secure: false)