@@ -5,7 +5,7 @@ import CircuitBreaker
55/// URL for the weather underground that many of the tests use
66let apiKey = " 96318a1fc52412b1 " // We don't know if API Key for the wunderground API could expire at some point...
77let echoURL = " http://httpbin.org/post "
8- let echoURLSecure = " https://httpbin.org/post "
8+ let echoURLSecure = " https://self-signed.badssl.com/ "
99let apiURL = " http://api.wunderground.com/api/ \( apiKey) /conditions/q/CA/San_Francisco.json "
1010let geolookupURL = " http://api.wunderground.com/api/ \( apiKey) /geolookup/q/CA/San_Francisco.json "
1111let templetedAPIURL = " http://api.wunderground.com/api/ \( apiKey) /conditions/q/{state}/{city}.json "
@@ -45,7 +45,6 @@ class SwiftyRequestTests: XCTestCase {
4545
4646 static var allTests = [
4747 ( " testEchoData " , testEchoData) ,
48- ( " testEchoDataSecure " , testEchoDataSecure) ,
4948 ( " testResponseData " , testResponseData) ,
5049 ( " testResponseObject " , testResponseObject) ,
5150 ( " testResponseArray " , testResponseArray) ,
@@ -60,6 +59,7 @@ class SwiftyRequestTests: XCTestCase {
6059 ( " testURLTemplateNoTemplateValues " , testURLTemplateNoTemplateValues) ,
6160 ( " testQueryParamUpdating " , testQueryParamUpdating) ,
6261 ( " testQueryTemplateParams " , testQueryTemplateParams)
62+
6363 ]
6464
6565 // MARK: Helper methods
@@ -133,35 +133,24 @@ class SwiftyRequestTests: XCTestCase {
133133 waitForExpectations ( timeout: 20 )
134134 }
135135
136- func testEchoDataSecure( ) {
136+ func testGetSelfSignedCert( ) {
137+ #if !os(Linux)
137138 let expectation = self . expectation ( description: " Data Echoed Back " )
138139
139- let origJson : [ String : Any ] = [ " Data " : " string " ]
140-
141- guard let data = try ? JSONSerialization . data ( withJSONObject: origJson, options: [ ] ) else {
142- XCTFail ( " Could not encode json " )
143- return
144- }
145-
146- let request = RestRequest ( method: . post, url: echoURLSecure, containsSelfSignedCert: true )
147- request. messageBody = data
140+ let request = RestRequest ( method: . get, url: echoURLSecure, containsSelfSignedCert: true )
148141
149142 request. responseData { response in
150143 switch response. result {
151144 case . success( let retval) :
152- guard let decoded = try ? JSONSerialization . jsonObject ( with: retval, options: [ ] ) ,
153- let json = decoded as? [ String : Any ] else {
154- XCTFail ( " Could not decode json " )
155- return
156- }
157- XCTAssertEqual ( " { \" Data \" : \" string \" } " , json [ " data " ] as? String )
145+ XCTAssert ( retval. count != 0 )
158146 case . failure( let error) :
159147 XCTFail ( " Failed to get data response: \( error) " )
160148 }
161149 expectation. fulfill ( )
162150 }
163151
164152 waitForExpectations ( timeout: 20 )
153+ #endif
165154 }
166155
167156 // API Key (96318a1fc52412b1) for the wunderground API may expire at some point.
0 commit comments