@@ -36,7 +36,8 @@ describe('server', function () {
36
36
listen ( function ( port ) {
37
37
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
38
38
. query ( { transport : 'tobi' } ) // no tobi transport - outrageous
39
- . end ( function ( res ) {
39
+ . end ( function ( err , res ) {
40
+ expect ( err ) . to . be . an ( Error ) ;
40
41
expect ( res . status ) . to . be ( 400 ) ;
41
42
expect ( res . body . code ) . to . be ( 0 ) ;
42
43
expect ( res . body . message ) . to . be ( 'Transport unknown' ) ;
@@ -52,7 +53,8 @@ describe('server', function () {
52
53
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
53
54
. set ( 'Origin' , 'http://engine.io' )
54
55
. query ( { transport : 'constructor' } )
55
- . end ( function ( res ) {
56
+ . end ( function ( err , res ) {
57
+ expect ( err ) . to . be . an ( Error ) ;
56
58
expect ( res . status ) . to . be ( 400 ) ;
57
59
expect ( res . body . code ) . to . be ( 0 ) ;
58
60
expect ( res . body . message ) . to . be ( 'Transport unknown' ) ;
@@ -68,7 +70,8 @@ describe('server', function () {
68
70
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
69
71
. set ( 'Origin' , 'http://engine.io' )
70
72
. query ( { transport : 'polling' , sid : 'test' } )
71
- . end ( function ( res ) {
73
+ . end ( function ( err , res ) {
74
+ expect ( err ) . to . be . an ( Error ) ;
72
75
expect ( res . status ) . to . be ( 400 ) ;
73
76
expect ( res . body . code ) . to . be ( 1 ) ;
74
77
expect ( res . body . message ) . to . be ( 'Session ID unknown' ) ;
@@ -84,7 +87,8 @@ describe('server', function () {
84
87
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
85
88
. set ( 'Origin' , 'http://engine.io' )
86
89
. query ( { transport : 'polling' } )
87
- . end ( function ( res ) {
90
+ . end ( function ( err , res ) {
91
+ expect ( err ) . to . be . an ( Error ) ;
88
92
expect ( res . status ) . to . be ( 403 ) ;
89
93
expect ( res . body . code ) . to . be ( 4 ) ;
90
94
expect ( res . body . message ) . to . be ( 'Thou shall not pass' ) ;
@@ -110,7 +114,8 @@ describe('server', function () {
110
114
listen ( function ( port ) {
111
115
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
112
116
. query ( { transport : 'polling' , b64 : 1 } )
113
- . end ( function ( res ) {
117
+ . end ( function ( err , res ) {
118
+ expect ( err ) . to . be ( null ) ;
114
119
// hack-obtain sid
115
120
var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
116
121
expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid + '; Path=/; HttpOnly' ) ;
@@ -123,7 +128,8 @@ describe('server', function () {
123
128
listen ( { cookie : 'woot' } , function ( port ) {
124
129
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
125
130
. query ( { transport : 'polling' , b64 : 1 } )
126
- . end ( function ( res ) {
131
+ . end ( function ( err , res ) {
132
+ expect ( err ) . to . be ( null ) ;
127
133
var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
128
134
expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'woot=' + sid + '; Path=/; HttpOnly' ) ;
129
135
done ( ) ;
@@ -135,7 +141,8 @@ describe('server', function () {
135
141
listen ( { cookiePath : '/custom' } , function ( port ) {
136
142
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
137
143
. query ( { transport : 'polling' , b64 : 1 } )
138
- . end ( function ( res ) {
144
+ . end ( function ( err , res ) {
145
+ expect ( err ) . to . be ( null ) ;
139
146
var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
140
147
expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid + '; Path=/custom; HttpOnly' ) ;
141
148
done ( ) ;
@@ -147,7 +154,8 @@ describe('server', function () {
147
154
listen ( { cookiePath : false } , function ( port ) {
148
155
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
149
156
. query ( { transport : 'polling' , b64 : 1 } )
150
- . end ( function ( res ) {
157
+ . end ( function ( err , res ) {
158
+ expect ( err ) . to . be ( null ) ;
151
159
var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
152
160
expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid ) ;
153
161
done ( ) ;
@@ -159,7 +167,8 @@ describe('server', function () {
159
167
listen ( { cookieHttpOnly : true } , function ( port ) {
160
168
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
161
169
. query ( { transport : 'polling' , b64 : 1 } )
162
- . end ( function ( res ) {
170
+ . end ( function ( err , res ) {
171
+ expect ( err ) . to . be ( null ) ;
163
172
var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
164
173
expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid + '; Path=/; HttpOnly' ) ;
165
174
done ( ) ;
@@ -171,7 +180,8 @@ describe('server', function () {
171
180
listen ( { cookieHttpOnly : true , cookiePath : false } , function ( port ) {
172
181
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
173
182
. query ( { transport : 'polling' , b64 : 1 } )
174
- . end ( function ( res ) {
183
+ . end ( function ( err , res ) {
184
+ expect ( err ) . to . be ( null ) ;
175
185
var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
176
186
expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid ) ;
177
187
done ( ) ;
@@ -183,7 +193,8 @@ describe('server', function () {
183
193
listen ( { cookieHttpOnly : false } , function ( port ) {
184
194
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
185
195
. query ( { transport : 'polling' , b64 : 1 } )
186
- . end ( function ( res ) {
196
+ . end ( function ( err , res ) {
197
+ expect ( err ) . to . be ( null ) ;
187
198
var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
188
199
expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid + '; Path=/' ) ;
189
200
done ( ) ;
@@ -195,7 +206,8 @@ describe('server', function () {
195
206
listen ( { cookieHttpOnly : 'no' } , function ( port ) {
196
207
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
197
208
. query ( { transport : 'polling' , b64 : 1 } )
198
- . end ( function ( res ) {
209
+ . end ( function ( err , res ) {
210
+ expect ( err ) . to . be ( null ) ;
199
211
var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
200
212
expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid + '; Path=/; HttpOnly' ) ;
201
213
done ( ) ;
@@ -207,7 +219,8 @@ describe('server', function () {
207
219
listen ( { cookie : false } , function ( port ) {
208
220
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
209
221
. query ( { transport : 'polling' } )
210
- . end ( function ( res ) {
222
+ . end ( function ( err , res ) {
223
+ expect ( err ) . to . be ( null ) ;
211
224
expect ( res . headers [ 'set-cookie' ] ) . to . be ( undefined ) ;
212
225
done ( ) ;
213
226
} ) ;
@@ -369,7 +382,7 @@ describe('server', function () {
369
382
. set ( { connection : 'close' } )
370
383
. query ( { transport : 'websocket' , sid : socket . id } )
371
384
. end ( function ( err , res ) {
372
- expect ( err ) . to . be ( null ) ;
385
+ expect ( err ) . to . be . an ( Error ) ;
373
386
expect ( res . status ) . to . be ( 400 ) ;
374
387
expect ( res . body . code ) . to . be ( 3 ) ;
375
388
socket . send ( 'echo' ) ;
@@ -410,7 +423,8 @@ describe('server', function () {
410
423
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
411
424
. set ( 'Origin' , 'http://engine.io' )
412
425
. query ( { transport : 'websocket' } )
413
- . end ( function ( res ) {
426
+ . end ( function ( err , res ) {
427
+ expect ( err ) . to . be . an ( Error ) ;
414
428
expect ( res . status ) . to . be ( 400 ) ;
415
429
expect ( res . body . code ) . to . be ( 3 ) ;
416
430
expect ( res . body . message ) . to . be ( 'Bad request' ) ;
@@ -2592,7 +2606,8 @@ describe('server', function () {
2592
2606
request . options ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
2593
2607
. set ( 'Origin' , 'http://engine.io' )
2594
2608
. query ( { transport : 'polling' } )
2595
- . end ( function ( res ) {
2609
+ . end ( function ( err , res ) {
2610
+ expect ( err ) . to . be . an ( Error ) ;
2596
2611
expect ( res . status ) . to . be ( 400 ) ;
2597
2612
expect ( res . body . code ) . to . be ( 2 ) ;
2598
2613
expect ( res . body . message ) . to . be ( 'Bad handshake method' ) ;
@@ -2608,7 +2623,8 @@ describe('server', function () {
2608
2623
request . options ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
2609
2624
. set ( 'Origin' , 'http://engine.io' )
2610
2625
. query ( { transport : 'polling' } )
2611
- . end ( function ( res ) {
2626
+ . end ( function ( err , res ) {
2627
+ expect ( err ) . to . be . an ( Error ) ;
2612
2628
expect ( res . status ) . to . be ( 501 ) ;
2613
2629
expect ( res . body . code ) . to . be ( undefined ) ;
2614
2630
done ( ) ;
@@ -2634,7 +2650,8 @@ describe('server', function () {
2634
2650
request . options ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
2635
2651
. set ( 'Origin' , 'http://engine.io' )
2636
2652
. query ( { transport : 'polling' } )
2637
- . end ( function ( res ) {
2653
+ . end ( function ( err , res ) {
2654
+ expect ( err ) . to . be ( null ) ;
2638
2655
expect ( res . status ) . to . be ( 200 ) ;
2639
2656
expect ( res . body ) . to . be . empty ( ) ;
2640
2657
expect ( res . header [ 'access-control-allow-credentials' ] ) . to . be ( 'true' ) ;
0 commit comments