From 4bc8b9ed0cfa271695a127d7ff071487e297ab36 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Fri, 6 Oct 2017 03:19:34 +0000 Subject: [PATCH 1/2] chore(package): update mocha to version 4.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f5740b1a..6b713be3 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "jquery": "3.2.1", "jquery-textcomplete": "1.8.4", "jquery-ui": "1.12.1", - "mocha": "3.5.3", + "mocha": "4.0.1", "mousetrap": "1.6.1", "npm-run-all": "4.1.1", "nyc": "11.2.1", From 44acc5cb004b63b166e7d423714b39b6f331179a Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Fri, 6 Oct 2017 12:53:08 +0300 Subject: [PATCH 2/2] Teardown sockets in tests --- src/plugins/auth/ldap.js | 1 + src/server.js | 2 ++ test/plugins/auth/ldap.js | 14 ++++++-------- test/server.js | 11 +++++++++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/plugins/auth/ldap.js b/src/plugins/auth/ldap.js index 059d23ce..54d8f472 100644 --- a/src/plugins/auth/ldap.js +++ b/src/plugins/auth/ldap.js @@ -91,6 +91,7 @@ function advancedLdapAuth(user, password, callback) { callback(false); }); res.on("end", function() { + ldapclient.unbind(); if (!found) { callback(false); } diff --git a/src/server.js b/src/server.js index de8c90e5..82982e66 100644 --- a/src/server.js +++ b/src/server.js @@ -177,6 +177,8 @@ module.exports = function() { process.on("SIGINT", exitGracefully); process.on("SIGTERM", exitGracefully); }); + + return server; }; function getClientIp(request) { diff --git a/test/plugins/auth/ldap.js b/test/plugins/auth/ldap.js index 0a4917fc..f2dcb180 100644 --- a/test/plugins/auth/ldap.js +++ b/test/plugins/auth/ldap.js @@ -109,29 +109,28 @@ function testLdapAuth() { } describe("LDAP authentication plugin", function() { - before(function(done) { + before((done) => { this.server = startLdapServer(done); }); - after(function(done) { + + after(() => { this.server.close(); - done(); }); - beforeEach(function(done) { + beforeEach(() => { Helper.config.public = false; Helper.config.ldap.enable = true; Helper.config.ldap.url = "ldap://localhost:" + String(serverPort); Helper.config.ldap.primaryKey = primaryKey; - done(); }); describe("LDAP authentication availability", function() { - it("checks that the configuration is correctly tied to isEnabled()", function(done) { + it("checks that the configuration is correctly tied to isEnabled()", function() { Helper.config.ldap.enable = true; expect(ldapAuth.isEnabled()).to.equal(true); + Helper.config.ldap.enable = false; expect(ldapAuth.isEnabled()).to.equal(false); - done(); }); }); @@ -145,4 +144,3 @@ describe("LDAP authentication plugin", function() { testLdapAuth(); }); }); - diff --git a/test/server.js b/test/server.js index ec2a31a8..bbdb8674 100644 --- a/test/server.js +++ b/test/server.js @@ -6,8 +6,15 @@ const request = require("request"); const io = require("socket.io-client"); describe("Server", () => { - const server = require("../src/server"); - server(); + let server; + + before(() => { + server = require("../src/server")(); + }); + + after((done) => { + server.close(done); + }); const webURL = `http://${Helper.config.host}:${Helper.config.port}/`;