Skip to content

Commit

Permalink
Merge d61da55 into b86f3e2
Browse files Browse the repository at this point in the history
  • Loading branch information
shiranyo committed Nov 23, 2017
2 parents b86f3e2 + d61da55 commit 01839ba
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 11 deletions.
41 changes: 33 additions & 8 deletions BluemixAppIDTests/AuthorizationUIManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class AuthorizationUIManagerTests: XCTestCase {
}

func onAuthorizationSuccess(accessToken: AccessToken?, identityToken: IdentityToken?, response:Response?) {
XCTFail()
self.exp?.fulfill()
}

}
Expand Down Expand Up @@ -113,9 +113,6 @@ public class AuthorizationUIManagerTests: XCTestCase {
}
}




}

func testApplicationErr3() {
Expand Down Expand Up @@ -149,10 +146,38 @@ public class AuthorizationUIManagerTests: XCTestCase {
XCTFail("err: \(error)")
}
}




}

// happy flow - sign_up done flow
func testApplicationDoneFlowSignUp() {

let expectation1 = expectation(description: "Found Flow")
let manager = AuthorizationUIManager(oAuthManager: oauthManager, authorizationDelegate: delegate(exp: expectation1, errMsg: nil), authorizationUrl: "someurl", redirectUri: "someredirect")
manager.loginView = MockSafariView(url:URL(string: "http://www.someurl.com")!)
// happy flow with sign_up done
XCTAssertTrue(manager.application(UIApplication.shared, open: URL(string:AppIDConstants.REDIRECT_URI_VALUE.lowercased() + "?flow=forgot_password")!, options: [:]))
waitForExpectations(timeout: 1) { error in
if let error = error {
XCTFail("err: \(error)")
}
}

}

// happy flow - forgot_password done flow
func testApplicationDoneFlowForgotPassword() {

let expectation1 = expectation(description: "Found Flow")
let manager = AuthorizationUIManager(oAuthManager: oauthManager, authorizationDelegate: delegate(exp: expectation1, errMsg: nil), authorizationUrl: "someurl", redirectUri: "someredirect")
manager.loginView = MockSafariView(url:URL(string: "http://www.someurl.com")!)
// happy flow with forgot_password done
XCTAssertTrue(manager.application(UIApplication.shared, open: URL(string:AppIDConstants.REDIRECT_URI_VALUE.lowercased() + "?flow=forgot_password")!, options: [:]))
waitForExpectations(timeout: 1) { error in
if let error = error {
XCTFail("err: \(error)")
}
}

}


Expand Down
4 changes: 2 additions & 2 deletions BluemixAppIDTests/TokenManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ class TokenManagerTests: XCTestCase {

func onAuthorizationSuccess(accessToken: AccessToken?, identityToken: IdentityToken?, response: Response?) {
if success {
XCTAssertEqual(accessToken?.raw, AccessTokenImpl(with: AppIDTestConstants.ACCESS_TOKEN)!.raw)
XCTAssertEqual(identityToken?.raw, IdentityTokenImpl(with: AppIDTestConstants.ID_TOKEN)!.raw)
XCTAssertEqual(accessToken!.raw, AccessTokenImpl(with: AppIDTestConstants.ACCESS_TOKEN)!.raw)
XCTAssertEqual(identityToken!.raw, IdentityTokenImpl(with: AppIDTestConstants.ID_TOKEN)!.raw)
exp.fulfill()
}
}
Expand Down
1 change: 1 addition & 0 deletions Source/BluemixAppID/internal/AppIDConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ internal class AppIDConstants {
internal static var JSON_SIGN_UP_KEY = "sign_up"
internal static var JSON_FORGOT_PASSWORD_KEY = "forgot_password"
internal static var JSON_GRANT_TYPE_KEY = "grant_type"
internal static var JSON_FLOW_KEY = "flow"
internal static var JSON_USERNAME = "username"
internal static var JSON_PASSWORD = "password"
internal static var APPID_ACCESS_TOKEN = "appid_access_token"
Expand Down
4 changes: 3 additions & 1 deletion Source/BluemixAppID/internal/AuthorizationUIManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class AuthorizationUIManager {
} else if let flow = Utils.getParamFromQuery(url: url, paramName: "flow") {
if flow == AppIDConstants.JSON_FORGOT_PASSWORD_KEY || flow == AppIDConstants.JSON_SIGN_UP_KEY {
loginView?.dismiss(animated: true, completion: { () -> Void in
AuthorizationUIManager.logger.debug(message: "finish " + flow + " flow")
AuthorizationUIManager.logger.debug(message: "Finish " + flow + " flow")
self.authorizationDelegate.onAuthorizationSuccess(accessToken: nil, identityToken: nil, response: nil)
})
return true
Expand Down Expand Up @@ -108,3 +108,5 @@ public class AuthorizationUIManager {


}


0 comments on commit 01839ba

Please sign in to comment.