diff --git a/samples/client/petstore/swift/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj b/samples/client/petstore/swift/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj index 82da934d964..d65a2a49ff8 100644 --- a/samples/client/petstore/swift/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj +++ b/samples/client/petstore/swift/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj @@ -13,7 +13,9 @@ 6D4EFB9A1C692C6300B96B06 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6D4EFB981C692C6300B96B06 /* Main.storyboard */; }; 6D4EFB9C1C692C6300B96B06 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6D4EFB9B1C692C6300B96B06 /* Assets.xcassets */; }; 6D4EFB9F1C692C6300B96B06 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6D4EFB9D1C692C6300B96B06 /* LaunchScreen.storyboard */; }; - 6D4EFBAA1C692C6300B96B06 /* SwaggerClientTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D4EFBA91C692C6300B96B06 /* SwaggerClientTests.swift */; }; + 6D4EFBB51C693BE200B96B06 /* PetAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D4EFBB41C693BE200B96B06 /* PetAPITests.swift */; }; + 6D4EFBB71C693BED00B96B06 /* StoreAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D4EFBB61C693BED00B96B06 /* StoreAPITests.swift */; }; + 6D4EFBB91C693BFC00B96B06 /* UserAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D4EFBB81C693BFC00B96B06 /* UserAPITests.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -35,8 +37,10 @@ 6D4EFB9E1C692C6300B96B06 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 6D4EFBA01C692C6300B96B06 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 6D4EFBA51C692C6300B96B06 /* SwaggerClientTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwaggerClientTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 6D4EFBA91C692C6300B96B06 /* SwaggerClientTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwaggerClientTests.swift; sourceTree = ""; }; 6D4EFBAB1C692C6300B96B06 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 6D4EFBB41C693BE200B96B06 /* PetAPITests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PetAPITests.swift; sourceTree = ""; }; + 6D4EFBB61C693BED00B96B06 /* StoreAPITests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StoreAPITests.swift; sourceTree = ""; }; + 6D4EFBB81C693BFC00B96B06 /* UserAPITests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserAPITests.swift; sourceTree = ""; }; 8A9666BD47569881BB2CE936 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; C07EC0A94AA0F86D60668B32 /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; }; DB0055390ED4A7AE7901DEDD /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; @@ -114,8 +118,10 @@ 6D4EFBA81C692C6300B96B06 /* SwaggerClientTests */ = { isa = PBXGroup; children = ( - 6D4EFBA91C692C6300B96B06 /* SwaggerClientTests.swift */, 6D4EFBAB1C692C6300B96B06 /* Info.plist */, + 6D4EFBB41C693BE200B96B06 /* PetAPITests.swift */, + 6D4EFBB61C693BED00B96B06 /* StoreAPITests.swift */, + 6D4EFBB81C693BFC00B96B06 /* UserAPITests.swift */, ); path = SwaggerClientTests; sourceTree = ""; @@ -281,7 +287,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 6D4EFBAA1C692C6300B96B06 /* SwaggerClientTests.swift in Sources */, + 6D4EFBB71C693BED00B96B06 /* StoreAPITests.swift in Sources */, + 6D4EFBB91C693BFC00B96B06 /* UserAPITests.swift in Sources */, + 6D4EFBB51C693BE200B96B06 /* PetAPITests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/samples/client/petstore/swift/SwaggerClientTests/SwaggerClient/Info.plist b/samples/client/petstore/swift/SwaggerClientTests/SwaggerClient/Info.plist index 40c6215d906..bb71d00fa8a 100644 --- a/samples/client/petstore/swift/SwaggerClientTests/SwaggerClient/Info.plist +++ b/samples/client/petstore/swift/SwaggerClientTests/SwaggerClient/Info.plist @@ -43,5 +43,17 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + NSAppTransportSecurity + + NSExceptionDomains + + petstore.swagger.io + + + NSTemporaryExceptionAllowsInsecureHTTPLoads + + + + diff --git a/samples/client/petstore/swift/SwaggerClientTests/SwaggerClientTests/Info.plist b/samples/client/petstore/swift/SwaggerClientTests/SwaggerClientTests/Info.plist index ba72822e872..802f84f540d 100644 --- a/samples/client/petstore/swift/SwaggerClientTests/SwaggerClientTests/Info.plist +++ b/samples/client/petstore/swift/SwaggerClientTests/SwaggerClientTests/Info.plist @@ -20,5 +20,17 @@ ???? CFBundleVersion 1 + NSAppTransportSecurity + + NSExceptionDomains + + petstore.swagger.io + + + NSTemporaryExceptionAllowsInsecureHTTPLoads + + + + diff --git a/samples/client/petstore/swift/SwaggerClientTests/SwaggerClientTests/PetAPITests.swift b/samples/client/petstore/swift/SwaggerClientTests/SwaggerClientTests/PetAPITests.swift new file mode 100644 index 00000000000..59375736c59 --- /dev/null +++ b/samples/client/petstore/swift/SwaggerClientTests/SwaggerClientTests/PetAPITests.swift @@ -0,0 +1,49 @@ +// +// PetAPITests.swift +// SwaggerClient +// +// Created by Joseph Zuromski on 2/8/16. +// Copyright © 2016 Swagger. All rights reserved. +// + +import PetstoreClient +import PromiseKit +import XCTest +@testable import SwaggerClient + +class PetAPITests: XCTestCase { + + let testTimeout = 10.0 + + override func setUp() { + super.setUp() + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testxxx() { + let expectation = self.expectationWithDescription("testLogin") + PetstoreClientAPI.UserAPI.loginUser(username: "swiftTester", password: "swift").execute().then { response -> Void in + expectation.fulfill() + }.always { + // Noop for now + }.error { errorType -> Void in + // The server isn't returning JSON - and currently the alamofire implementation + // always parses responses as JSON, so making an exception for this here + // Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." + // UserInfo={NSDebugDescription=Invalid value around character 0.} + let error = errorType as NSError + if error.code == 3840 { + expectation.fulfill() + } else { + XCTFail("error logging in") + } + } + self.waitForExpectationsWithTimeout(testTimeout, handler: nil) + } + +} diff --git a/samples/client/petstore/swift/SwaggerClientTests/SwaggerClientTests/StoreAPITests.swift b/samples/client/petstore/swift/SwaggerClientTests/SwaggerClientTests/StoreAPITests.swift new file mode 100644 index 00000000000..3fad76aae4f --- /dev/null +++ b/samples/client/petstore/swift/SwaggerClientTests/SwaggerClientTests/StoreAPITests.swift @@ -0,0 +1,49 @@ +// +// StoreAPITests.swift +// SwaggerClient +// +// Created by Joseph Zuromski on 2/8/16. +// Copyright © 2016 Swagger. All rights reserved. +// + +import PetstoreClient +import PromiseKit +import XCTest +@testable import SwaggerClient + +class StoreAPITests: XCTestCase { + + let testTimeout = 10.0 + + override func setUp() { + super.setUp() + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testxxx() { + let expectation = self.expectationWithDescription("testLogin") + PetstoreClientAPI.UserAPI.loginUser(username: "swiftTester", password: "swift").execute().then { response -> Void in + expectation.fulfill() + }.always { + // Noop for now + }.error { errorType -> Void in + // The server isn't returning JSON - and currently the alamofire implementation + // always parses responses as JSON, so making an exception for this here + // Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." + // UserInfo={NSDebugDescription=Invalid value around character 0.} + let error = errorType as NSError + if error.code == 3840 { + expectation.fulfill() + } else { + XCTFail("error logging in") + } + } + self.waitForExpectationsWithTimeout(testTimeout, handler: nil) + } + +} diff --git a/samples/client/petstore/swift/SwaggerClientTests/SwaggerClientTests/SwaggerClientTests.swift b/samples/client/petstore/swift/SwaggerClientTests/SwaggerClientTests/SwaggerClientTests.swift deleted file mode 100644 index 27a86aa440a..00000000000 --- a/samples/client/petstore/swift/SwaggerClientTests/SwaggerClientTests/SwaggerClientTests.swift +++ /dev/null @@ -1,36 +0,0 @@ -// -// SwaggerClientTests.swift -// SwaggerClientTests -// -// Created by Joseph Zuromski on 2/8/16. -// Copyright © 2016 Swagger. All rights reserved. -// - -import XCTest -@testable import SwaggerClient - -class SwaggerClientTests: XCTestCase { - - override func setUp() { - super.setUp() - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDown() { - // Put teardown code here. This method is called after the invocation of each test method in the class. - super.tearDown() - } - - func testExample() { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. - } - - func testPerformanceExample() { - // This is an example of a performance test case. - self.measureBlock { - // Put the code you want to measure the time of here. - } - } - -} diff --git a/samples/client/petstore/swift/SwaggerClientTests/SwaggerClientTests/UserAPITests.swift b/samples/client/petstore/swift/SwaggerClientTests/SwaggerClientTests/UserAPITests.swift new file mode 100644 index 00000000000..b86dc2e1a06 --- /dev/null +++ b/samples/client/petstore/swift/SwaggerClientTests/SwaggerClientTests/UserAPITests.swift @@ -0,0 +1,71 @@ +// +// UserAPITests.swift +// SwaggerClient +// +// Created by Joseph Zuromski on 2/8/16. +// Copyright © 2016 Swagger. All rights reserved. +// + +import PetstoreClient +import PromiseKit +import XCTest +@testable import SwaggerClient + +class UserAPITests: XCTestCase { + + let testTimeout = 10.0 + + override func setUp() { + super.setUp() + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testLogin() { + let expectation = self.expectationWithDescription("testLogin") + PetstoreClientAPI.UserAPI.loginUser(username: "swiftTester", password: "swift").execute().then { response -> Void in + expectation.fulfill() + }.always { + // Noop for now + }.error { errorType -> Void in + // The server isn't returning JSON - and currently the alamofire implementation + // always parses responses as JSON, so making an exception for this here + // Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." + // UserInfo={NSDebugDescription=Invalid value around character 0.} + let error = errorType as NSError + if error.code == 3840 { + expectation.fulfill() + } else { + XCTFail("error logging in") + } + } + self.waitForExpectationsWithTimeout(testTimeout, handler: nil) + } + + func testLogout() { + let expectation = self.expectationWithDescription("testLogout") + PetstoreClientAPI.UserAPI.logoutUser().execute().then { response -> Void in + expectation.fulfill() + }.always { + // Noop for now + }.error { errorType -> Void in + // The server gives us no data back so alamofire parsing fails - at least + // verify that is the error we get here + // Error Domain=com.alamofire.error Code=-6006 "JSON could not be serialized. Input data was nil or zero + // length." UserInfo={NSLocalizedFailureReason=JSON could not be serialized. Input data was nil or zero + // length.} + let error = errorType as NSError + if error.code == -6006 { + expectation.fulfill() + } else { + XCTFail("error logging out") + } + } + self.waitForExpectationsWithTimeout(testTimeout, handler: nil) + } + +}