@@ -73,7 +73,7 @@ describe('socket.io', function(){
7373 it ( 'should be able to set origins to engine.io' , function ( ) {
7474 var srv = io ( http ( ) ) ;
7575 srv . set ( 'origins' , 'http://hostname.com:*' ) ;
76- expect ( srv . origins ( ) ) . to . eql ( [ 'http://hostname.com:*' ] ) ;
76+ expect ( srv . origins ( ) ) . to . be ( 'http://hostname.com:*' ) ;
7777 } ) ;
7878
7979 it ( 'should be able to set authorization and send error packet' , function ( done ) {
@@ -262,6 +262,17 @@ describe('socket.io', function(){
262262 } ) ;
263263 } ) ;
264264
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+
265276 it ( 'should allow request when origin defined as function and same is supplied' , function ( done ) {
266277 var sockets = io ( { origins : function ( origin , callback ) {
267278 if ( origin == 'http://foo.example' ) {
@@ -296,7 +307,7 @@ describe('socket.io', function(){
296307
297308 it ( 'should allow request when origin defined as function and no origin is supplied' , function ( done ) {
298309 var sockets = io ( { origins : function ( origin , callback ) {
299- if ( origin === undefined ) {
310+ if ( origin == '*' ) {
300311 return callback ( null , true ) ;
301312 }
302313 return callback ( null , false ) ;
@@ -309,6 +320,17 @@ describe('socket.io', function(){
309320 } ) ;
310321 } ) ;
311322
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+
312334 it ( 'should allow request if custom function in opts.allowRequest returns true' , function ( done ) {
313335 var sockets = io ( http ( ) . listen ( 54022 ) , { allowRequest : function ( req , callback ) {
314336 return callback ( null , true ) ;
@@ -345,17 +367,6 @@ describe('socket.io', function(){
345367 done ( ) ;
346368 } ) ;
347369 } ) ;
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- } ) ;
359370 } ) ;
360371
361372 describe ( 'close' , function ( ) {
0 commit comments