Teardown sockets in tests

This commit is contained in:
Pavel Djundik 2017-10-06 12:53:08 +03:00
parent 4bc8b9ed0c
commit 44acc5cb00
4 changed files with 18 additions and 10 deletions

View file

@ -91,6 +91,7 @@ function advancedLdapAuth(user, password, callback) {
callback(false);
});
res.on("end", function() {
ldapclient.unbind();
if (!found) {
callback(false);
}

View file

@ -177,6 +177,8 @@ module.exports = function() {
process.on("SIGINT", exitGracefully);
process.on("SIGTERM", exitGracefully);
});
return server;
};
function getClientIp(request) {

View file

@ -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();
});
});

View file

@ -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}/`;