@@ -73,7 +73,7 @@ describe('socket.io', function(){
73
73
it ( 'should be able to set origins to engine.io' , function ( ) {
74
74
var srv = io ( http ( ) ) ;
75
75
srv . set ( 'origins' , 'http://hostname.com:*' ) ;
76
- expect ( srv . origins ( ) ) . to . eql ( [ 'http://hostname.com:*' ] ) ;
76
+ expect ( srv . origins ( ) ) . to . be ( 'http://hostname.com:*' ) ;
77
77
} ) ;
78
78
79
79
it ( 'should be able to set authorization and send error packet' , function ( done ) {
@@ -262,6 +262,17 @@ describe('socket.io', function(){
262
262
} ) ;
263
263
} ) ;
264
264
265
+ it ( 'should allow request when origin defined an the same is specified' , function ( done ) {
266
+ var sockets = io ( { origins : 'http://foo.example:*' } ) . listen ( '54015' ) ;
267
+ request . get ( 'http://localhost:54015/socket.io/default/' )
268
+ . set ( 'origin' , 'http://foo.example' )
269
+ . query ( { transport : 'polling' } )
270
+ . end ( function ( err , res ) {
271
+ expect ( res . status ) . to . be ( 200 ) ;
272
+ done ( ) ;
273
+ } ) ;
274
+ } ) ;
275
+
265
276
it ( 'should allow request when origin defined as function and same is supplied' , function ( done ) {
266
277
var sockets = io ( { origins : function ( origin , callback ) {
267
278
if ( origin == 'http://foo.example' ) {
@@ -296,7 +307,7 @@ describe('socket.io', function(){
296
307
297
308
it ( 'should allow request when origin defined as function and no origin is supplied' , function ( done ) {
298
309
var sockets = io ( { origins : function ( origin , callback ) {
299
- if ( origin === undefined ) {
310
+ if ( origin == '*' ) {
300
311
return callback ( null , true ) ;
301
312
}
302
313
return callback ( null , false ) ;
@@ -309,6 +320,17 @@ describe('socket.io', function(){
309
320
} ) ;
310
321
} ) ;
311
322
323
+ it ( 'should default to port 443 when protocol is https' , function ( done ) {
324
+ var sockets = io ( { origins : 'https://foo.example:443' } ) . listen ( '54036' ) ;
325
+ request . get ( 'http://localhost:54036/socket.io/default/' )
326
+ . set ( 'origin' , 'https://foo.example' )
327
+ . query ( { transport : 'polling' } )
328
+ . end ( function ( err , res ) {
329
+ expect ( res . status ) . to . be ( 200 ) ;
330
+ done ( ) ;
331
+ } ) ;
332
+ } ) ;
333
+
312
334
it ( 'should allow request if custom function in opts.allowRequest returns true' , function ( done ) {
313
335
var sockets = io ( http ( ) . listen ( 54022 ) , { allowRequest : function ( req , callback ) {
314
336
return callback ( null , true ) ;
@@ -345,17 +367,6 @@ describe('socket.io', function(){
345
367
done ( ) ;
346
368
} ) ;
347
369
} ) ;
348
-
349
- it ( 'should disallow any origin by default' , ( done ) => {
350
- io ( ) . listen ( '54025' ) ;
351
- request . get ( 'http://localhost:54025/socket.io/default/' )
352
- . set ( 'origin' , 'https://foo.example' )
353
- . query ( { transport : 'polling' } )
354
- . end ( ( err , res ) => {
355
- expect ( res . status ) . to . be ( 403 ) ;
356
- done ( ) ;
357
- } ) ;
358
- } ) ;
359
370
} ) ;
360
371
361
372
describe ( 'close' , function ( ) {
0 commit comments