Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added a functional spec that reproduces issue #26.

  • Loading branch information...
commit 7e4a8f5a4e83c693532e813b3f70836be3537c09 1 parent 0f8de83
@lukeredpath authored
Showing with 56 additions and 1 deletion.
  1. +49 −1 Functional Specs/PrivateChannelsSpec.m
  2. +7 −0 Scripts/auth_server.rb
View
50 Functional Specs/PrivateChannelsSpec.m
@@ -72,7 +72,55 @@
});
[[expectFutureValue(theValue(failedToSubscribe)) shouldEventuallyBeforeTimingOutAfter(3)] beYes];
- });
+ });
+});
+
+describe(@"Subscribing to multiple private channels with delays (see issue #26)", ^{
+
+ __block PTPusher *client = nil;
+
+ registerMatchers(@"PT");
+ enableClientDebugging();
+
+ beforeAll(^{
+ client = newTestClient();
+
+ // this requires the auth server to be running (rake authserver:start)
+ client.authorizationURL = [NSURL URLWithString:@"http://localhost:9292/private/slowauth"];
+ });
+
+ afterAll(^{
+ [client disconnect];
+ waitForClientToDisconnect(client);
+ });
+
+ it(@"should be successful", ^{
+ onAuthorizationRequired(^(NSMutableURLRequest *authRequest) {
+ NSLog(@"AUTHORIZING REQUEST");
+ [authRequest setHTTPBasicAuthUsername:@"admin" password:@"letmein"];
+ });
+
+ NSInteger numberToConnect = 5;
+
+ onConnect(^{
+ for (int i = 0; i < numberToConnect; i++) {
+ [client subscribeToPrivateChannelNamed:[NSString stringWithFormat:@"secret-channel-%d", i]];
+ }
+ });
+
+ __block NSInteger numberOfSubscribedChannels = 0;
+ __block BOOL allSubscribed = NO;
+
+ onSubscribe(^(PTPusherChannel *subscribedChannel) {
+ numberOfSubscribedChannels++;
+
+ if (numberOfSubscribedChannels == numberToConnect) {
+ allSubscribed = YES;
+ }
+ });
+
+ [[expectFutureValue(theValue(allSubscribed)) shouldEventuallyBeforeTimingOutAfter(10)] beYes];
+ });
});
SPEC_END
View
7 Scripts/auth_server.rb
@@ -41,6 +41,13 @@ class FakeAuthServer < Sinatra::Base
[200, {"Content-Type" => "application/json"}, response.to_json]
end
+ post "/private/slowauth" do
+ puts ">> Authenticating private channel:#{params[:channel_name]} socket:#{params[:socket_id]}"
+ response = Pusher[params[:channel_name]].authenticate(params[:socket_id])
+ sleep(1)
+ [200, {"Content-Type" => "application/json"}, response.to_json]
+ end
+
post "/presence/auth" do
puts ">> Authenticating presence channel:#{params[:channel_name]} socket:#{params[:socket_id]}"
Please sign in to comment.
Something went wrong with that request. Please try again.