diff --git a/test/command_pass.js b/test/command_pass.js index 653a25a..0bbdb57 100644 --- a/test/command_pass.js +++ b/test/command_pass.js @@ -29,6 +29,29 @@ describe("PASS OK", function () { user = server.getUserlist()["some_nick"] assert.equal(user["registered"], true) done() + }) + + it("should end connection on wrong password", function (done) { + const server = IRCServer.create({ + password: "itsJustATest" + }) + let mockedSock = new EventEmitter() + + mockedSock.address = function() { + return { port: 12346, family: 'IPv4', address: '127.0.0.1' } + } + + mockedSock.write = function (data) { + return + } + + mockedSock.destroy = function () { + // connection has to be destroyed + done("") + } + + server.emit("connection", mockedSock) + mockedSock.emit('data', Buffer.from("PASS wrongpassword\r\n", "ascii")) }) })