2017-03-16 05:07:57 +07:00
|
|
|
|
|
|
|
|
|
var sinon = require('sinon');
|
|
|
|
|
var server = require('../../src/lib/server');
|
|
|
|
|
var assert = require('assert');
|
|
|
|
|
|
|
|
|
|
describe('test server configuration', function() {
|
2017-03-16 07:25:55 +07:00
|
|
|
|
var deps;
|
|
|
|
|
var config;
|
|
|
|
|
|
|
|
|
|
before(function() {
|
|
|
|
|
config = {};
|
2017-03-16 05:07:57 +07:00
|
|
|
|
config.notifier = {
|
|
|
|
|
gmail: {
|
|
|
|
|
user: 'user@example.com',
|
|
|
|
|
pass: 'password'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
transporter = {};
|
|
|
|
|
transporter.sendMail = sinon.stub().yields();
|
|
|
|
|
|
|
|
|
|
var nodemailer = {};
|
|
|
|
|
nodemailer.createTransport = sinon.spy(function() {
|
|
|
|
|
return transporter;
|
|
|
|
|
});
|
|
|
|
|
|
2017-03-16 07:25:55 +07:00
|
|
|
|
deps = {};
|
2017-03-16 05:07:57 +07:00
|
|
|
|
deps.nedb = require('nedb');
|
2017-03-25 21:17:21 +07:00
|
|
|
|
deps.winston = sinon.spy();
|
2017-03-16 05:07:57 +07:00
|
|
|
|
deps.nodemailer = nodemailer;
|
2017-03-25 21:17:21 +07:00
|
|
|
|
deps.ldapjs = {};
|
|
|
|
|
deps.ldapjs.createClient = sinon.spy(function() {
|
|
|
|
|
return { on: sinon.spy() };
|
|
|
|
|
});
|
2017-03-16 05:07:57 +07:00
|
|
|
|
deps.session = sinon.spy(function() {
|
|
|
|
|
return function(req, res, next) { next(); };
|
|
|
|
|
});
|
2017-03-16 07:25:55 +07:00
|
|
|
|
});
|
2017-03-16 05:07:57 +07:00
|
|
|
|
|
2017-03-16 07:25:55 +07:00
|
|
|
|
|
|
|
|
|
it('should set cookie scope to domain set in the config', function() {
|
2017-03-22 02:57:03 +07:00
|
|
|
|
config.session = {};
|
|
|
|
|
config.session.domain = 'example.com';
|
2017-05-13 23:12:26 +07:00
|
|
|
|
config.session.secret = 'secret';
|
2017-03-25 21:17:21 +07:00
|
|
|
|
config.ldap = {};
|
|
|
|
|
config.ldap.url = 'http://ldap';
|
|
|
|
|
server.run(config, deps);
|
2017-03-16 05:07:57 +07:00
|
|
|
|
|
|
|
|
|
assert(deps.session.calledOnce);
|
|
|
|
|
assert.equal(deps.session.getCall(0).args[0].cookie.domain, 'example.com');
|
|
|
|
|
});
|
|
|
|
|
});
|