Skip to content

Commit

Permalink
Merge pull request #91 from ably/RSA8b
Browse files Browse the repository at this point in the history
RSA8b
  • Loading branch information
mattheworiordan committed Jan 14, 2016
2 parents 453605e + 62fd370 commit 652abd5
Showing 1 changed file with 54 additions and 2 deletions.
56 changes: 54 additions & 2 deletions ablySpec/Auth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,7 @@ class Auth : QuickSpec {
let mergedParams = rest.auth.mergeParams(tokenParams)
expect(mergedParams.ttl) == 30.0
}

// TODO: RSA8b

}

// RSA8c
Expand Down Expand Up @@ -598,6 +597,59 @@ class Auth : QuickSpec {

expect(createTokenRequestMethodWasCalled).to(beTrue())
}

// RSA8b
context("should support all TokenParams") {

let options = AblyTests.commonAppSetup()
let currentCliend = "client_string"
options.clientId = currentCliend

let rest = ARTRest(options: options)

it("using defaults") {
// Default values
let defaultTokenParams = ARTAuthTokenParams(clientId: currentCliend)

waitUntil(timeout: testTimeout) { done in
rest.auth.requestToken(nil, withOptions: nil, callback: { tokenDetails, error in
expect(tokenDetails?.clientId).to(equal(defaultTokenParams.clientId))
expect(tokenDetails?.capability).to(equal(defaultTokenParams.capability))
expect(tokenDetails?.issued).toNot(beNil())
expect(tokenDetails?.expires).toNot(beNil())
if let issued = tokenDetails?.issued, let expires = tokenDetails?.expires {
expect(expires.timeIntervalSinceDate(issued)).to(equal(defaultTokenParams.ttl))
}
done()
})
}
}

it("overriding defaults") {
// Custom values
let expectedClientId = "token_client"
let expectedTtl = 4800.0
let expectedCapability = "{\"canpublish:*\":[\"publish\"]}"

let tokenParams = ARTAuthTokenParams(clientId: expectedClientId)
tokenParams.ttl = expectedTtl
tokenParams.capability = expectedCapability

waitUntil(timeout: testTimeout) { done in
rest.auth.requestToken(tokenParams, withOptions: nil, callback: { tokenDetails, error in
expect(tokenDetails?.clientId).to(equal(expectedClientId))
expect(tokenDetails?.capability).to(equal(expectedCapability))
expect(tokenDetails?.issued).toNot(beNil())
expect(tokenDetails?.expires).toNot(beNil())
if let issued = tokenDetails?.issued, let expires = tokenDetails?.expires {
expect(expires.timeIntervalSinceDate(issued)).to(equal(expectedTtl))
}
done()
})
}
}

}
}
}
}

0 comments on commit 652abd5

Please sign in to comment.