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

189 lines
5.6 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
* it, installs and app and 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'),
2016-05-19 00:46:42 +00:00
mailer = require('../mailer.js');
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();
2015-12-18 04:41:54 +00:00
var cloudron, appId, box, backupInfo;
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);
sleep(20); // sometime for the mail container to come up
});
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 () {
2016-04-05 00:02:21 +00:00
appStore.restore(box.id, backupInfo.id);
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
});
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);
});
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);
});
});