authelia/server/test/ServerConfiguration.test.ts
Clement Michaud 7b68a543bf Strengthen password in LDAP using SHA512 crypt algorithm
Uses the crypt() function to do password encryption. This function handles
several schemes such as: MD5, Blowfish, SHA1, SHA2.
SHA-512 is used in Authelia for best security.
The algorithm is fully described in
https://www.akkadia.org/drepper/SHA-crypt.txt

The 'crypt3' npm package has been added as a dependency to use the crypt()
function. The package needs to be compiled in order to call the c function,
that's why python, make and C++ compiler are installed temporarily in the
Docker image.
2017-10-31 07:27:36 +01:00

81 lines
1.9 KiB
TypeScript

import Assert = require("assert");
import Sinon = require("sinon");
import nedb = require("nedb");
import express = require("express");
import winston = require("winston");
import speakeasy = require("speakeasy");
import u2f = require("u2f");
import session = require("express-session");
import { AppConfiguration, UserConfiguration } from "../src/lib/configuration/Configuration";
import { GlobalDependencies } from "../types/Dependencies";
import Server from "../src/lib/Server";
describe("test server configuration", function () {
let deps: GlobalDependencies;
let sessionMock: Sinon.SinonSpy;
before(function () {
sessionMock = Sinon.spy(session);
deps = {
speakeasy: speakeasy,
u2f: u2f,
nedb: nedb,
winston: winston,
ldapjs: {
createClient: Sinon.spy(function () {
return {
on: Sinon.spy(),
bind: Sinon.spy(),
};
})
},
session: sessionMock as any,
ConnectRedis: Sinon.spy()
};
});
it("should set cookie scope to domain set in the config", function () {
const config: UserConfiguration = {
session: {
domain: "example.com",
secret: "secret"
},
ldap: {
url: "http://ldap",
user: "user",
password: "password",
base_dn: "dc=example,dc=com"
},
notifier: {
email: {
username: "user@example.com",
password: "password",
sender: "test@authelia.com",
service: "gmail"
}
},
regulation: {
max_retries: 3,
ban_time: 5 * 60,
find_time: 5 * 60
},
storage: {
local: {
in_memory: true
}
}
};
const server = new Server(deps);
server.start(config, deps)
.then(function () {
Assert(sessionMock.calledOnce);
Assert.equal(sessionMock.getCall(0).args[0].cookie.domain, "example.com");
});
});
});