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

Add rsa4e #750

Merged
merged 2 commits into from
Jul 26, 2018
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
5 changes: 5 additions & 0 deletions Source/ARTAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ - (void)_requestToken:(ARTTokenParams *)tokenParams withOptions:(ARTAuthOptions

void (^checkerCallback)(ARTTokenDetails *_Nullable, NSError *_Nullable) = ^(ARTTokenDetails *tokenDetails, NSError *error) {
if (error) {
if (error.code == NSURLErrorTimedOut) {
ARTErrorInfo *ablyError = [ARTErrorInfo createWithCode:40170 message:@"Error in requesting auth token"];
callback(nil, ablyError);
return;
}
callback(nil, error);
return;
}
Expand Down
33 changes: 32 additions & 1 deletion Spec/RestClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,37 @@ class RestClient: QuickSpec {
}
}

} //RestClient
}

context("if in the course of a REST request an attempt to authenticate using authUrl fails due to a timeout") {
// RSA4e
it("the request should result in an error with code 40170, statusCode 401, and a suitable error message") {
let options = AblyTests.commonAppSetup()
let token = getTestToken()
options.httpRequestTimeout = 3 // short timeout to make it fail faster
options.authUrl = NSURL(string: "http://10.255.255.1")! as URL
options.authParams = [NSURLQueryItem]() as [URLQueryItem]?
options.authParams?.append(NSURLQueryItem(name: "type", value: "text") as URLQueryItem)
options.authParams?.append(NSURLQueryItem(name: "body", value: token) as URLQueryItem)

let client = ARTRest(options: options)
waitUntil(timeout: testTimeout, action: { done in
let channel = client.channels.get("test-channel")
channel.publish("test", data: "test-data", callback: { error in
guard let error = error else {
fail("Error should not be empty")
done()
return
}
expect(error.statusCode).to(equal(401))
expect(error.code).to(equal(40170))
expect(error.message).to(contain("Error in requesting auth token"))
done()
})
})


}
}
}
}