2016-04-26 17:07:47 +00:00
|
|
|
/*
|
|
|
|
* This tests if setting an alternate domain works
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var AppStore = require('../appstore.js'),
|
|
|
|
AWS = require('aws-sdk'),
|
|
|
|
Cloudron = require('../cloudron.js'),
|
2016-06-24 03:56:59 +00:00
|
|
|
common = require('../common.js');
|
2016-04-26 17:07:47 +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;
|
|
|
|
var ALT_LOCATION = 'altlocation';
|
|
|
|
|
2016-04-26 18:27:46 +00:00
|
|
|
describe('Alt domain test', function () {
|
2016-04-26 17:07:47 +00:00
|
|
|
this.timeout(0);
|
|
|
|
|
|
|
|
var appStore = new AppStore('https://api.staging.cloudron.io');
|
|
|
|
var route53 = new AWS.Route53({ accessKeyId: process.env.AWS_STAGING_ACCESS_KEY, secretAccessKey: process.env.AWS_STAGING_SECRET_KEY });
|
|
|
|
|
|
|
|
var owner = common.getOwner();
|
|
|
|
var admin = common.getAdmin();
|
|
|
|
var cloudron, appId, box;
|
|
|
|
|
|
|
|
it('can login to the store', function () {
|
|
|
|
var accessToken = appStore.getAccessToken(owner);
|
|
|
|
appStore.setCredentials(owner.password, accessToken);
|
|
|
|
|
|
|
|
var adminAccessToken = appStore.getAccessToken(admin);
|
|
|
|
appStore.setAdminCredentials(admin.password, adminAccessToken);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('can create a cloudron', function () {
|
|
|
|
box = appStore.createCloudron({
|
|
|
|
domain: common.cloudronDomain(__filename),
|
|
|
|
region: 'sfo1',
|
|
|
|
size: '1gb',
|
|
|
|
version: BOX_VERSION
|
|
|
|
});
|
|
|
|
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-02 06:08:38 +00:00
|
|
|
|
|
|
|
it('can enable email', function () {
|
|
|
|
cloudron.setEmailEnabled(true);
|
|
|
|
});
|
2016-04-26 17:07:47 +00:00
|
|
|
|
|
|
|
var location = 'test' + (Math.random() * 10000).toFixed();
|
|
|
|
it('can install app', function () {
|
|
|
|
var manifest = appStore.getManifest(common.TESTAPP_ID, common.TESTAPP_VERSION);
|
|
|
|
appId = cloudron.installApp(location, manifest);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('can populate the addons', function () {
|
2016-04-26 17:11:03 +00:00
|
|
|
cloudron.populateAddons(cloudron.appFqdn(location));
|
2016-04-26 17:07:47 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('can check the addons', function () {
|
2016-04-26 17:11:03 +00:00
|
|
|
cloudron.checkAddons(cloudron.appFqdn(location), owner);
|
2016-04-26 17:07:47 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('can setup cname for altlocation', function (done) {
|
|
|
|
route53.listHostedZonesByName({ DNSName: CUSTOM_DOMAIN, MaxItems: '1'}, function (error, result) {
|
|
|
|
if (error) return done(error);
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
ChangeBatch: {
|
|
|
|
Changes: [{
|
|
|
|
Action: 'UPSERT',
|
|
|
|
ResourceRecordSet: {
|
|
|
|
Type: 'CNAME',
|
|
|
|
Name: ALT_LOCATION + '.' + CUSTOM_DOMAIN + '.',
|
|
|
|
ResourceRecords: [ { Value: cloudron.appFqdn(location) } ],
|
|
|
|
TTL: 1
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
HostedZoneId: result.HostedZones[0].Id
|
|
|
|
};
|
|
|
|
|
|
|
|
route53.changeResourceRecordSets(params, function(error) {
|
|
|
|
if (error) return done(error);
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('can configure app to alt location', function () {
|
|
|
|
cloudron.configureApp(appId, location, ALT_LOCATION + '.' + CUSTOM_DOMAIN);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('can check the addons', function () {
|
2016-04-26 17:11:31 +00:00
|
|
|
cloudron.checkAddons(ALT_LOCATION + '.' + CUSTOM_DOMAIN, owner);
|
2016-04-26 17:07:47 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('can reboot the cloudron', function () {
|
|
|
|
cloudron.reboot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('can check the addons', function () {
|
2016-04-26 17:11:31 +00:00
|
|
|
cloudron.checkAddons(ALT_LOCATION + '.' + CUSTOM_DOMAIN, owner);
|
2016-04-26 17:07:47 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('can uninstall app', function () {
|
|
|
|
cloudron.uninstallApp(appId);
|
|
|
|
});
|
|
|
|
|
2016-04-30 16:48:52 +00:00
|
|
|
it('can delete cname for altlocation', function (done) {
|
|
|
|
route53.listHostedZonesByName({ DNSName: CUSTOM_DOMAIN, MaxItems: '1'}, function (error, result) {
|
|
|
|
if (error) return done(error);
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
ChangeBatch: {
|
|
|
|
Changes: [{
|
|
|
|
Action: 'DELETE',
|
|
|
|
ResourceRecordSet: {
|
|
|
|
Type: 'CNAME',
|
|
|
|
Name: ALT_LOCATION + '.' + CUSTOM_DOMAIN + '.',
|
|
|
|
ResourceRecords: [ { Value: cloudron.appFqdn(location) } ],
|
|
|
|
TTL: 1
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
HostedZoneId: result.HostedZones[0].Id
|
|
|
|
};
|
|
|
|
|
|
|
|
route53.changeResourceRecordSets(params, function(error) {
|
|
|
|
if (error) return done(error);
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-04-26 17:07:47 +00:00
|
|
|
it('can delete the cloudron', function () {
|
|
|
|
appStore.deleteCloudron(box);
|
|
|
|
});
|
|
|
|
});
|