Parcourir la source

Fixed TLS evaluation test that can fail in a different way when behind a proxy.

Christian Noon il y a 9 ans
Parent
commit
80f01ba759
1 fichiers modifiés avec 5 ajouts et 3 suppressions
  1. 5 3
      Tests/TLSEvaluationTests.swift

+ 5 - 3
Tests/TLSEvaluationTests.swift

@@ -93,10 +93,12 @@ class TLSEvaluationExpiredLeafCertificateTestCase: BaseTestCase {
         waitForExpectationsWithTimeout(timeout, handler: nil)
 
         // Then
-        XCTAssertNotNil(error, "error should not be nil")
+        XCTAssertNotNil(error)
 
-        if let code = error?.code {
-            XCTAssertEqual(code, NSURLErrorServerCertificateUntrusted, "code should be untrusted server certficate")
+        if let error = error where error.domain == NSURLErrorDomain {
+            XCTAssertEqual(error.code, NSURLErrorServerCertificateUntrusted)
+        } else if let error = error where error.domain == (kCFErrorDomainCFNetwork as String) {
+            XCTAssertEqual(error.code, Int(CFNetworkErrors.CFErrorHTTPSProxyConnectionFailure.rawValue))
         } else {
             XCTFail("error should be an NSError")
         }