fixed all broken tests with socket.io 1.0, close #10

This commit is contained in:
José F. Romaniello
2014-06-05 15:45:41 -03:00
parent 130357ff80
commit 3484a429ed
5 changed files with 36 additions and 25 deletions

View File

@ -11,13 +11,12 @@ describe('authorizer', function () {
describe('when the user is not logged in', function () {
it('should emit error with unauthorized handshake', function (done){
var socket = io.connect('http://localhost:9000', {
'query': 'token=Booooooooooooooooooooo',
'force new connection': true
var socket = io.connect('http://localhost:9000?token=boooooo', {
'forceNew': true
});
socket.on('error', function(err){
err.should.eql('handshake unauthorized');
err.should.eql("Invalid token: no header in signature 'boooooo'");
done();
});
});
@ -39,7 +38,7 @@ describe('authorizer', function () {
it('should do the handshake and connect', function (done){
var socket = io.connect('http://localhost:9000', {
'force new connection':true,
'forceNew':true,
'query': 'token=' + this.token
});
socket.on('connect', function(){

View File

@ -24,7 +24,7 @@ describe('authorizer without querystring', function () {
it('should not respond echo', function (done){
var socket = io.connect('http://localhost:9000', {
'force new connection':true,
'forceNew':true,
});
socket.on('echo-response', function () {
@ -51,7 +51,7 @@ describe('authorizer without querystring', function () {
it('should do the handshake and connect', function (done){
var socket = io.connect('http://localhost:9000', {
'force new connection':true,
'forceNew':true,
});
var token = this.token;
socket.on('connect', function(){

View File

@ -48,12 +48,11 @@ exports.start = function (options, callback) {
var sio = socketIo.listen(server);
sio.configure(function(){
if (options.handshake) {
this.set('authorization', socketio_jwt.authorize(options));
}
this.set('log level', 0);
});
if (options.handshake) {
// this.set('authorization', socketio_jwt.authorize(options));
sio.use(socketio_jwt.authorize(options));
}
sio.set('log level', 0);
if (options.handshake) {
sio.sockets.on('echo', function (m) {