Skip to content

Commit

Permalink
RSA10l (#524)
Browse files Browse the repository at this point in the history
* Auth: deprecate `authorise` in favor of `authorize`.

* RSA10l

* Use `authorize` instead of `authorise` (close #496)
  • Loading branch information
ricardopereira authored Oct 19, 2016
1 parent 069e81c commit ceae327
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 52 deletions.
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

0 comments on commit ceae327

Please sign in to comment.