diff --git a/src/routes/test/oauth2-test.js b/src/routes/test/oauth2-test.js index 11017ee4d..4f94e1075 100644 --- a/src/routes/test/oauth2-test.js +++ b/src/routes/test/oauth2-test.js @@ -17,6 +17,7 @@ var expect = require('expect.js'), server = require('../../server.js'), querystring = require('querystring'), database = require('../../database.js'), + domains = require('../../domains.js'), clientdb = require('../../clientdb.js'), clients = require('../../clients.js'), userdb = require('../../userdb.js'), @@ -137,6 +138,14 @@ describe('OAuth2', function () { }); describe('flow', function () { + const DOMAIN_0 = { + domain: 'example.com', + zoneName: 'example.com', + config: {}, + provider: 'manual', + fallbackCertificate: null + }; + var USER_0 = { id: uuid.v4(), username: 'someUSERname', @@ -154,7 +163,7 @@ describe('OAuth2', function () { appStoreId: '', manifest: { version: '0.1.0', addons: { } }, location: 'test', - domain: 'example.com', + domain: DOMAIN_0.domain, portBindings: {}, accessRestriction: null, memoryLimit: 0, @@ -166,7 +175,7 @@ describe('OAuth2', function () { appStoreId: '', manifest: { version: '0.1.0', addons: { } }, location: 'test1', - domain: 'example.com', + domain: DOMAIN_0.domain, portBindings: {}, accessRestriction: { users: [ 'foobar' ] }, memoryLimit: 0, @@ -178,7 +187,7 @@ describe('OAuth2', function () { appStoreId: '', manifest: { version: '0.1.0', addons: { } }, location: 'test2', - domain: 'example.com', + domain: DOMAIN_0.domain, portBindings: {}, accessRestriction: { users: [ USER_0.id ] }, memoryLimit: 0, @@ -190,7 +199,7 @@ describe('OAuth2', function () { appStoreId: '', manifest: { version: '0.1.0', addons: { } }, location: 'test3', - domain: 'example.com', + domain: DOMAIN_0.domain, portBindings: {}, accessRestriction: { groups: [ 'someothergroup', 'admin', 'anothergroup' ] }, memoryLimit: 0, @@ -301,6 +310,7 @@ describe('OAuth2', function () { async.series([ server.start, database._clear, + domains.add.bind(null, DOMAIN_0.domain, DOMAIN_0.zoneName, DOMAIN_0.provider, DOMAIN_0.config, DOMAIN_0.fallbackCertificate), clientdb.add.bind(null, CLIENT_0.id, CLIENT_0.appId, CLIENT_0.type, CLIENT_0.clientSecret, CLIENT_0.redirectURI, CLIENT_0.scope), clientdb.add.bind(null, CLIENT_1.id, CLIENT_1.appId, CLIENT_1.type, CLIENT_1.clientSecret, CLIENT_1.redirectURI, CLIENT_1.scope), clientdb.add.bind(null, CLIENT_2.id, CLIENT_2.appId, CLIENT_2.type, CLIENT_2.clientSecret, CLIENT_2.redirectURI, CLIENT_2.scope), diff --git a/src/test/ldap-test.js b/src/test/ldap-test.js index 65e6f292f..83aa1b4a5 100644 --- a/src/test/ldap-test.js +++ b/src/test/ldap-test.js @@ -253,7 +253,7 @@ describe('Ldap', function () { it('succeeds without accessRestriction when email is enabled', function (done) { // use maildb to not trigger further events - maildb.update(DOMAIN, { enabled: true }, function (error) { + 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') }); @@ -263,7 +263,7 @@ describe('Ldap', function () { client.unbind(); - maildb.update(DOMAIN, { enabled: false }, done); + maildb.update(DOMAIN_0.domain, { enabled: false }, done); }); }); }); @@ -309,7 +309,7 @@ describe('Ldap', function () { var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + config.get('ldapPort') }); var opts = { - filter: '(&(l=Seattle)(email=*@' + DOMAIN + '))' + filter: '(&(l=Seattle)(email=*@' + DOMAIN_0.domain + '))' }; client.search('o=example', opts, function (error, result) { @@ -385,7 +385,7 @@ describe('Ldap', function () { it ('succeeds with basic filter and email enabled', function (done) { // user settingsdb instead of settings, to not trigger further events - maildb.update(DOMAIN, { enabled: true }, function (error) { + 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') }); @@ -416,7 +416,7 @@ describe('Ldap', function () { client.unbind(); - maildb.update(DOMAIN, { enabled: false }, done); + maildb.update(DOMAIN_0.domain, { enabled: false }, done); }); }); }); @@ -852,7 +852,7 @@ describe('Ldap', function () { it('email enabled - allows with valid email', function (done) { // use maildb to not trigger further events - maildb.update(DOMAIN, { enabled: true }, function (error) { + 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') }); @@ -862,14 +862,14 @@ describe('Ldap', function () { client.unbind(); - maildb.update(DOMAIN, { enabled: false }, done); + maildb.update(DOMAIN_0.domain, { enabled: false }, done); }); }); }); it('email enabled - does not allow with invalid password', function (done) { // use maildb to not trigger further events - maildb.update(DOMAIN, { enabled: true }, function (error) { + 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') }); @@ -879,7 +879,7 @@ describe('Ldap', function () { client.unbind(); - maildb.update(DOMAIN, { enabled: false }, done); + maildb.update(DOMAIN_0.domain, { enabled: false }, done); }); }); }); @@ -888,7 +888,7 @@ describe('Ldap', function () { describe('app sendmail bind', function () { // these tests should work even when email is disabled before(function (done) { - maildb.update(DOMAIN, { enabled: false }, done); + maildb.update(DOMAIN_0.domain, { enabled: false }, done); }); it('does not allow with invalid app', function (done) { @@ -940,7 +940,7 @@ describe('Ldap', function () { it('email enabled - allows with valid email', function (done) { // use maildb to not trigger further events - maildb.update(DOMAIN, { enabled: true }, function (error) { + 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') }); @@ -950,14 +950,14 @@ describe('Ldap', function () { client.unbind(); - maildb.update(DOMAIN, { enabled: false }, done); + maildb.update(DOMAIN_0.domain, { enabled: false }, done); }); }); }); it('email enabled - does not allow with invalid password', function (done) { // use maildb to not trigger further events - maildb.update(DOMAIN, { enabled: true }, function (error) { + 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') }); @@ -967,7 +967,7 @@ describe('Ldap', function () { client.unbind(); - maildb.update(DOMAIN, { enabled: false }, done); + maildb.update(DOMAIN_0.domain, { enabled: false }, done); }); }); }); diff --git a/src/test/mail-test.js b/src/test/mail-test.js index 0488c0644..c51a4a3a2 100644 --- a/src/test/mail-test.js +++ b/src/test/mail-test.js @@ -8,6 +8,7 @@ var async = require('async'), config = require('../config.js'), database = require('../database.js'), + domains = require('../domains.js'), expect = require('expect.js'), mail = require('../mail.js'), maildb = require('../maildb.js'); @@ -16,7 +17,8 @@ const DOMAIN_0 = { domain: 'example.com', zoneName: 'example.com', provider: 'manual', - config: { } + config: {}, + fallbackCertificate: null }; function setup(done) { @@ -27,7 +29,8 @@ function setup(done) { async.series([ database.initialize, database._clear, - // DOMAIN_0 already added for test through domaindb.addDefaultDomain() + domains.add.bind(null, DOMAIN_0.domain, DOMAIN_0.zoneName, DOMAIN_0.provider, DOMAIN_0.config, DOMAIN_0.fallbackCertificate), + mail.add.bind(null, DOMAIN_0.domain) ], done); }