@@ -99,9 +99,9 @@ def authentication_string(*data)
99
99
end
100
100
101
101
it "should return an authentication string given a socket id" do
102
- auth = @channel . authentication_string ( 'socketid ' )
102
+ auth = @channel . authentication_string ( '1.1 ' )
103
103
104
- auth . should == '12345678900000001:827076f551e22451357939e4c7bb1200de29f921d5bf80b40d71668f9cd61c40 '
104
+ auth . should == '12345678900000001:02259dff9a2a3f71ea8ab29ac0c0c0ef7996c8f3fd3702be5533f30da7d7fed4 '
105
105
end
106
106
107
107
it "should raise error if authentication is invalid" do
@@ -112,17 +112,17 @@ def authentication_string(*data)
112
112
113
113
describe 'with extra string argument' do
114
114
it 'should be a string or nil' do
115
- authentication_string ( 'socketid ' , 123 ) . should raise_error Pusher ::Error
116
- authentication_string ( 'socketid ' , { } ) . should raise_error Pusher ::Error
115
+ authentication_string ( '1.1 ' , 123 ) . should raise_error Pusher ::Error
116
+ authentication_string ( '1.1 ' , { } ) . should raise_error Pusher ::Error
117
117
118
- authentication_string ( 'socketid ' , 'boom' ) . should_not raise_error
119
- authentication_string ( 'socketid ' , nil ) . should_not raise_error
118
+ authentication_string ( '1.1 ' , 'boom' ) . should_not raise_error
119
+ authentication_string ( '1.1 ' , nil ) . should_not raise_error
120
120
end
121
121
122
122
it "should return an authentication string given a socket id and custom args" do
123
- auth = @channel . authentication_string ( 'socketid ' , 'foobar' )
123
+ auth = @channel . authentication_string ( '1.1 ' , 'foobar' )
124
124
125
- auth . should == "12345678900000001:#{ hmac ( @client . secret , "socketid :test_channel:foobar" ) } "
125
+ auth . should == "12345678900000001:#{ hmac ( @client . secret , "1.1 :test_channel:foobar" ) } "
126
126
end
127
127
end
128
128
end
@@ -135,12 +135,34 @@ def authentication_string(*data)
135
135
it 'should return a hash with signature including custom data and data as json string' do
136
136
MultiJson . stub ( :encode ) . with ( @custom_data ) . and_return 'a json string'
137
137
138
- response = @channel . authenticate ( 'socketid ' , @custom_data )
138
+ response = @channel . authenticate ( '1.1 ' , @custom_data )
139
139
140
140
response . should == {
141
- :auth => "12345678900000001:#{ hmac ( @client . secret , "socketid :test_channel:a json string" ) } " ,
141
+ :auth => "12345678900000001:#{ hmac ( @client . secret , "1.1 :test_channel:a json string" ) } " ,
142
142
:channel_data => 'a json string'
143
143
}
144
144
end
145
+
146
+ it 'should fail on invalid socket_ids' do
147
+ lambda {
148
+ @channel . authenticate ( '1.1:' )
149
+ } . should raise_error Pusher ::Error
150
+
151
+ lambda {
152
+ @channel . authenticate ( '1.1foo' , 'channel' )
153
+ } . should raise_error Pusher ::Error
154
+
155
+ lambda {
156
+ @channel . authenticate ( ':1.1' )
157
+ } . should raise_error Pusher ::Error
158
+
159
+ lambda {
160
+ @channel . authenticate ( 'foo1.1' , 'channel' )
161
+ } . should raise_error Pusher ::Error
162
+
163
+ lambda {
164
+ @channel . authenticate ( 'foo' , 'channel' )
165
+ } . should raise_error Pusher ::Error
166
+ end
145
167
end
146
168
end
0 commit comments