diff --git a/src/database.js b/src/database.js index f8f2be083..eabb99702 100644 --- a/src/database.js +++ b/src/database.js @@ -105,7 +105,6 @@ function clear(callback) { child_process.exec.bind(null, cmd), require('./clientdb.js')._addDefaultClients, require('./domaindb.js')._addDefaultDomain, - require('./maildb.js')._addDefaultDomain, require('./groupdb.js')._addDefaultGroups ], callback); } diff --git a/src/routes/test/backups-test.js b/src/routes/test/backups-test.js index 03b62f07e..a84e0ed23 100644 --- a/src/routes/test/backups-test.js +++ b/src/routes/test/backups-test.js @@ -13,19 +13,19 @@ var appdb = require('../../appdb.js'), nock = require('nock'), superagent = require('superagent'), server = require('../../server.js'), - settings = require('../../settings.js'), - settingsdb = require('../../settingsdb.js'); + settings = require('../../settings.js'); var SERVER_URL = 'http://localhost:' + config.get('port'); var USERNAME = 'superadmin', PASSWORD = 'Foobar?1337', EMAIL ='silly@me.com'; +var DOMAIN = 'example-backups-test.com'; var token = null; function setup(done) { nock.cleanAll(); config._reset(); config.setVersion('1.2.3'); - config.setFqdn('example-backups-test.com'); + config.setFqdn(DOMAIN); async.series([ server.start.bind(server), @@ -49,7 +49,7 @@ function setup(done) { function addApp(callback) { var manifest = { version: '0.0.1', manifestVersion: 1, dockerImage: 'foo', healthCheckPath: '/', httpPort: 3, title: 'ok', addons: { } }; - appdb.add('appid', 'appStoreId', manifest, 'location', config.fqdn(), [ ] /* portBindings */, { }, callback); + appdb.add('appid', 'appStoreId', manifest, 'location', DOMAIN, [ ] /* portBindings */, { }, callback); }, function createSettings(callback) { diff --git a/src/routes/test/caas-test.js b/src/routes/test/caas-test.js index 6209b548f..9ed225cc1 100644 --- a/src/routes/test/caas-test.js +++ b/src/routes/test/caas-test.js @@ -24,7 +24,7 @@ var SERVER_URL = 'http://localhost:' + config.get('port'); var USERNAME = 'superadmin', PASSWORD = 'Foobar?1337', EMAIL ='silly@me.com'; var token = null; - +var DOMAIN = 'example-backups-test.com'; var gSudoOriginal = null; function injectShellMock() { @@ -41,7 +41,7 @@ function setup(done) { config._reset(); config.set('provider', 'caas'); config.setVersion('1.2.3'); - config.setFqdn('example-backups-test.com'); + config.setFqdn(DOMAIN); async.series([ server.start.bind(server), @@ -72,7 +72,7 @@ function setup(done) { function addApp(callback) { var manifest = { version: '0.0.1', manifestVersion: 1, dockerImage: 'foo', healthCheckPath: '/', httpPort: 3, title: 'ok', addons: { } }; - appdb.add('appid', 'appStoreId', manifest, 'location', config.fqdn(), [ ] /* portBindings */, { }, callback); + appdb.add('appid', 'appStoreId', manifest, 'location', DOMAIN, [ ] /* portBindings */, { }, callback); }, function createSettings(callback) { @@ -149,7 +149,6 @@ describe('Caas', function () { expect(result.statusCode).to.equal(200); expect(result.body.apiServerOrigin).to.eql('http://localhost:6060'); expect(result.body.webServerOrigin).to.eql(null); - expect(result.body.fqdn).to.eql(config.fqdn()); expect(result.body.adminFqdn).to.eql(config.adminFqdn()); expect(result.body.progress).to.be.an('object'); expect(result.body.update).to.be.an('object'); diff --git a/src/routes/test/cloudron-test.js b/src/routes/test/cloudron-test.js index 9e3f72a65..1f135f8a9 100644 --- a/src/routes/test/cloudron-test.js +++ b/src/routes/test/cloudron-test.js @@ -189,7 +189,6 @@ describe('Cloudron', function () { expect(result.statusCode).to.equal(200); expect(result.body.apiServerOrigin).to.eql('http://localhost:6060'); expect(result.body.webServerOrigin).to.eql(null); - expect(result.body.fqdn).to.eql(config.fqdn()); expect(result.body.adminFqdn).to.eql(config.adminFqdn()); expect(result.body.progress).to.be.an('object'); expect(result.body.update).to.be.an('object'); @@ -211,7 +210,6 @@ describe('Cloudron', function () { expect(result.body.apiServerOrigin).to.eql('http://localhost:6060'); expect(result.body.webServerOrigin).to.eql(null); - expect(result.body.fqdn).to.eql(config.fqdn()); expect(result.body.adminFqdn).to.eql(config.adminFqdn()); expect(result.body.progress).to.be.an('object'); expect(result.body.version).to.eql(config.version()); diff --git a/src/routes/test/domains-test.js b/src/routes/test/domains-test.js index f5d2e8815..4551b7cf4 100644 --- a/src/routes/test/domains-test.js +++ b/src/routes/test/domains-test.js @@ -16,6 +16,7 @@ var SERVER_URL = 'http://localhost:' + config.get('port'); var USERNAME = 'superadmin', PASSWORD = 'Foobar?1337', EMAIL ='silly@me.com'; var token = null; +var DOMAIN = 'example-domains-test.com'; var DOMAIN_0 = { domain: 'cloudron.com', @@ -35,7 +36,7 @@ describe('Domains API', function () { before(function (done) { config._reset(); - config.setFqdn('example-domains-test.com'); + config.setFqdn(DOMAIN); async.series([ server.start.bind(null), @@ -140,11 +141,10 @@ describe('Domains API', function () { .end(function (error, result) { expect(result.statusCode).to.equal(200); expect(result.body.domains).to.be.an(Array); - // includes currently the implicitly added config.fqdn() expect(result.body.domains.length).to.equal(3); expect(result.body.domains[0].domain).to.equal(DOMAIN_0.domain); - expect(result.body.domains[1].domain).to.equal(config.fqdn()); + expect(result.body.domains[1].domain).to.equal(DOMAIN); expect(result.body.domains[2].domain).to.equal(DOMAIN_1.domain); done(); diff --git a/src/routes/test/sysadmin-test.js b/src/routes/test/sysadmin-test.js index ea1203e8c..814933a6f 100644 --- a/src/routes/test/sysadmin-test.js +++ b/src/routes/test/sysadmin-test.js @@ -27,10 +27,11 @@ var appdb = require('../../appdb.js'), var SERVER_URL = 'http://localhost:' + config.get('port'); var USERNAME = 'superadmin', PASSWORD = 'Foobar?1337', EMAIL ='silly@me.com'; +var DOMAIN = 'example-sysadmin-test.com'; function setup(done) { config._reset(); - config.setFqdn('example-sysadmin-test.com'); + config.setFqdn(DOMAIN); config.setVersion('1.2.3'); async.series([ @@ -52,7 +53,7 @@ function setup(done) { function addApp(callback) { var manifest = { version: '0.0.1', manifestVersion: 1, dockerImage: 'foo', healthCheckPath: '/', httpPort: 3, title: 'ok', addons: { } }; - appdb.add('appid', 'appStoreId', manifest, 'location', config.fqdn(), [ ] /* portBindings */, { }, callback); + appdb.add('appid', 'appStoreId', manifest, 'location', DOMAIN, [ ] /* portBindings */, { }, callback); }, function createSettings(callback) { @@ -61,7 +62,7 @@ function setup(done) { s3._mockInject(MockS3); safe.fs.mkdirSync('/tmp/box-sysadmin-test'); - settingsdb.set(settings.BACKUP_CONFIG_KEY, JSON.stringify({ provider: 'caas', token: 'BACKUP_TOKEN', fqdn: config.fqdn(), key: 'key', prefix: 'boxid', format: 'tgz'}), callback); + settingsdb.set(settings.BACKUP_CONFIG_KEY, JSON.stringify({ provider: 'caas', token: 'BACKUP_TOKEN', fqdn: DOMAIN, key: 'key', prefix: 'boxid', format: 'tgz'}), callback); } ], done); } diff --git a/src/test/apps-test.js b/src/test/apps-test.js index 745b61aa4..b1938c37c 100644 --- a/src/test/apps-test.js +++ b/src/test/apps-test.js @@ -236,7 +236,7 @@ describe('Apps', function () { expect(error).to.be(null); expect(app).to.be.ok(); expect(app.iconUrl).to.be(null); - expect(app.fqdn).to.eql(APP_0.location + '.' + config.fqdn()); + expect(app.fqdn).to.eql(APP_0.location + '.' + DOMAIN_0.domain); expect(app.memoryLimit).to.eql(0); done(); }); @@ -248,7 +248,7 @@ describe('Apps', function () { expect(apps).to.be.an(Array); expect(apps[0].id).to.be(APP_0.id); expect(apps[0].iconUrl).to.be(null); - expect(apps[0].fqdn).to.eql(APP_0.location + '.' + config.fqdn()); + expect(apps[0].fqdn).to.eql(APP_0.location + '.' + DOMAIN_0.domain); done(); }); }); diff --git a/src/test/apptask-test.js b/src/test/apptask-test.js index 3cc44f0e1..953554db9 100644 --- a/src/test/apptask-test.js +++ b/src/test/apptask-test.js @@ -22,31 +22,31 @@ var addons = require('../addons.js'), _ = require('underscore'); var MANIFEST = { - "id": "io.cloudron.test", - "author": "The Presidents Of the United States Of America", - "title": "test title", - "description": "test description", - "tagline": "test rocks", - "website": "http://test.cloudron.io", - "contactEmail": "support@cloudron.io", - "version": "0.1.0", - "manifestVersion": 1, - "dockerImage": "cloudron/test:25.2.0", - "healthCheckPath": "/", - "httpPort": 7777, - "tcpPorts": { - "ECHO_SERVER_PORT": { - "title": "Echo Server Port", - "description": "Echo server", - "containerPort": 7778 + 'id': 'io.cloudron.test', + 'author': 'The Presidents Of the United States Of America', + 'title': 'test title', + 'description': 'test description', + 'tagline': 'test rocks', + 'website': 'http://test.cloudron.io', + 'contactEmail': 'support@cloudron.io', + 'version': '0.1.0', + 'manifestVersion': 1, + 'dockerImage': 'cloudron/test:25.2.0', + 'healthCheckPath': '/', + 'httpPort': 7777, + 'tcpPorts': { + 'ECHO_SERVER_PORT': { + 'title': 'Echo Server Port', + 'description': 'Echo server', + 'containerPort': 7778 + } + }, + 'addons': { + 'oauth': { }, + 'redis': { }, + 'mysql': { }, + 'postgresql': { } } - }, - "addons": { - "oauth": { }, - "redis": { }, - "mysql": { }, - "postgresql": { } - } }; const DOMAIN_0 = { @@ -89,7 +89,7 @@ describe('apptask', function () { awsHostedZones = { HostedZones: [{ Id: '/hostedzone/ZONEID', - Name: config.fqdn() + '.', + Name: `${DOMAIN_0.domain}.`, CallerReference: '305AFD59-9D73-4502-B020-F4E6F889CB30', ResourceRecordSetCount: 2, ChangeInfo: { @@ -243,7 +243,7 @@ describe('apptask', function () { .get('/2013-04-01/hostedzone') .times(2) .reply(200, js2xml('ListHostedZonesResponse', awsHostedZones, { wrapHandlers: { HostedZones: () => 'HostedZone'} })) - .get('/2013-04-01/hostedzone/ZONEID/rrset?maxitems=1&name=applocation.' + config.fqdn() + '.&type=A') + .get('/2013-04-01/hostedzone/ZONEID/rrset?maxitems=1&name=applocation.' + DOMAIN_0.domain + '.&type=A') .reply(200, js2xml('ListResourceRecordSetsResponse', { ResourceRecordSets: [ ] }, { 'Content-Type': 'application/xml' })) .post('/2013-04-01/hostedzone/ZONEID/rrset/') .reply(200, js2xml('ChangeResourceRecordSetsResponse', { ChangeInfo: { Id: 'RRID', Status: 'INSYNC' } })); diff --git a/src/test/dns-test.js b/src/test/dns-test.js index a58802c98..ad42955c4 100644 --- a/src/test/dns-test.js +++ b/src/test/dns-test.js @@ -249,7 +249,7 @@ describe('dns provider', function () { .post('/v2/domains/' + config.zoneName() + '/records') .reply(201, { domain_record: DOMAIN_RECORD_2_NEW }); - domains.upsertDNSRecords('', config.fqdn(), 'TXT', [ DOMAIN_RECORD_2_NEW.data, DOMAIN_RECORD_1_NEW.data, DOMAIN_RECORD_3_NEW.data ], function (error, result) { + domains.upsertDNSRecords('', DOMAIN_0.domain, 'TXT', [ DOMAIN_RECORD_2_NEW.data, DOMAIN_RECORD_1_NEW.data, DOMAIN_RECORD_3_NEW.data ], function (error, result) { expect(error).to.eql(null); expect(result).to.eql('3352893'); expect(req1.isDone()).to.be.ok(); @@ -473,7 +473,7 @@ describe('dns provider', function () { } }]); - domains.upsertDNSRecords('', config.fqdn(), 'TXT', [ 'first', 'second', 'third' ], function (error, result) { + domains.upsertDNSRecords('', DOMAIN_0.domain, 'TXT', [ 'first', 'second', 'third' ], function (error, result) { expect(error).to.eql(null); expect(result).to.eql('/change/C2QLKQIWEI0BZF'); expect(awsAnswerQueue.length).to.eql(0); @@ -614,7 +614,7 @@ describe('dns provider', function () { zoneQueue.push([null, [ ]]); // getRecords zoneQueue.push([null, {id: '3'}]); - domains.upsertDNSRecords('', config.fqdn(), 'TXT', [ 'first', 'second', 'third' ], function (error, result) { + domains.upsertDNSRecords('', DOMAIN_0.domain, 'TXT', [ 'first', 'second', 'third' ], function (error, result) { expect(error).to.eql(null); expect(result).to.eql('3'); expect(zoneQueue.length).to.eql(0); diff --git a/src/test/server-test.js b/src/test/server-test.js index 9fa2e53a0..00f06d0a1 100644 --- a/src/test/server-test.js +++ b/src/test/server-test.js @@ -15,6 +15,7 @@ var config = require('../config.js'), server = require('../server.js'); var SERVER_URL = 'http://localhost:' + config.get('port'); +var DOMAIN = 'example-server-test.com'; function cleanup(done) { done(); @@ -25,7 +26,7 @@ describe('Server', function () { before(function () { config._reset(); - config.setFqdn('example-server-test.com'); + config.setFqdn(DOMAIN); config.set('provider', 'notcaas'); // otherwise, cron sets a caas timer for heartbeat causing the test to not quit }); @@ -252,28 +253,4 @@ describe('Server', function () { }); }); }); - - describe('heartbeat', function () { - var successfulHeartbeatGet; - - before(function (done) { - server.start(done); - - var scope = nock(config.apiServerOrigin()); - successfulHeartbeatGet = scope.get('/api/v1/boxes/' + config.fqdn() + '/heartbeat'); - successfulHeartbeatGet.reply(200); - }); - - after(function (done) { - server.stop(done); - nock.cleanAll(); - }); - - it('sends heartbeat', function (done) { - setTimeout(function () { - expect(successfulHeartbeatGet.counter).to.equal(1); - done(); - }, 100); - }); - }); });