Skip to content

Commit

Permalink
Add test to request a JWT token via requestToken with application/jwt…
Browse files Browse the repository at this point in the history
… content type
  • Loading branch information
funkyboy committed Jun 4, 2018
1 parent 5c36c8c commit 4e37a96
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions Spec/Auth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3907,24 +3907,37 @@ class Auth : QuickSpec {
}

context("when the JWT token is returned with application/jwt content tye") {
let options = AblyTests.clientOptions()
let keys = getKeys()
options.authUrl = NSURL(string: echoServerAddress)! as URL
options.authParams = [URLQueryItem]() as [URLQueryItem]?
options.authParams?.append(URLQueryItem(name: "keyName", value: keys["keyName"]) as URLQueryItem)
options.authParams?.append(URLQueryItem(name: "keySecret", value: keys["keySecret"]) as URLQueryItem)
options.authParams?.append(URLQueryItem(name: "returnType", value: "jwt") as URLQueryItem)
let client = ARTRest(options: options)

it("the client successfully connects and pulls stats") {
let options = AblyTests.clientOptions()
let keys = getKeys()
options.authUrl = NSURL(string: echoServerAddress)! as URL
options.authParams = [URLQueryItem]() as [URLQueryItem]?
options.authParams?.append(URLQueryItem(name: "keyName", value: keys["keyName"]) as URLQueryItem)
options.authParams?.append(URLQueryItem(name: "keySecret", value: keys["keySecret"]) as URLQueryItem)
options.authParams?.append(URLQueryItem(name: "returnType", value: "jwt") as URLQueryItem)
let client = ARTRest(options: options)

waitUntil(timeout: testTimeout) { done in
client.stats{ stats, error in
expect(error).to(beNil())
done()
}
}
}

it("the client can request a new token to initilize another client that connects and pulls stats") {
waitUntil(timeout: testTimeout) { done in
client.auth.requestToken(nil, with: nil, callback: { tokenDetails, error in
let newClientOptions = AblyTests.clientOptions()
newClientOptions.token = tokenDetails!.token
let newClient = ARTRest(options: newClientOptions)
newClient.stats{ stats, error in
expect(error).to(beNil())
done()
}
})
}
}
}
}
}
Expand Down

0 comments on commit 4e37a96

Please sign in to comment.