Skip to content

Commit

Permalink
Fix RSC9
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardopereira committed Oct 27, 2016
1 parent 2fdb883 commit 095122d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions Spec/RestClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -371,22 +371,30 @@ class RestClient: QuickSpec {
// RSC9
it("should use Auth to manage authentication") {
let options = AblyTests.clientOptions()
options.tokenDetails = getTestTokenDetails()
guard let testTokenDetails = getTestTokenDetails() else {
fail("No test token details"); return
}
options.tokenDetails = testTokenDetails
options.authCallback = { tokenParams, completion in
completion(testTokenDetails, nil)
}

let client = ARTRest(options: options)
expect(client.auth).to(beAnInstanceOf(ARTAuth.self))

waitUntil(timeout: testTimeout) { done in
ARTRest(options: options).auth.authorize(nil, options: nil) { tokenDetails, error in
client.auth.authorize(nil, options: nil) { tokenDetails, error in
if let e = error {
XCTFail(e.description)
done()
return
}
guard let tokenDetails = tokenDetails else {
XCTFail("expected tokenDetails not to be nil when error is nil")
XCTFail("expected tokenDetails to not be nil when error is nil")
done()
return
}
// Use the same token because it is valid
expect(tokenDetails.token).to(equal(options.tokenDetails!.token))
expect(tokenDetails.token).to(equal(testTokenDetails.token))
done()
}
}
Expand Down

0 comments on commit 095122d

Please sign in to comment.