cloudron-e2e-test/test/cloudron-migrate-test.js

220 lines
6.7 KiB
JavaScript
Raw Normal View History

2015-12-17 21:58:49 +00:00
/*
* This tests a flow for cloudron owner creating a cloudron
* with a custom domain from the appstore. Owner creates a cloudron, activates
2017-01-28 09:56:16 +00:00
* it, installs an app. The cloudron then updates and we check if box updated
* correctly. It deletes the cloudron eventually.
2016-05-19 00:46:42 +00:00
*
2015-12-17 21:58:49 +00:00
*/
'use strict';
var AppStore = require('../appstore.js'),
2015-12-18 04:41:54 +00:00
assert = require('assert'),
2015-12-17 21:58:49 +00:00
async = require('async'),
Cloudron = require('../cloudron.js'),
common = require('../common.js'),
2017-01-28 09:55:13 +00:00
mailer = require('../mailer.js'),
request = require('superagent-sync'),
semver = require('semver'),
sleep = require('../shell.js').sleep;
2015-12-17 21:58:49 +00:00
require('colors');
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
var BOX_VERSION = process.env.BOX_VERSION;
var CUSTOM_DOMAIN = process.env.CUSTOM_DOMAIN;
2015-12-18 05:25:20 +00:00
describe('Custom domain test', function () {
2015-12-17 21:58:49 +00:00
this.timeout(0);
var appStore = new AppStore('https://api.staging.cloudron.io');
var owner = common.getOwner();
var admin = common.getAdmin();
2017-01-28 09:55:13 +00:00
var cloudron, appId, box, backupInfo, nextVersion;
it('can query versions', function () {
var res = request.get('https://s3.amazonaws.com/staging-cloudron-releases/versions.json').end();
common.verifyResponse2xx(res);
var boxVersions = Object.keys(common.stripUnreachable(res.body)).sort(semver.rcompare);
var curVersion = boxVersions[1];
assert.strictEqual(curVersion, BOX_VERSION);
nextVersion = boxVersions[0];
});
2015-12-17 21:58:49 +00:00
it('can login to the store', function () {
var accessToken = appStore.getAccessToken(owner);
appStore.setCredentials(owner.password, accessToken);
var adminAccessToken = appStore.getAccessToken(admin);
2015-12-18 16:31:22 +00:00
appStore.setAdminCredentials(admin.password, adminAccessToken);
2015-12-17 21:58:49 +00:00
});
it('can get profile', function () {
var profile = appStore.getProfile();
owner.id = profile.id;
});
it('can setup billing details', function (done) {
appStore.setupBilling(owner, done);
});
it('can create a cloudron', function () {
box = appStore.createCloudron({
2016-07-08 22:22:30 +00:00
domain: common.cloudronDomain(__filename),
2016-06-29 17:21:18 +00:00
region: 'ams2',
size: '1gb',
2015-12-17 21:58:49 +00:00
version: BOX_VERSION
});
});
it('can wait for cloudron', function () {
box = appStore.waitForCloudron(box.id);
cloudron = new Cloudron(box);
});
it('can activate the box', function () {
cloudron.activate(owner);
});
it('can login to the box', function () {
var token = cloudron.getOauthToken(owner);
cloudron.setCredentials(owner.password, token);
});
2016-09-01 16:03:27 +00:00
it('can enable email', function () {
cloudron.setEmailEnabled(true);
});
2016-07-08 22:22:30 +00:00
it('can migrate cloudron to custom domain', function () {
cloudron.migrate({
domain: CUSTOM_DOMAIN,
provider: 'route53',
accessKeyId: process.env.AWS_STAGING_ACCESS_KEY,
secretAccessKey: process.env.AWS_STAGING_SECRET_KEY
});
});
it('can wait for cloudron', function () {
box = appStore.waitForCloudron(box.id);
cloudron = new Cloudron(box);
});
2016-07-08 22:54:21 +00:00
it('can login to the box', function () {
var token = cloudron.getOauthToken(owner);
cloudron.setCredentials(owner.password, token);
});
2016-05-19 00:46:42 +00:00
it('send mail to cloudron user', function (done) {
mailer.sendMailToCloudronUser(owner.username + '@' + CUSTOM_DOMAIN, done);
});
2016-07-08 22:22:30 +00:00
it('can set dns credentials again', function () {
2015-12-18 02:36:31 +00:00
cloudron.setDnsConfig({ provider: 'route53', accessKeyId: process.env.AWS_STAGING_ACCESS_KEY, secretAccessKey: process.env.AWS_STAGING_SECRET_KEY });
});
2015-12-18 04:41:54 +00:00
var location = 'test' + (Math.random() * 10000).toFixed();
2015-12-17 21:58:49 +00:00
it('can install app', function () {
2015-12-18 04:41:54 +00:00
var manifest = appStore.getManifest(common.TESTAPP_ID, common.TESTAPP_VERSION);
2015-12-17 21:58:49 +00:00
appId = cloudron.installApp(location, manifest);
});
2015-12-18 04:41:54 +00:00
it('can populate the addons', function () {
cloudron.populateAddons(cloudron.appFqdn(location));
2015-12-18 04:41:54 +00:00
});
it('can check the addons', function () {
cloudron.checkAddons(cloudron.appFqdn(location), owner);
2015-12-18 04:41:54 +00:00
});
it('can backup the box', function () {
backupInfo = cloudron.backup();
2016-04-20 22:06:59 +00:00
assert.strictEqual(backupInfo.dependsOn.length, 1);
2015-12-18 04:41:54 +00:00
});
it('can restore the box', function () {
2017-04-24 18:48:50 +00:00
appStore.restore(box.id, backupInfo.id + '.tar.gz.enc');
2015-12-18 04:41:54 +00:00
box = appStore.waitForCloudron(box.id);
});
2015-12-18 05:16:07 +00:00
it('wait for app to be ready', function () {
cloudron.waitForApp(appId);
});
2015-12-17 21:58:49 +00:00
it('can configure app', function () {
location = location + 'x';
cloudron.configureApp(appId, location);
});
2015-12-18 04:41:54 +00:00
it('can check the addons', function () {
2016-04-26 17:34:26 +00:00
cloudron.checkAddons(cloudron.appFqdn(location), owner);
2015-12-18 04:41:54 +00:00
});
it('can reboot the cloudron', function () {
cloudron.reboot();
});
it('can check the addons', function () {
2016-04-26 17:34:26 +00:00
cloudron.checkAddons(cloudron.appFqdn(location), owner);
2015-12-18 04:41:54 +00:00
});
2017-01-13 03:18:12 +00:00
it('can check dnsbl', function () {
cloudron.checkDnsbl(cloudron.appFqdn(location));
});
2016-07-08 22:22:30 +00:00
it('can migrate to bigger size', function () {
cloudron.migrate({ size: '2gb' });
});
it('can wait for cloudron', function () {
box = appStore.waitForCloudron(box.id);
cloudron = new Cloudron(box);
});
2016-07-08 22:54:21 +00:00
it('can login to the box', function () {
var token = cloudron.getOauthToken(owner);
cloudron.setCredentials(owner.password, token);
});
2016-07-08 22:22:30 +00:00
it('can check the addons', function () {
cloudron.checkAddons(cloudron.appFqdn(location), owner);
});
2017-01-28 09:55:13 +00:00
it('can update to new version', function () {
console.log('Wait for cloudron to get the update to ' + nextVersion);
cloudron.checkForUpdates();
sleep(60 * 2);
cloudron.update(nextVersion);
});
it('runs the app', function () {
cloudron.waitForApp(appId);
});
it('can check the addons', function () {
cloudron.checkAddons(cloudron.appFqdn(location), owner);
});
2015-12-17 21:58:49 +00:00
it('can uninstall app', function () {
cloudron.uninstallApp(appId);
});
2016-05-19 00:46:42 +00:00
it('can check mail', function (done) {
cloudron.checkMail(owner, done);
});
2015-12-17 21:58:49 +00:00
// check this after activation
it('has setup DNS records correctly', function (done) {
async.series([
2015-12-18 04:41:54 +00:00
// cloudron.checkA.bind(cloudron), // this is at user's discretion
2015-12-17 21:58:49 +00:00
cloudron.checkSPF.bind(cloudron),
cloudron.checkDKIM.bind(cloudron),
2016-05-18 06:31:50 +00:00
cloudron.checkMX.bind(cloudron),
2015-12-18 16:19:37 +00:00
// cloudron.checkDMARC.bind(cloudron)
2015-12-17 21:58:49 +00:00
], done);
});
it('can delete the cloudron', function () {
appStore.deleteCloudron(box);
});
});