diff --git a/box.js b/box.js index 05e6762eb..8ff306863 100755 --- a/box.js +++ b/box.js @@ -30,8 +30,6 @@ console.log(' Version: ', constants.VERSION); console.log(' Admin Origin: ', config.adminOrigin()); console.log(' Appstore API server origin: ', config.apiServerOrigin()); console.log(' Appstore Web server origin: ', config.webServerOrigin()); -console.log(' LDAP Server Port: ', config.get('ldapPort')); -console.log(' Docker Proxy Port: ', config.get('dockerProxyPort')); console.log(); console.log('=========================================='); console.log(); diff --git a/src/addons.js b/src/addons.js index cd546cd0f..cf75be92c 100644 --- a/src/addons.js +++ b/src/addons.js @@ -38,6 +38,7 @@ var accesscontrol = require('./accesscontrol.js'), async = require('async'), clients = require('./clients.js'), config = require('./config.js'), + constants = require('./constants.js'), ClientsError = clients.ClientsError, crypto = require('crypto'), DatabaseError = require('./databaseerror.js'), @@ -685,7 +686,7 @@ function getEnvironment(app, callback) { appdb.getAddonConfigByAppId(app.id, function (error, result) { if (error) return callback(error); - if (app.manifest.addons['docker']) result.push({ name: 'DOCKER_HOST', value: `tcp://172.18.0.1:${config.get('dockerProxyPort')}` }); + if (app.manifest.addons['docker']) result.push({ name: 'DOCKER_HOST', value: `tcp://172.18.0.1:${constants.DOCKER_PROXY_PORT}` }); return callback(null, result.map(function (e) { return e.name + '=' + e.value; })); }); @@ -876,8 +877,8 @@ function setupLdap(app, options, callback) { var env = [ { name: `${envPrefix}LDAP_SERVER`, value: '172.18.0.1' }, - { name: `${envPrefix}LDAP_PORT`, value: '' + config.get('ldapPort') }, - { name: `${envPrefix}LDAP_URL`, value: 'ldap://172.18.0.1:' + config.get('ldapPort') }, + { name: `${envPrefix}LDAP_PORT`, value: '' + constants.LDAP_PORT }, + { name: `${envPrefix}LDAP_URL`, value: 'ldap://172.18.0.1:' + constants.LDAP_PORT }, { name: `${envPrefix}LDAP_USERS_BASE_DN`, value: 'ou=users,dc=cloudron' }, { name: `${envPrefix}LDAP_GROUPS_BASE_DN`, value: 'ou=groups,dc=cloudron' }, { name: `${envPrefix}LDAP_BIND_DN`, value: 'cn='+ app.id + ',ou=apps,dc=cloudron' }, diff --git a/src/apps.js b/src/apps.js index 361ed45c7..578fbf887 100644 --- a/src/apps.js +++ b/src/apps.js @@ -152,7 +152,7 @@ function validatePortBindings(portBindings, manifest) { config.get('port'), /* app server (lo) */ constants.SYSADMIN_PORT, /* sysadmin app server (lo) */ constants.INTERNAL_SMTP_PORT, /* internal smtp port (lo) */ - config.get('ldapPort'), /* ldap server (lo) */ + constants.LDAP_PORT, 3306, /* mysql (lo) */ 4190, /* managesieve */ 8000, /* ESXi monitoring */ diff --git a/src/config.js b/src/config.js index cd3731efd..bf9ef4583 100644 --- a/src/config.js +++ b/src/config.js @@ -85,8 +85,6 @@ function initConfig() { data.apiServerOrigin = null; data.webServerOrigin = null; data.provider = 'generic'; - data.ldapPort = 3002; - data.dockerProxyPort = 3003; // keep in sync with start.sh data.database = { diff --git a/src/constants.js b/src/constants.js index 6364bfbdf..c5c53e69a 100644 --- a/src/constants.js +++ b/src/constants.js @@ -23,6 +23,8 @@ exports = module.exports = { INTERNAL_SMTP_PORT: 2525, // this value comes from the mail container SYSADMIN_PORT: 3001, + LDAP_PORT: 3002, + DOCKER_PROXY_PORT: 3003, NGINX_DEFAULT_CONFIG_FILE_NAME: 'default.conf', diff --git a/src/dockerproxy.js b/src/dockerproxy.js index 1019d2235..d70040a31 100644 --- a/src/dockerproxy.js +++ b/src/dockerproxy.js @@ -9,6 +9,7 @@ var apps = require('./apps.js'), AppsError = apps.AppsError, assert = require('assert'), config = require('./config.js'), + constants = require('./constants.js'), express = require('express'), debug = require('debug')('box:dockerproxy'), http = require('http'), @@ -135,9 +136,9 @@ function start(callback) { .use(middleware.lastMile()); gHttpServer = http.createServer(proxyServer); - gHttpServer.listen(config.get('dockerProxyPort'), '0.0.0.0', callback); + gHttpServer.listen(constants.DOCKER_PROXY_PORT, '0.0.0.0', callback); - debug(`startDockerProxy: started proxy on port ${config.get('dockerProxyPort')}`); + debug(`startDockerProxy: started proxy on port ${constants.DOCKER_PROXY_PORT}`); gHttpServer.on('upgrade', function (req, client, head) { // Create a new tcp connection to the TCP server @@ -150,7 +151,7 @@ function start(callback) { if (req.headers['content-type'] === 'application/json') { // TODO we have to parse the immediate upgrade request body, but I don't know how let plainBody = '{"Detach":false,"Tty":false}\r\n'; - upgradeMessage += `Content-Type: application/json\r\n`; + upgradeMessage += 'Content-Type: application/json\r\n'; upgradeMessage += `Content-Length: ${Buffer.byteLength(plainBody)}\r\n`; upgradeMessage += '\r\n'; upgradeMessage += plainBody; diff --git a/src/ldap.js b/src/ldap.js index 027f52cbd..0d4107005 100644 --- a/src/ldap.js +++ b/src/ldap.js @@ -9,7 +9,7 @@ var assert = require('assert'), appdb = require('./appdb.js'), apps = require('./apps.js'), async = require('async'), - config = require('./config.js'), + constants = require('./constants.js'), DatabaseError = require('./databaseerror.js'), debug = require('debug')('box:ldap'), eventlog = require('./eventlog.js'), @@ -640,7 +640,7 @@ function start(callback) { res.end(); }); - gServer.listen(config.get('ldapPort'), '0.0.0.0', callback); + gServer.listen(constants.LDAP_PORT, '0.0.0.0', callback); } function stop(callback) { diff --git a/src/test/dockerproxy-test.js b/src/test/dockerproxy-test.js index f36f95435..60437aa56 100644 --- a/src/test/dockerproxy-test.js +++ b/src/test/dockerproxy-test.js @@ -6,12 +6,12 @@ 'use strict'; -var dockerProxy = require('../dockerproxy.js'), - config = require('../config.js'), +var constants = require('../constants.js'), + dockerProxy = require('../dockerproxy.js'), exec = require('child_process').exec, expect = require('expect.js'); -const DOCKER = `docker -H tcp://localhost:${config.get('dockerProxyPort')} `; +const DOCKER = `docker -H tcp://localhost:${constants.DOCKER_PROXY_PORT} `; describe('Dockerproxy', function () { var containerId; diff --git a/src/test/ldap-test.js b/src/test/ldap-test.js index 7e11f71b8..e37d2a906 100644 --- a/src/test/ldap-test.js +++ b/src/test/ldap-test.js @@ -10,9 +10,10 @@ var appdb = require('../appdb.js'), apps = require('../apps.js'), assert = require('assert'), async = require('async'), + config = require('../config.js'), + constants = require('../constants.js'), database = require('../database.js'), domains = require('../domains.js'), - config = require('../config.js'), EventEmitter = require('events').EventEmitter, expect = require('expect.js'), groups = require('../groups.js'), @@ -219,7 +220,7 @@ describe('Ldap', function () { describe('bind', function () { it('fails for nonexisting user', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=doesnotexist,ou=users,dc=cloudron', 'password', function (error) { expect(error).to.be.a(ldap.NoSuchObjectError); @@ -229,7 +230,7 @@ describe('Ldap', function () { }); it('fails with wrong password', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + USER_0.id + ',ou=users,dc=cloudron', 'wrongpassword', function (error) { expect(error).to.be.a(ldap.InvalidCredentialsError); @@ -239,7 +240,7 @@ describe('Ldap', function () { }); it('succeeds without accessRestriction', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + USER_0.id + ',ou=users,dc=cloudron', USER_0.password, function (error) { expect(error).to.be(null); @@ -249,7 +250,7 @@ describe('Ldap', function () { }); it('succeeds with username and without accessRestriction', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + USER_0.username + ',ou=users,dc=cloudron', USER_0.password, function (error) { expect(error).to.be(null); @@ -259,7 +260,7 @@ describe('Ldap', function () { }); it('succeeds with email and without accessRestriction', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + USER_0.email + ',ou=users,dc=cloudron', USER_0.password, function (error) { expect(error).to.be(null); @@ -273,7 +274,7 @@ describe('Ldap', function () { maildb.update(DOMAIN_0.domain, { enabled: true }, function (error) { expect(error).not.to.be.ok(); - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + USER_0.email.toLowerCase() + ',ou=users,dc=cloudron', USER_0.password, function (error) { expect(error).to.be(null); @@ -286,7 +287,7 @@ describe('Ldap', function () { }); it('fails with username for mail attribute and without accessRestriction', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('mail=' + USER_0.username + ',ou=users,dc=cloudron', USER_0.password, function (error) { expect(error).to.be.a(ldap.NoSuchObjectError); @@ -296,7 +297,7 @@ describe('Ldap', function () { }); it('fails with accessRestriction denied', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); appdb.update(APP_0.id, { accessRestriction: { users: [ USER_0.id ], groups: [] }}, function (error) { expect(error).to.eql(null); @@ -310,7 +311,7 @@ describe('Ldap', function () { }); it('succeeds with accessRestriction allowed', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); appdb.update(APP_0.id, { accessRestriction: { users: [ USER_1.id, USER_0.id ], groups: [] }}, function (error) { expect(error).to.eql(null); @@ -326,7 +327,7 @@ describe('Ldap', function () { describe('search users', function () { it ('fails for non existing tree', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); var opts = { filter: '(&(l=Seattle)(email=*@' + DOMAIN_0.domain + '))' @@ -348,7 +349,7 @@ describe('Ldap', function () { }); it ('succeeds with basic filter', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); var opts = { filter: 'objectcategory=person' @@ -377,7 +378,7 @@ describe('Ldap', function () { }); it ('succeeds with pagination', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); var opts = { filter: 'objectcategory=person', @@ -411,7 +412,7 @@ describe('Ldap', function () { maildb.update(DOMAIN_0.domain, { enabled: true }, function (error) { expect(error).not.to.be.ok(); - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); var opts = { filter: 'objectcategory=person' @@ -446,7 +447,7 @@ describe('Ldap', function () { }); it ('succeeds with username wildcard filter', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); var opts = { filter: '&(objectcategory=person)(username=username*)' @@ -473,7 +474,7 @@ describe('Ldap', function () { }); it ('succeeds with username filter', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); var opts = { filter: '&(objectcategory=person)(username=' + USER_0.username + ')' @@ -502,7 +503,7 @@ describe('Ldap', function () { appdb.update(APP_0.id, { accessRestriction: { users: [], groups: [] } }, function (error) { expect(error).to.be(null); - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); var opts = { filter: 'objectcategory=person' @@ -534,7 +535,7 @@ describe('Ldap', function () { appdb.update(APP_0.id, { accessRestriction: { users: [], groups: [ GROUP_ID ] } }, function (error) { expect(error).to.be(null); - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); var opts = { filter: 'objectcategory=person' @@ -567,7 +568,7 @@ describe('Ldap', function () { describe('search groups', function () { it ('succeeds with basic filter', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); var opts = { filter: 'objectclass=group' @@ -603,7 +604,7 @@ describe('Ldap', function () { }); it ('succeeds with cn wildcard filter', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); var opts = { filter: '&(objectclass=group)(cn=*)' @@ -635,7 +636,7 @@ describe('Ldap', function () { }); it('succeeds with memberuid filter', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); var opts = { filter: '&(objectclass=group)(memberuid=' + USER_1.id + ')' @@ -664,7 +665,7 @@ describe('Ldap', function () { appdb.update(APP_0.id, { accessRestriction: { users: [], groups: [ GROUP_ID ] } }, function (error) { expect(error).to.be(null); - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); var opts = { filter: '&(objectclass=group)(cn=*)' @@ -698,7 +699,7 @@ describe('Ldap', function () { }); it ('succeeds with pagination', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); var opts = { filter: 'objectclass=group', @@ -737,7 +738,7 @@ describe('Ldap', function () { // ldapsearch -LLL -E pr=10/noprompt -x -h localhost -p 3002 -b cn=userName0@example.com,ou=mailboxes,dc=cloudron objectclass=mailbox function ldapSearch(dn, filter, callback) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); var opts = { filter: filter, @@ -866,7 +867,7 @@ describe('Ldap', function () { describe('user mailbox bind', function () { it('email disabled - cannot find domain email', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + USER_0.username + '@example.com,domain=example.com,ou=mailboxes,dc=cloudron', USER_0.password + 'nope', function (error) { expect(error).to.be.a(ldap.NoSuchObjectError); @@ -880,7 +881,7 @@ describe('Ldap', function () { maildb.update(DOMAIN_0.domain, { enabled: true }, function (error) { expect(error).not.to.be.ok(); - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + USER_0.username + '@example.com,domain=example.com,ou=mailboxes,dc=cloudron', USER_0.password + 'nope', function (error) { expect(error).to.be.a(ldap.InvalidCredentialsError); @@ -897,7 +898,7 @@ describe('Ldap', function () { maildb.update(DOMAIN_0.domain, { enabled: true }, function (error) { expect(error).not.to.be.ok(); - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + USER_0.username + '@example.com,domain=example.com,ou=mailboxes,dc=cloudron', USER_0.password, function (error) { expect(error).not.to.be.ok(); @@ -914,7 +915,7 @@ describe('Ldap', function () { maildb.update(DOMAIN_0.domain, { enabled: true }, function (error) { expect(error).not.to.be.ok(); - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + USER_0_ALIAS + '@example.com,domain=example.com,ou=mailboxes,dc=cloudron', USER_0.password, function (error) { expect(error).to.be.a(ldap.NoSuchObjectError); @@ -929,7 +930,7 @@ describe('Ldap', function () { describe('user sendmail bind', function () { it('email disabled - cannot find domain email', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + USER_0.username + '@example.com,ou=sendmail,dc=cloudron', USER_0.password + 'nope', function (error) { expect(error).to.be.a(ldap.InvalidCredentialsError); @@ -939,7 +940,7 @@ describe('Ldap', function () { }); it('email disabled - cannot find reset email', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + USER_0.email + ',ou=sendmail,dc=cloudron', USER_0.password + 'nope', function (error) { expect(error).to.be.a(ldap.NoSuchObjectError); @@ -953,7 +954,7 @@ describe('Ldap', function () { maildb.update(DOMAIN_0.domain, { enabled: true }, function (error) { expect(error).not.to.be.ok(); - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + USER_0.username.toLocaleLowerCase() + '@' + DOMAIN_0.domain + ',ou=sendmail,dc=cloudron', USER_0.password, function (error) { expect(error).not.to.be.ok(); @@ -970,7 +971,7 @@ describe('Ldap', function () { maildb.update(DOMAIN_0.domain, { enabled: true }, function (error) { expect(error).not.to.be.ok(); - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + USER_0.username + '@example.com,ou=sendmail,dc=cloudron', USER_0.password + 'nope', function (error) { expect(error).to.be.a(ldap.InvalidCredentialsError); @@ -990,7 +991,7 @@ describe('Ldap', function () { }); it('does not allow with invalid app', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=hacker.app@example.com,ou=sendmail,dc=cloudron', 'nope', function (error) { expect(error).to.be.a(ldap.NoSuchObjectError); @@ -1000,7 +1001,7 @@ describe('Ldap', function () { }); it('does not allow with invalid password', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + APP_0.location + '.app@example.com,ou=sendmail,dc=cloudron', 'nope', function (error) { expect(error).to.be.a(ldap.NoSuchObjectError); @@ -1010,7 +1011,7 @@ describe('Ldap', function () { }); it('allows with valid password', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + APP_0.location + '.app@example.com,ou=sendmail,dc=cloudron', 'sendmailpassword', function (error) { client.unbind(); @@ -1025,7 +1026,7 @@ describe('Ldap', function () { }); it('email disabled - cannot find domain email', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + USER_0.username + '@example.com,ou=recvmail,dc=cloudron', USER_0.password + 'nope', function (error) { expect(error).to.be.a(ldap.NoSuchObjectError); @@ -1035,7 +1036,7 @@ describe('Ldap', function () { }); it('email disabled - cannot find reset email', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + USER_0.email + ',ou=recvmail,dc=cloudron', USER_0.password + 'nope', function (error) { expect(error).to.be.a(ldap.NoSuchObjectError); @@ -1049,7 +1050,7 @@ describe('Ldap', function () { maildb.update(DOMAIN_0.domain, { enabled: true }, function (error) { expect(error).not.to.be.ok(); - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + USER_0.username + '@example.com,ou=recvmail,dc=cloudron', USER_0.password, function (error) { expect(error).not.to.be.ok(); @@ -1066,7 +1067,7 @@ describe('Ldap', function () { maildb.update(DOMAIN_0.domain, { enabled: true }, function (error) { expect(error).not.to.be.ok(); - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + USER_0.username + '@example.com,ou=recvmail,dc=cloudron', USER_0.password + 'nope', function (error) { expect(error).to.be.a(ldap.InvalidCredentialsError); @@ -1085,7 +1086,7 @@ describe('Ldap', function () { }); it('does not allow with invalid app', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=hacker.app@example.com,ou=recvmail,dc=cloudron', 'nope', function (error) { expect(error).to.be.a(ldap.NoSuchObjectError); @@ -1095,7 +1096,7 @@ describe('Ldap', function () { }); it('does not allow with invalid password', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + APP_0.location + '.app@example.com,ou=recvmail,dc=cloudron', 'nope', function (error) { expect(error).to.be.a(ldap.NoSuchObjectError); @@ -1105,7 +1106,7 @@ describe('Ldap', function () { }); it('allows with valid password', function (done) { - var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); + var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT }); client.bind('cn=' + APP_0.location + '.app@example.com,ou=recvmail,dc=cloudron', 'recvmailpassword', function (error) { client.unbind();