tests: cleanup common variables
This commit is contained in:
@@ -47,7 +47,7 @@ const MANIFEST = {
|
||||
}
|
||||
};
|
||||
|
||||
const DOMAIN = {
|
||||
const domain = {
|
||||
domain: 'example.com',
|
||||
zoneName: 'example.com',
|
||||
provider: 'noop',
|
||||
@@ -57,9 +57,9 @@ const DOMAIN = {
|
||||
wellKnown: null
|
||||
};
|
||||
|
||||
const AUDIT_SOURCE = { ip: '1.2.3.4' };
|
||||
const auditSource = { ip: '1.2.3.4' };
|
||||
|
||||
const ADMIN = {
|
||||
const admin = {
|
||||
id: null,
|
||||
username: 'testadmin',
|
||||
password: 'secret123',
|
||||
@@ -76,7 +76,7 @@ const ADMIN = {
|
||||
active: true,
|
||||
};
|
||||
|
||||
const USER = {
|
||||
const user = {
|
||||
id: null,
|
||||
username: 'user',
|
||||
password: '123secret',
|
||||
@@ -93,20 +93,20 @@ const USER = {
|
||||
active: true,
|
||||
};
|
||||
|
||||
const APP = {
|
||||
const app = {
|
||||
id: 'appid',
|
||||
appStoreId: 'appStoreId',
|
||||
installationState: apps.ISTATE_PENDING_INSTALL,
|
||||
runState: 'running',
|
||||
location: 'applocation',
|
||||
domain: DOMAIN.domain,
|
||||
fqdn: DOMAIN.domain + '.' + 'applocation',
|
||||
domain: domain.domain,
|
||||
fqdn: domain.domain + '.' + 'applocation',
|
||||
manifest: MANIFEST,
|
||||
containerId: 'someid',
|
||||
portBindings: null,
|
||||
accessRestriction: null,
|
||||
memoryLimit: 0,
|
||||
mailboxDomain: DOMAIN.domain,
|
||||
mailboxDomain: domain.domain,
|
||||
alternateDomains: [],
|
||||
aliasDomains: []
|
||||
};
|
||||
@@ -117,22 +117,22 @@ exports = module.exports = {
|
||||
setup,
|
||||
cleanup,
|
||||
|
||||
MOCK_API_SERVER_ORIGIN: 'http://localhost:6060',
|
||||
mockApiServerOrigin: 'http://localhost:6060',
|
||||
DASHBOARD_DOMAIN: 'test.example.com',
|
||||
DASHBOARD_FQDN: 'my.test.example.com',
|
||||
|
||||
APP,
|
||||
ADMIN,
|
||||
AUDIT_SOURCE,
|
||||
DOMAIN,
|
||||
app,
|
||||
admin,
|
||||
auditSource,
|
||||
domain,
|
||||
MANIFEST,
|
||||
USER,
|
||||
APPSTORE_TOKEN: 'atoken',
|
||||
user,
|
||||
appstoreToken: 'atoken',
|
||||
|
||||
MAILBOX_NAME: 'support',
|
||||
MAILBOX: `support@${DOMAIN.domain}`,
|
||||
MAILBOX: `support@${domain.domain}`,
|
||||
ALIAS_NAME: 'alsosupport',
|
||||
ALIAS: `alsosupport@${DOMAIN.domain}`
|
||||
ALIAS: `alsosupport@${domain.domain}`
|
||||
};
|
||||
|
||||
function createTree(root, obj) {
|
||||
@@ -163,11 +163,11 @@ function domainSetup(done) {
|
||||
async.series([
|
||||
database.initialize,
|
||||
database._clear,
|
||||
settings._setApiServerOrigin.bind(null, exports.MOCK_API_SERVER_ORIGIN),
|
||||
settings._setApiServerOrigin.bind(null, exports.mockApiServerOrigin),
|
||||
settings.setDashboardLocation.bind(null, exports.DASHBOARD_DOMAIN, exports.DASHBOARD_FQDN),
|
||||
settings.initCache,
|
||||
blobs.initSecrets,
|
||||
domains.add.bind(null, DOMAIN.domain, DOMAIN, AUDIT_SOURCE),
|
||||
domains.add.bind(null, domain.domain, domain, auditSource),
|
||||
], done);
|
||||
}
|
||||
|
||||
@@ -175,17 +175,17 @@ function setup(done) {
|
||||
async.series([
|
||||
domainSetup,
|
||||
async function createOwner() {
|
||||
const result = await users.createOwner(ADMIN.email, ADMIN.username, ADMIN.password, ADMIN.displayName, AUDIT_SOURCE);
|
||||
ADMIN.id = result;
|
||||
const result = await users.createOwner(admin.email, admin.username, admin.password, admin.displayName, auditSource);
|
||||
admin.id = result;
|
||||
},
|
||||
appdb.add.bind(null, APP.id, APP.appStoreId, APP.manifest, APP.location, APP.domain, APP.portBindings, APP),
|
||||
settingsdb.set.bind(null, settings.CLOUDRON_TOKEN_KEY, exports.APPSTORE_TOKEN), // appstore token
|
||||
appdb.add.bind(null, app.id, app.appStoreId, app.manifest, app.location, app.domain, app.portBindings, app),
|
||||
settingsdb.set.bind(null, settings.CLOUDRON_TOKEN_KEY, exports.appstoreToken), // appstore token
|
||||
async function createUser() {
|
||||
const result = await users.add(USER.email, USER, AUDIT_SOURCE);
|
||||
USER.id = result;
|
||||
const result = await users.add(user.email, user, auditSource);
|
||||
user.id = result;
|
||||
},
|
||||
(done) => mailboxdb.addMailbox(exports.MAILBOX_NAME, DOMAIN.domain, { ownerId: USER.id, ownerType: mail.OWNERTYPE_USER, active: true }, done),
|
||||
(done) => mailboxdb.setAliasesForName(exports.MAILBOX_NAME, DOMAIN.domain, [ { name: exports.ALIAS_NAME, domain: DOMAIN.domain} ], done),
|
||||
(done) => mailboxdb.addMailbox(exports.MAILBOX_NAME, domain.domain, { ownerId: user.id, ownerType: mail.OWNERTYPE_USER, active: true }, done),
|
||||
(done) => mailboxdb.setAliasesForName(exports.MAILBOX_NAME, domain.domain, [ { name: exports.ALIAS_NAME, domain: domain.domain} ], done),
|
||||
|
||||
tasks.stopAllTasks,
|
||||
], done);
|
||||
|
||||
Reference in New Issue
Block a user