Fixup various tests for multidomain
This commit is contained in:
@@ -127,11 +127,12 @@ describe('Apps', function () {
|
||||
};
|
||||
|
||||
before(function (done) {
|
||||
config.setFqdn(DOMAIN_0.domain);
|
||||
|
||||
async.series([
|
||||
database.initialize,
|
||||
database._clear,
|
||||
domaindb.add.bind(null, DOMAIN_0.domain, DOMAIN_0.zoneName, DOMAIN_0.config),
|
||||
// DOMAIN_0 already added for test through domaindb.addDefaultDomain()
|
||||
domaindb.add.bind(null, DOMAIN_1.domain, DOMAIN_1.zoneName, DOMAIN_1.config),
|
||||
userdb.add.bind(null, ADMIN_0.id, ADMIN_0),
|
||||
userdb.add.bind(null, USER_0.id, USER_0),
|
||||
|
||||
@@ -11,6 +11,7 @@ var addons = require('../addons.js'),
|
||||
async = require('async'),
|
||||
config = require('../config.js'),
|
||||
database = require('../database.js'),
|
||||
domains = require('../domains.js'),
|
||||
expect = require('expect.js'),
|
||||
fs = require('fs'),
|
||||
js2xml = require('js2xmlparser').parse,
|
||||
@@ -48,12 +49,24 @@ var MANIFEST = {
|
||||
}
|
||||
};
|
||||
|
||||
const DOMAIN_0 = {
|
||||
domain: 'example.com',
|
||||
zoneName: 'example.com',
|
||||
config: {
|
||||
provider: 'route53',
|
||||
accessKeyId: 'accessKeyId',
|
||||
secretAccessKey: 'secretAccessKey',
|
||||
endpoint: 'http://localhost:5353'
|
||||
}
|
||||
};
|
||||
|
||||
var APP = {
|
||||
id: 'appid',
|
||||
appStoreId: 'appStoreId',
|
||||
installationState: appdb.ISTATE_PENDING_INSTALL,
|
||||
runState: null,
|
||||
location: 'applocation',
|
||||
domain: DOMAIN_0.domain,
|
||||
manifest: MANIFEST,
|
||||
containerId: null,
|
||||
httpPort: 4567,
|
||||
@@ -63,13 +76,12 @@ var APP = {
|
||||
memoryLimit: 0
|
||||
};
|
||||
|
||||
var awsHostedZones;
|
||||
var awsHostedZones;
|
||||
|
||||
describe('apptask', function () {
|
||||
before(function (done) {
|
||||
config.set('version', '0.5.0');
|
||||
config.setFqdn('foobar.com');
|
||||
config.setZoneName('foobar.com');
|
||||
config.setFqdn(DOMAIN_0.domain);
|
||||
config.set('provider', 'caas');
|
||||
|
||||
awsHostedZones = {
|
||||
@@ -89,9 +101,9 @@ describe('apptask', function () {
|
||||
|
||||
async.series([
|
||||
database.initialize,
|
||||
appdb.add.bind(null, APP.id, APP.appStoreId, APP.manifest, APP.location, APP.portBindings, APP),
|
||||
domains.update.bind(null, DOMAIN_0.domain, DOMAIN_0.config, null),
|
||||
appdb.add.bind(null, APP.id, APP.appStoreId, APP.manifest, APP.location, APP.domain, APP.portBindings, APP),
|
||||
settings.initialize,
|
||||
settings.setDnsConfig.bind(null, { provider: 'route53', accessKeyId: 'accessKeyId', secretAccessKey: 'secretAccessKey', endpoint: 'http://localhost:5353' }, config.fqdn(), config.zoneName()),
|
||||
settings.setTlsConfig.bind(null, { provider: 'caas' })
|
||||
], done);
|
||||
});
|
||||
@@ -246,7 +258,7 @@ describe('apptask', function () {
|
||||
.post('/2013-04-01/hostedzone/ZONEID/rrset/')
|
||||
.reply(200, js2xml('ChangeResourceRecordSetsResponse', { ChangeInfo: { Id: 'RRID', Status: 'INSYNC' } }));
|
||||
|
||||
apptask._unregisterSubdomain(APP, APP.location, function (error) {
|
||||
apptask._unregisterSubdomain(APP, APP.location, APP.domain, function (error) {
|
||||
expect(error).to.be(null);
|
||||
expect(awsScope.isDone()).to.be.ok();
|
||||
done();
|
||||
|
||||
@@ -9,6 +9,7 @@ var async = require('async'),
|
||||
config = require('../config.js'),
|
||||
database = require('../database.js'),
|
||||
digest = require('../digest.js'),
|
||||
domaindb = require('../domaindb.js'),
|
||||
eventlog = require('../eventlog.js'),
|
||||
expect = require('expect.js'),
|
||||
mailer = require('../mailer.js'),
|
||||
@@ -27,6 +28,12 @@ var USER_0 = {
|
||||
displayName: 'User 0'
|
||||
};
|
||||
|
||||
const DOMAIN_0 = {
|
||||
domain: 'example.com',
|
||||
zoneName: 'example.com',
|
||||
config: { provider: 'manual' }
|
||||
};
|
||||
|
||||
var AUDIT_SOURCE = {
|
||||
ip: '1.2.3.4'
|
||||
};
|
||||
@@ -62,6 +69,7 @@ describe('digest', function () {
|
||||
config.set('version', '1.0.0');
|
||||
config.set('apiServerOrigin', 'http://localhost:4444');
|
||||
config.set('provider', 'notcaas');
|
||||
config.setFqdn(DOMAIN_0.domain);
|
||||
safe.fs.unlinkSync(paths.UPDATE_CHECKER_FILE);
|
||||
|
||||
async.series([
|
||||
@@ -124,7 +132,7 @@ describe('digest', function () {
|
||||
digest.maybeSend(function (error) {
|
||||
if (error) return done(error);
|
||||
|
||||
checkMails(1, `${USER_0.email}, ${USER_0.username}@${config.fqdn()}`, done);
|
||||
checkMails(1, `${USER_0.email}, ${USER_0.username}@${DOMAIN_0.domain}`, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+16
-8
@@ -7,6 +7,7 @@
|
||||
'use strict';
|
||||
|
||||
var async = require('async'),
|
||||
config = require('../config.js'),
|
||||
constants = require('../constants.js'),
|
||||
database = require('../database.js'),
|
||||
DatabaseError = require('../databaseerror.js'),
|
||||
@@ -23,6 +24,12 @@ var GROUP0_NAME = 'administrators',
|
||||
var GROUP1_NAME = 'externs',
|
||||
group1Object;
|
||||
|
||||
const DOMAIN_0 = {
|
||||
domain: 'example.com',
|
||||
zoneName: 'example.com',
|
||||
config: { provider: 'manual' }
|
||||
};
|
||||
|
||||
var USER_0 = {
|
||||
id: 'uuid213',
|
||||
username: 'uuid213',
|
||||
@@ -50,12 +57,13 @@ var USER_1 = { // this user has not signed up yet
|
||||
};
|
||||
|
||||
function setup(done) {
|
||||
// ensure data/config/mount paths
|
||||
database.initialize(function (error) {
|
||||
expect(error).to.be(null);
|
||||
config.setFqdn(DOMAIN_0.domain);
|
||||
|
||||
database._clear(done);
|
||||
});
|
||||
// ensure data/config/mount paths
|
||||
async.series([
|
||||
database.initialize,
|
||||
database._clear
|
||||
], done);
|
||||
}
|
||||
|
||||
function cleanup(done) {
|
||||
@@ -118,7 +126,7 @@ describe('Groups', function () {
|
||||
});
|
||||
|
||||
it('did create mailbox', function (done) {
|
||||
mailboxdb.getGroup(GROUP0_NAME.toLowerCase(), function (error, mailbox) {
|
||||
mailboxdb.getGroup(GROUP0_NAME.toLowerCase(), DOMAIN_0.domain, function (error, mailbox) {
|
||||
expect(error).to.be(null);
|
||||
expect(mailbox.ownerType).to.be(mailboxdb.TYPE_GROUP);
|
||||
done();
|
||||
@@ -162,7 +170,7 @@ describe('Groups', function () {
|
||||
});
|
||||
|
||||
it('did delete mailbox', function (done) {
|
||||
mailboxdb.getGroup(GROUP0_NAME.toLowerCase(), function (error) {
|
||||
mailboxdb.getGroup(GROUP0_NAME.toLowerCase(), DOMAIN_0.domain, function (error) {
|
||||
expect(error.reason).to.be(DatabaseError.NOT_FOUND);
|
||||
done();
|
||||
});
|
||||
@@ -241,7 +249,7 @@ describe('Group membership', function () {
|
||||
});
|
||||
|
||||
it('can get list members', function (done) {
|
||||
mailboxdb.getGroup(GROUP0_NAME.toLowerCase(), function (error, result) {
|
||||
mailboxdb.getGroup(GROUP0_NAME.toLowerCase(), DOMAIN_0.domain, function (error, result) {
|
||||
expect(error).to.be(null);
|
||||
expect(result.name).to.be(GROUP0_NAME.toLowerCase());
|
||||
expect(result.ownerType).to.be(mailboxdb.TYPE_GROUP);
|
||||
|
||||
@@ -28,6 +28,12 @@ var USER_0 = {
|
||||
displayName: 'User 0'
|
||||
};
|
||||
|
||||
const DOMAIN_0 = {
|
||||
domain: 'example.com',
|
||||
zoneName: 'example.com',
|
||||
config: { provider: 'manual' }
|
||||
};
|
||||
|
||||
var AUDIT_SOURCE = {
|
||||
ip: '1.2.3.4'
|
||||
};
|
||||
@@ -54,6 +60,7 @@ function cleanup(done) {
|
||||
describe('updatechecker - box - manual (email)', function () {
|
||||
before(function (done) {
|
||||
config._reset();
|
||||
config.setFqdn(DOMAIN_0.domain);
|
||||
config.set('version', '1.0.0');
|
||||
config.set('apiServerOrigin', 'http://localhost:4444');
|
||||
config.set('provider', 'notcaas');
|
||||
@@ -157,9 +164,11 @@ describe('updatechecker - box - manual (email)', function () {
|
||||
|
||||
describe('updatechecker - box - automatic (no email)', function () {
|
||||
before(function (done) {
|
||||
config.setFqdn(DOMAIN_0.domain);
|
||||
config.set('version', '1.0.0');
|
||||
config.set('apiServerOrigin', 'http://localhost:4444');
|
||||
config.set('provider', 'notcaas');
|
||||
|
||||
async.series([
|
||||
database.initialize,
|
||||
settings.initialize,
|
||||
@@ -198,9 +207,11 @@ describe('updatechecker - box - automatic (no email)', function () {
|
||||
|
||||
describe('updatechecker - box - automatic free (email)', function () {
|
||||
before(function (done) {
|
||||
config.setFqdn(DOMAIN_0.domain);
|
||||
config.set('version', '1.0.0');
|
||||
config.set('apiServerOrigin', 'http://localhost:4444');
|
||||
config.set('provider', 'notcaas');
|
||||
|
||||
async.series([
|
||||
database.initialize,
|
||||
settings.initialize,
|
||||
@@ -244,6 +255,7 @@ describe('updatechecker - app - manual (email)', function () {
|
||||
installationProgress: null,
|
||||
runState: null,
|
||||
location: 'some-location-0',
|
||||
domain: DOMAIN_0.domain,
|
||||
manifest: {
|
||||
version: '1.0.0', dockerImage: 'docker/app0', healthCheckPath: '/', httpPort: 80, title: 'app0',
|
||||
tcpPorts: {
|
||||
@@ -262,6 +274,7 @@ describe('updatechecker - app - manual (email)', function () {
|
||||
};
|
||||
|
||||
before(function (done) {
|
||||
config.setFqdn(DOMAIN_0.domain);
|
||||
config.set('version', '1.0.0');
|
||||
config.set('apiServerOrigin', 'http://localhost:4444');
|
||||
config.set('provider', 'notcaas');
|
||||
@@ -271,7 +284,7 @@ describe('updatechecker - app - manual (email)', function () {
|
||||
database._clear,
|
||||
settings.initialize,
|
||||
mailer._clearMailQueue,
|
||||
appdb.add.bind(null, APP_0.id, APP_0.appStoreId, APP_0.manifest, APP_0.location, APP_0.portBindings, APP_0),
|
||||
appdb.add.bind(null, APP_0.id, APP_0.appStoreId, APP_0.manifest, APP_0.location, APP_0.domain, APP_0.portBindings, APP_0),
|
||||
user.createOwner.bind(null, USER_0.username, USER_0.password, USER_0.email, USER_0.displayName, AUDIT_SOURCE),
|
||||
settings.setAutoupdatePattern.bind(null, constants.AUTOUPDATE_PATTERN_NEVER),
|
||||
settingsdb.set.bind(null, settings.APPSTORE_CONFIG_KEY, JSON.stringify({ userId: 'uid', cloudronId: 'cid', token: 'token' }))
|
||||
@@ -356,6 +369,7 @@ describe('updatechecker - app - automatic (no email)', function () {
|
||||
installationProgress: null,
|
||||
runState: null,
|
||||
location: 'some-location-0',
|
||||
domain: DOMAIN_0.domain,
|
||||
manifest: {
|
||||
version: '1.0.0', dockerImage: 'docker/app0', healthCheckPath: '/', httpPort: 80, title: 'app0',
|
||||
tcpPorts: {
|
||||
@@ -374,6 +388,7 @@ describe('updatechecker - app - automatic (no email)', function () {
|
||||
};
|
||||
|
||||
before(function (done) {
|
||||
config.setFqdn(DOMAIN_0.domain);
|
||||
config.set('version', '1.0.0');
|
||||
config.set('apiServerOrigin', 'http://localhost:4444');
|
||||
config.set('provider', 'notcaas');
|
||||
@@ -383,7 +398,7 @@ describe('updatechecker - app - automatic (no email)', function () {
|
||||
database._clear,
|
||||
settings.initialize,
|
||||
mailer._clearMailQueue,
|
||||
appdb.add.bind(null, APP_0.id, APP_0.appStoreId, APP_0.manifest, APP_0.location, APP_0.portBindings, APP_0),
|
||||
appdb.add.bind(null, APP_0.id, APP_0.appStoreId, APP_0.manifest, APP_0.location, APP_0.domain, APP_0.portBindings, APP_0),
|
||||
user.createOwner.bind(null, USER_0.username, USER_0.password, USER_0.email, USER_0.displayName, AUDIT_SOURCE),
|
||||
settingsdb.set.bind(null, settings.APPSTORE_CONFIG_KEY, JSON.stringify({ userId: 'uid', cloudronId: 'cid', token: 'token' }))
|
||||
], done);
|
||||
@@ -417,6 +432,7 @@ describe('updatechecker - app - automatic free (email)', function () {
|
||||
installationProgress: null,
|
||||
runState: null,
|
||||
location: 'some-location-0',
|
||||
domain: DOMAIN_0.domain,
|
||||
manifest: {
|
||||
version: '1.0.0', dockerImage: 'docker/app0', healthCheckPath: '/', httpPort: 80, title: 'app0',
|
||||
tcpPorts: {
|
||||
@@ -435,6 +451,7 @@ describe('updatechecker - app - automatic free (email)', function () {
|
||||
};
|
||||
|
||||
before(function (done) {
|
||||
config.setFqdn(DOMAIN_0.domain);
|
||||
config.set('version', '1.0.0');
|
||||
config.set('apiServerOrigin', 'http://localhost:4444');
|
||||
config.set('provider', 'notcaas');
|
||||
@@ -444,7 +461,7 @@ describe('updatechecker - app - automatic free (email)', function () {
|
||||
database._clear,
|
||||
settings.initialize,
|
||||
mailer._clearMailQueue,
|
||||
appdb.add.bind(null, APP_0.id, APP_0.appStoreId, APP_0.manifest, APP_0.location, APP_0.portBindings, APP_0),
|
||||
appdb.add.bind(null, APP_0.id, APP_0.appStoreId, APP_0.manifest, APP_0.location, APP_0.domain, APP_0.portBindings, APP_0),
|
||||
user.createOwner.bind(null, USER_0.username, USER_0.password, USER_0.email, USER_0.displayName, AUDIT_SOURCE),
|
||||
settingsdb.set.bind(null, settings.APPSTORE_CONFIG_KEY, JSON.stringify({ userId: 'uid', cloudronId: 'cid', token: 'token' }))
|
||||
], done);
|
||||
|
||||
+15
-6
@@ -39,6 +39,12 @@ var EMAIL_1 = 'second@user.com';
|
||||
var PASSWORD_1 = 'Sup2345$@strong';
|
||||
var DISPLAY_NAME_1 = 'Second User';
|
||||
|
||||
const DOMAIN_0 = {
|
||||
domain: 'example.com',
|
||||
zoneName: 'example.com',
|
||||
config: { provider: 'manual' }
|
||||
};
|
||||
|
||||
function cleanupUsers(done) {
|
||||
async.series([
|
||||
groupdb._clear,
|
||||
@@ -62,9 +68,12 @@ function createOwner(done) {
|
||||
}
|
||||
|
||||
function setup(done) {
|
||||
config.setFqdn(DOMAIN_0.domain);
|
||||
|
||||
async.series([
|
||||
database.initialize,
|
||||
database._clear,
|
||||
mailer.start,
|
||||
mailer._clearMailQueue
|
||||
], done);
|
||||
}
|
||||
@@ -205,7 +214,7 @@ describe('User', function () {
|
||||
});
|
||||
|
||||
it('did create mailbox', function (done) {
|
||||
mailboxdb.getMailbox(USERNAME.toLowerCase(), function (error, mailbox) {
|
||||
mailboxdb.getMailbox(USERNAME.toLowerCase(), DOMAIN_0.domain, function (error, mailbox) {
|
||||
expect(error).to.be(null);
|
||||
expect(mailbox.ownerType).to.be(mailboxdb.TYPE_USER);
|
||||
done();
|
||||
@@ -712,10 +721,10 @@ describe('User', function () {
|
||||
});
|
||||
|
||||
it('updated the mailbox', function (done) {
|
||||
mailboxdb.getMailbox(USERNAME, function (error) {
|
||||
mailboxdb.getMailbox(USERNAME, DOMAIN_0.domain, function (error) {
|
||||
expect(error.reason).to.be(DatabaseError.NOT_FOUND);
|
||||
|
||||
mailboxdb.getMailbox(USERNAME_NEW.toLowerCase(), function (error, mailbox) {
|
||||
mailboxdb.getMailbox(USERNAME_NEW.toLowerCase(), DOMAIN_0.domain, function (error, mailbox) {
|
||||
expect(error).to.be(null);
|
||||
expect(mailbox.ownerId).to.be(userObject.id);
|
||||
done();
|
||||
@@ -998,7 +1007,7 @@ describe('User', function () {
|
||||
user.setAliases(userObject.id, [ 'everything', 'is', 'awesome' ], function (error) {
|
||||
expect(error).to.be(null);
|
||||
|
||||
mailboxdb.getAliasesForName(USERNAME.toLowerCase(), function (error, results) {
|
||||
mailboxdb.getAliasesForName(USERNAME.toLowerCase(), DOMAIN_0.domain, function (error, results) {
|
||||
expect(error).to.be(null);
|
||||
expect(results.length).to.be(3);
|
||||
done();
|
||||
@@ -1014,10 +1023,10 @@ describe('User', function () {
|
||||
});
|
||||
|
||||
it('did delete mailbox and aliases', function (done) {
|
||||
mailboxdb.getMailbox(userObject.username.toLowerCase(), function (error, mailbox) {
|
||||
mailboxdb.getMailbox(userObject.username.toLowerCase(), DOMAIN_0.domain, function (error, mailbox) {
|
||||
expect(error.reason).to.be(DatabaseError.NOT_FOUND);
|
||||
|
||||
mailboxdb.getAliasesForName(USERNAME.toLowerCase(), function (error, results) {
|
||||
mailboxdb.getAliasesForName(USERNAME.toLowerCase(), DOMAIN_0.domain, function (error, results) {
|
||||
expect(error).to.be(null);
|
||||
expect(results.length).to.be(0);
|
||||
done();
|
||||
|
||||
Reference in New Issue
Block a user