@@ -35,7 +35,8 @@ describe('server', function () {
35
35
listen ( function ( port ) {
36
36
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
37
37
. query ( { transport : 'tobi' } ) // no tobi transport - outrageous
38
- . end ( function ( res ) {
38
+ . end ( function ( err , res ) {
39
+ expect ( err ) . to . be . an ( Error ) ;
39
40
expect ( res . status ) . to . be ( 400 ) ;
40
41
expect ( res . body . code ) . to . be ( 0 ) ;
41
42
expect ( res . body . message ) . to . be ( 'Transport unknown' ) ;
@@ -51,7 +52,8 @@ describe('server', function () {
51
52
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
52
53
. set ( 'Origin' , 'http://engine.io' )
53
54
. query ( { transport : 'constructor' } )
54
- . end ( function ( res ) {
55
+ . end ( function ( err , res ) {
56
+ expect ( err ) . to . be . an ( Error ) ;
55
57
expect ( res . status ) . to . be ( 400 ) ;
56
58
expect ( res . body . code ) . to . be ( 0 ) ;
57
59
expect ( res . body . message ) . to . be ( 'Transport unknown' ) ;
@@ -67,7 +69,8 @@ describe('server', function () {
67
69
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
68
70
. set ( 'Origin' , 'http://engine.io' )
69
71
. query ( { transport : 'polling' , sid : 'test' } )
70
- . end ( function ( res ) {
72
+ . end ( function ( err , res ) {
73
+ expect ( err ) . to . be . an ( Error ) ;
71
74
expect ( res . status ) . to . be ( 400 ) ;
72
75
expect ( res . body . code ) . to . be ( 1 ) ;
73
76
expect ( res . body . message ) . to . be ( 'Session ID unknown' ) ;
@@ -83,7 +86,8 @@ describe('server', function () {
83
86
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
84
87
. set ( 'Origin' , 'http://engine.io' )
85
88
. query ( { transport : 'polling' } )
86
- . end ( function ( res ) {
89
+ . end ( function ( err , res ) {
90
+ expect ( err ) . to . be . an ( Error ) ;
87
91
expect ( res . status ) . to . be ( 403 ) ;
88
92
expect ( res . body . code ) . to . be ( 4 ) ;
89
93
expect ( res . body . message ) . to . be ( 'Thou shall not pass' ) ;
@@ -109,7 +113,8 @@ describe('server', function () {
109
113
listen ( function ( port ) {
110
114
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
111
115
. query ( { transport : 'polling' , b64 : 1 } )
112
- . end ( function ( res ) {
116
+ . end ( function ( err , res ) {
117
+ expect ( err ) . to . be ( null ) ;
113
118
// hack-obtain sid
114
119
var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
115
120
expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid + '; Path=/; HttpOnly' ) ;
@@ -122,7 +127,8 @@ describe('server', function () {
122
127
listen ( { cookie : 'woot' } , function ( port ) {
123
128
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
124
129
. query ( { transport : 'polling' , b64 : 1 } )
125
- . end ( function ( res ) {
130
+ . end ( function ( err , res ) {
131
+ expect ( err ) . to . be ( null ) ;
126
132
var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
127
133
expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'woot=' + sid + '; Path=/; HttpOnly' ) ;
128
134
done ( ) ;
@@ -134,7 +140,8 @@ describe('server', function () {
134
140
listen ( { cookiePath : '/custom' } , function ( port ) {
135
141
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
136
142
. query ( { transport : 'polling' , b64 : 1 } )
137
- . end ( function ( res ) {
143
+ . end ( function ( err , res ) {
144
+ expect ( err ) . to . be ( null ) ;
138
145
var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
139
146
expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid + '; Path=/custom; HttpOnly' ) ;
140
147
done ( ) ;
@@ -146,7 +153,8 @@ describe('server', function () {
146
153
listen ( { cookiePath : false } , function ( port ) {
147
154
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
148
155
. query ( { transport : 'polling' , b64 : 1 } )
149
- . end ( function ( res ) {
156
+ . end ( function ( err , res ) {
157
+ expect ( err ) . to . be ( null ) ;
150
158
var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
151
159
expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid ) ;
152
160
done ( ) ;
@@ -158,7 +166,8 @@ describe('server', function () {
158
166
listen ( { cookieHttpOnly : true } , function ( port ) {
159
167
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
160
168
. query ( { transport : 'polling' , b64 : 1 } )
161
- . end ( function ( res ) {
169
+ . end ( function ( err , res ) {
170
+ expect ( err ) . to . be ( null ) ;
162
171
var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
163
172
expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid + '; Path=/; HttpOnly' ) ;
164
173
done ( ) ;
@@ -170,7 +179,8 @@ describe('server', function () {
170
179
listen ( { cookieHttpOnly : true , cookiePath : false } , function ( port ) {
171
180
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
172
181
. query ( { transport : 'polling' , b64 : 1 } )
173
- . end ( function ( res ) {
182
+ . end ( function ( err , res ) {
183
+ expect ( err ) . to . be ( null ) ;
174
184
var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
175
185
expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid ) ;
176
186
done ( ) ;
@@ -182,7 +192,8 @@ describe('server', function () {
182
192
listen ( { cookieHttpOnly : false } , function ( port ) {
183
193
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
184
194
. query ( { transport : 'polling' , b64 : 1 } )
185
- . end ( function ( res ) {
195
+ . end ( function ( err , res ) {
196
+ expect ( err ) . to . be ( null ) ;
186
197
var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
187
198
expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid + '; Path=/' ) ;
188
199
done ( ) ;
@@ -194,7 +205,8 @@ describe('server', function () {
194
205
listen ( { cookieHttpOnly : 'no' } , function ( port ) {
195
206
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
196
207
. query ( { transport : 'polling' , b64 : 1 } )
197
- . end ( function ( res ) {
208
+ . end ( function ( err , res ) {
209
+ expect ( err ) . to . be ( null ) ;
198
210
var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
199
211
expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid + '; Path=/; HttpOnly' ) ;
200
212
done ( ) ;
@@ -206,7 +218,8 @@ describe('server', function () {
206
218
listen ( { cookie : false } , function ( port ) {
207
219
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
208
220
. query ( { transport : 'polling' } )
209
- . end ( function ( res ) {
221
+ . end ( function ( err , res ) {
222
+ expect ( err ) . to . be ( null ) ;
210
223
expect ( res . headers [ 'set-cookie' ] ) . to . be ( undefined ) ;
211
224
done ( ) ;
212
225
} ) ;
@@ -356,7 +369,7 @@ describe('server', function () {
356
369
. set ( { connection : 'close' } )
357
370
. query ( { transport : 'websocket' , sid : socket . id } )
358
371
. end ( function ( err , res ) {
359
- expect ( err ) . to . be ( null ) ;
372
+ expect ( err ) . to . be . an ( Error ) ;
360
373
expect ( res . status ) . to . be ( 400 ) ;
361
374
expect ( res . body . code ) . to . be ( 3 ) ;
362
375
socket . send ( 'echo' ) ;
@@ -397,7 +410,8 @@ describe('server', function () {
397
410
request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
398
411
. set ( 'Origin' , 'http://engine.io' )
399
412
. query ( { transport : 'websocket' } )
400
- . end ( function ( res ) {
413
+ . end ( function ( err , res ) {
414
+ expect ( err ) . to . be . an ( Error ) ;
401
415
expect ( res . status ) . to . be ( 400 ) ;
402
416
expect ( res . body . code ) . to . be ( 3 ) ;
403
417
expect ( res . body . message ) . to . be ( 'Bad request' ) ;
@@ -2579,7 +2593,8 @@ describe('server', function () {
2579
2593
request . options ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
2580
2594
. set ( 'Origin' , 'http://engine.io' )
2581
2595
. query ( { transport : 'polling' } )
2582
- . end ( function ( res ) {
2596
+ . end ( function ( err , res ) {
2597
+ expect ( err ) . to . be . an ( Error ) ;
2583
2598
expect ( res . status ) . to . be ( 400 ) ;
2584
2599
expect ( res . body . code ) . to . be ( 2 ) ;
2585
2600
expect ( res . body . message ) . to . be ( 'Bad handshake method' ) ;
@@ -2595,7 +2610,8 @@ describe('server', function () {
2595
2610
request . options ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
2596
2611
. set ( 'Origin' , 'http://engine.io' )
2597
2612
. query ( { transport : 'polling' } )
2598
- . end ( function ( res ) {
2613
+ . end ( function ( err , res ) {
2614
+ expect ( err ) . to . be . an ( Error ) ;
2599
2615
expect ( res . status ) . to . be ( 501 ) ;
2600
2616
expect ( res . body . code ) . to . be ( undefined ) ;
2601
2617
done ( ) ;
@@ -2621,7 +2637,8 @@ describe('server', function () {
2621
2637
request . options ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
2622
2638
. set ( 'Origin' , 'http://engine.io' )
2623
2639
. query ( { transport : 'polling' } )
2624
- . end ( function ( res ) {
2640
+ . end ( function ( err , res ) {
2641
+ expect ( err ) . to . be ( null ) ;
2625
2642
expect ( res . status ) . to . be ( 200 ) ;
2626
2643
expect ( res . body ) . to . be . empty ( ) ;
2627
2644
expect ( res . header [ 'access-control-allow-credentials' ] ) . to . be ( 'true' ) ;
0 commit comments