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

Fix spec failures #506

Merged
merged 14 commits into from
Sep 27, 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
6 changes: 6 additions & 0 deletions Ably.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
D7588AF41BFF91B800BB8279 /* ARTURLSessionServerTrust.m in Sources */ = {isa = PBXBuildFile; fileRef = D7588AF21BFF91B800BB8279 /* ARTURLSessionServerTrust.m */; };
D77394031C6F6FFE00F5478F /* ARTProtocolMessage+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = D77394021C6F6FFE00F5478F /* ARTProtocolMessage+Private.h */; settings = {ATTRIBUTES = (Private, ); }; };
D780846E1C68B3E50083009D /* NSObject+TestSuite.m in Sources */ = {isa = PBXBuildFile; fileRef = D780846D1C68B3E50083009D /* NSObject+TestSuite.m */; };
D79FF2751D901CD50067FA6A /* ARTRealtime+TestSuite.m in Sources */ = {isa = PBXBuildFile; fileRef = D79FF2741D901CD50067FA6A /* ARTRealtime+TestSuite.m */; };
D7B17EE31C07208B00A6958E /* ARTConnectionDetails.h in Headers */ = {isa = PBXBuildFile; fileRef = D7B17EE11C07208B00A6958E /* ARTConnectionDetails.h */; settings = {ATTRIBUTES = (Public, ); }; };
D7B17EE41C07208B00A6958E /* ARTConnectionDetails.m in Sources */ = {isa = PBXBuildFile; fileRef = D7B17EE21C07208B00A6958E /* ARTConnectionDetails.m */; };
D7C1B8771BBEA81A0087B55F /* Auth.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7C1B8761BBEA81A0087B55F /* Auth.swift */; };
Expand Down Expand Up @@ -361,6 +362,8 @@
D77394021C6F6FFE00F5478F /* ARTProtocolMessage+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ARTProtocolMessage+Private.h"; sourceTree = "<group>"; };
D780846C1C68B3E50083009D /* NSObject+TestSuite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+TestSuite.h"; sourceTree = "<group>"; };
D780846D1C68B3E50083009D /* NSObject+TestSuite.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+TestSuite.m"; sourceTree = "<group>"; };
D79FF2731D901CD50067FA6A /* ARTRealtime+TestSuite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ARTRealtime+TestSuite.h"; sourceTree = "<group>"; };
D79FF2741D901CD50067FA6A /* ARTRealtime+TestSuite.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "ARTRealtime+TestSuite.m"; sourceTree = "<group>"; };
D7B17EE11C07208B00A6958E /* ARTConnectionDetails.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARTConnectionDetails.h; sourceTree = "<group>"; };
D7B17EE21C07208B00A6958E /* ARTConnectionDetails.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTConnectionDetails.m; sourceTree = "<group>"; };
D7C1B8761BBEA81A0087B55F /* Auth.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Auth.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -464,6 +467,8 @@
1C1E52E81AB32E6E004A690F /* Realtime */ = {
isa = PBXGroup;
children = (
D79FF2731D901CD50067FA6A /* ARTRealtime+TestSuite.h */,
D79FF2741D901CD50067FA6A /* ARTRealtime+TestSuite.m */,
96E408351A38595F00087F77 /* ARTRealtimeAttachTest.m */,
1CC3D94A1AB6FBB60005BEB0 /* ARTRealtimeChannelHistoryTest.m */,
1C1E53011AB373C5004A690F /* ARTRealtimeChannelTest.m */,
Expand Down Expand Up @@ -1221,6 +1226,7 @@
1C1E53021AB373C5004A690F /* ARTRealtimeChannelTest.m in Sources */,
1CC3D9571AB700EC0005BEB0 /* ARTRealtimeMessageTest.m in Sources */,
1C1E52F21AB32ED1004A690F /* ARTRestChannelPublishTest.m in Sources */,
D79FF2751D901CD50067FA6A /* ARTRealtime+TestSuite.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
4 changes: 3 additions & 1 deletion Source/ARTAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,10 @@ - (void)handleAuthUrlResponse:(NSHTTPURLResponse *)response withData:(NSData *)d
ARTTokenRequest *tokenRequest = [_rest.encoders[@"application/json"] decodeTokenRequest:data error:&decodeError];
if (decodeError) {
callback(nil, decodeError);
} else {
} else if (tokenRequest) {
[tokenRequest toTokenDetails:self callback:callback];
} else {
callback(nil, [ARTErrorInfo createWithCode:ARTStateAuthUrlIncompatibleContent message:@"content response cannot be used for token request"]);
}
} else {
callback(tokenDetails, nil);
Expand Down
10 changes: 9 additions & 1 deletion Source/ARTRestPresence.m
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,15 @@ - (BOOL)history:(ARTDataQuery *)query callback:(void(^)(__GENERIC(ARTPaginatedRe

ARTPaginatedResultResponseProcessor responseProcessor = ^(NSHTTPURLResponse *response, NSData *data) {
id<ARTEncoder> encoder = [_channel.rest.encoders objectForKey:response.MIMEType];
return [encoder decodePresenceMessages:data];
return [[encoder decodePresenceMessages:data] artMap:^(ARTPresenceMessage *message) {
NSError *error;
message = [message decodeWithEncoder:_channel.dataEncoder error:&error];
if (error != nil) {
ARTErrorInfo *errorInfo = [ARTErrorInfo wrap:(ARTErrorInfo *)error.userInfo[NSLocalizedFailureReasonErrorKey] prepend:@"Failed to decode data: "];
[_channel.logger error:@"RS:%p %@", _channel.rest, errorInfo.message];
}
return message;
}];
};

[ARTPaginatedResult executePaginated:_channel.rest withRequest:request andResponseProcessor:responseProcessor callback:callback];
Expand Down
1 change: 1 addition & 0 deletions Source/ARTStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ typedef NS_ENUM(NSUInteger, ARTState) {
ARTStateNoClientId,
ARTStateMismatchedClientId,
ARTStateRequestTokenFailed,
ARTStateAuthUrlIncompatibleContent,
ARTStateBadConnectionState,
ARTStateError = 99999
};
Expand Down
10 changes: 7 additions & 3 deletions Spec/Auth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class Auth : QuickSpec {
options.autoConnect = false

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

Expand Down Expand Up @@ -1893,6 +1893,10 @@ class Auth : QuickSpec {
// Invalid TokenDetails
waitUntil(timeout: testTimeout) { done in
ARTRest(options: options).auth.authorise(nil, options: nil) { tokenDetails, error in
guard let error = error else {
fail("Error is nil"); done(); return
}
expect(error.code).to(equal(Int(ARTState.AuthUrlIncompatibleContent.rawValue)))
expect(tokenDetails).to(beNil())
done()
}
Expand Down Expand Up @@ -2030,7 +2034,7 @@ class Auth : QuickSpec {

describe("Reauth") {
// RTC8
it("should use authorise({force: true}) to reauth with a token with a different set of capabilities") {
pending("should use authorise({force: true}) to reauth with a token with a different set of capabilities") {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EvgenyKarkan The re-attach is failing because the channel is in the Failed state. I saw that RTC8 as some subspecs so I assumed that it isn't ready.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ricardopereira not sure what you mean by some subspecs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattheworiordan I mean RTC8 is composed by RTC8a1, RTC8a2, RTC8a3, etc. So the test should be complying those but now I noticed that RTC8 is a new spec from v0.9. I will fix #485, the one responsible for failing the test.

// init ARTRest
let restOptions = AblyTests.setupOptions(AblyTests.jsonRestOptions)
let rest = ARTRest(options: restOptions)
Expand Down Expand Up @@ -2059,7 +2063,7 @@ class Auth : QuickSpec {
realtimeOptions.clientId = "testClientId"

let realtime = ARTRealtime(options:realtimeOptions)
defer { realtime.close() }
defer { realtime.dispose(); realtime.close() }

// wait for connected state
waitUntil(timeout: testTimeout) { done in
Expand Down
2 changes: 1 addition & 1 deletion Spec/RealtimeClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class RealtimeClient: QuickSpec {
// G4
it("All WebSocket connections should include the current API version") {
let client = AblyTests.newRealtime(AblyTests.commonAppSetup())
defer { client.close() }
defer { client.dispose(); client.close() }
let channel = client.channels.get("test")
waitUntil(timeout: testTimeout) { done in
channel.publish(nil, data: "message") { error in
Expand Down
Loading