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

RSA10l #524

Merged
merged 3 commits into from
Oct 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Source/ARTAuth.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ ART_ASSUME_NONNULL_BEGIN
- (void)requestToken:(art_nullable ARTTokenParams *)tokenParams withOptions:(art_nullable ARTAuthOptions *)authOptions
callback:(void (^)(ARTTokenDetails *__art_nullable, NSError *__art_nullable))callback;

- (void)authorise:(art_nullable ARTTokenParams *)tokenParams options:(art_nullable ARTAuthOptions *)authOptions callback:(void (^)(ARTTokenDetails *__art_nullable, NSError *__art_nullable))callback;
- (void)authorise:(art_nullable ARTTokenParams *)tokenParams options:(art_nullable ARTAuthOptions *)authOptions callback:(void (^)(ARTTokenDetails *__art_nullable, NSError *__art_nullable))callback DEPRECATED_MSG_ATTRIBUTE("method will be removed in v1.0. Use authorize: method instead.");

- (void)authorize:(art_nullable ARTTokenParams *)tokenParams options:(art_nullable ARTAuthOptions *)authOptions callback:(void (^)(ARTTokenDetails *__art_nullable, NSError *__art_nullable))callback;

- (void)createTokenRequest:(art_nullable ARTTokenParams *)tokenParams options:(art_nullable ARTAuthOptions *)options
callback:(void (^)(ARTTokenRequest *__art_nullable tokenRequest, NSError *__art_nullable error))callback;
Expand Down
4 changes: 4 additions & 0 deletions Source/ARTAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ - (void)executeTokenRequest:(ARTTokenRequest *)tokenRequest callback:(void (^)(A
}

- (void)authorise:(ARTTokenParams *)tokenParams options:(ARTAuthOptions *)authOptions callback:(void (^)(ARTTokenDetails *, NSError *))callback {
[self authorize:tokenParams options:authOptions callback:callback];
}

- (void)authorize:(ARTTokenParams *)tokenParams options:(ARTAuthOptions *)authOptions callback:(void (^)(ARTTokenDetails *, NSError *))callback {
BOOL requestNewToken = NO;

ARTAuthOptions *replacedOptions;
Expand Down
2 changes: 1 addition & 1 deletion Source/ARTRest.m
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ - (void)prepareAuthorisationHeader:(ARTAuthMethod)method force:(BOOL)force compl
}
else {
self.options.force = force;
[self.auth authorise:nil options:self.options callback:^(ARTTokenDetails *tokenDetails, NSError *error) {
[self.auth authorize:nil options:self.options callback:^(ARTTokenDetails *tokenDetails, NSError *error) {
if (error) {
if (callback) callback(nil, error);
return;
Expand Down
2 changes: 1 addition & 1 deletion Source/ARTWebSocketTransport.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ - (void)connectForcingNewToken:(BOOL)forceNewToken {
[self.logger debug:__FILE__ line:__LINE__ message:@"R:%p WS:%p connecting with token auth; authorising", _delegate, self];
__weak ARTWebSocketTransport *selfWeak = self;
// Token
[self.auth authorise:nil options:options callback:^(ARTTokenDetails *tokenDetails, NSError *error) {
[self.auth authorize:nil options:options callback:^(ARTTokenDetails *tokenDetails, NSError *error) {
[self.logger debug:__FILE__ line:__LINE__ message:@"R:%p WS:%p authorised: %@ error: %@", _delegate, self, tokenDetails, error];
ARTWebSocketTransport *selfStrong = selfWeak;
if (!selfStrong) return;
Expand Down
100 changes: 54 additions & 46 deletions Spec/Auth.swift

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Spec/RestClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ class RestClient: QuickSpec {
options.tokenDetails = getTestTokenDetails()

waitUntil(timeout: testTimeout) { done in
ARTRest(options: options).auth.authorise(nil, options: nil) { tokenDetails, error in
ARTRest(options: options).auth.authorize(nil, options: nil) { tokenDetails, error in
if let e = error {
XCTFail(e.description)
done()
Expand Down
2 changes: 1 addition & 1 deletion Tests/ARTRealtimeAttachTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ - (void)testPresenceEnterRestricted {
ARTTokenParams *tokenParams = [[ARTTokenParams alloc] initWithClientId:options.clientId];
tokenParams.capability = @"{\"canpublish:*\":[\"publish\"],\"canpublish:andpresence\":[\"presence\",\"publish\"],\"cansubscribe:*\":[\"subscribe\"]}";

[realtime.auth authorise:tokenParams options:options callback:^(ARTTokenDetails *tokenDetails, NSError *error) {
[realtime.auth authorize:tokenParams options:options callback:^(ARTTokenDetails *tokenDetails, NSError *error) {
options.token = tokenDetails.token;
[realtime connect];
}];
Expand Down
2 changes: 1 addition & 1 deletion Tests/ARTRestCapabilityTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ - (void)testPublishRestricted {
ARTTokenParams *tokenParams = [[ARTTokenParams alloc] initWithClientId:options.clientId];
tokenParams.capability = @"{\"canpublish:*\":[\"publish\"],\"canpublish:andpresence\":[\"presence\",\"publish\"],\"cansubscribe:*\":[\"subscribe\"]}";

[[[ARTRest alloc] initWithOptions:options].auth authorise:tokenParams options:options callback:^(ARTTokenDetails *tokenDetails, NSError *error) {
[[[ARTRest alloc] initWithOptions:options].auth authorize:tokenParams options:options callback:^(ARTTokenDetails *tokenDetails, NSError *error) {
options.token = tokenDetails.token;
ARTRest *rest = [[ARTRest alloc] initWithOptions:options];
ARTRestChannel *channel = [rest.channels get:@"canpublish:test"];
Expand Down