Skip to content
This repository has been archived by the owner on Feb 11, 2020. It is now read-only.

Commit

Permalink
Added a test for the auth error.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Jun 10, 2014
1 parent c4b0b35 commit 5ddcc66
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ Client.prototype.handleConnect = function(packet, completeConnection) {
logger.info({ username: packet.username }, "authentication error");
client.connack({
returnCode: 4
});
});
client.stream.end();
return;
}
Expand Down
20 changes: 19 additions & 1 deletion test/abstract_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,25 @@ module.exports = function(moscaSettings, createConnection) {

client.on('connack', function(packet) {
expect(packet.returnCode).to.eql(5);
client.disconnect();
});
});
});

it("should support authentication (error)", function(done) {
instance.authenticate = function(client, username, password, callback) {
callback(new Error("auth error"));
};

buildClient(done, function(client) {

var options = buildOpts();
options.username = "matteo";
options.password = "collina";

client.connect(options);

client.on('connack', function(packet) {
expect(packet.returnCode).to.eql(4);
});
});
});
Expand Down

0 comments on commit 5ddcc66

Please sign in to comment.