Created
January 10, 2015 02:19
-
-
Save alxyang/cbc84a57d24744b67a32 to your computer and use it in GitHub Desktop.
Authorization fail test socketio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http').Server; | |
var io = require('..'); | |
// ... | |
it('should be able to set authorization and send error packet', function(done) { | |
var httpSrv = http(); | |
var srv = io(httpSrv); | |
// srv.set('authorization', function(o, f) { f(null, false); }); | |
// srv.set('authorization', function(handshake, f){ | |
// setTimeout(function(){ | |
// f(null, false); | |
// }, 100); | |
// }); | |
// srv.use(function(socket, next){ | |
// setTimeout(function(){ | |
// next(new Error('Not authorized')); | |
// }, 100); | |
// }); | |
srv.use(function(socket, next){ | |
next(new Error('Not authorized')); | |
}); | |
var socket = client(httpSrv); | |
socket.on('connect', function(){ | |
expect().fail(); | |
}); | |
socket.on('error', function(err) { | |
expect(err).to.be('Not authorized'); | |
done(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment