Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSA8c2 #346

Merged
merged 1 commit into from Apr 1, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 29 additions & 2 deletions Spec/Auth.swift
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