Skip to content

Commit

Permalink
Merge pull request #346 from ably/rsa8c2
Browse files Browse the repository at this point in the history
RSA8c2
  • Loading branch information
tcard committed Apr 1, 2016
2 parents 7271481 + c03ec0a commit f22aacb
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions Spec/Auth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class Auth : QuickSpec {
options.autoConnect = false

let client = ARTRealtime(options: options)
defer { client.close() }
client.setTransportClass(TestProxyTransport.self)
client.connect()

Expand All @@ -162,8 +163,6 @@ class Auth : QuickSpec {
else {
XCTFail("MockTransport is not working")
}

client.close()
}
}

Expand Down Expand Up @@ -617,6 +616,34 @@ class Auth : QuickSpec {
}
}
}

// RSA8c2
it("TokenParams should take precedence over any configured authParams when a name conflict occurs") {
let options = ARTClientOptions()
options.clientId = "john"
options.authUrl = NSURL(string: "http://auth.ably.io")
options.authMethod = "GET"
options.authHeaders = ["X-Header-1": "foo1", "X-Header-2": "foo2"]
let authParams = [
"key": "secret",
"clientId": "should be overridden"
]
options.authParams = authParams.map { NSURLQueryItem(name: $0, value: $1) }

let tokenParams = ARTTokenParams()
tokenParams.clientId = "tester"

let client = ARTRest(options: options)
client.httpExecutor = mockExecutor

waitUntil(timeout: testTimeout) { done in
client.auth.requestToken(tokenParams, withOptions: nil) { tokenDetails, error in
let query = mockExecutor.requests[0].URL!.query
expect(query).to(haveParam("clientId", withValue: tokenParams.clientId!))
done()
}
}
}

// RSA8c3
it("should override previously configured parameters") {
Expand Down

0 comments on commit f22aacb

Please sign in to comment.