Add test for alt-domain
This commit is contained in:
parent
bee818e13a
commit
21ec8797cc
@ -182,8 +182,12 @@ Cloudron.prototype.installApp = function (location, manifest, cloudronVersion) {
|
||||
return appId;
|
||||
};
|
||||
|
||||
Cloudron.prototype.configureApp = function (appId, newLocation) {
|
||||
var res = request.post(this._origin + '/api/v1/apps/' + appId + '/configure').query({ access_token: this._credentials.accessToken }).send({ location: newLocation, accessRestriction: null, oauthProxy: false, password: this._credentials.password }).end();
|
||||
Cloudron.prototype.configureApp = function (appId, newLocation, altDomain /* optional */) {
|
||||
var data = { location: newLocation, accessRestriction: null, oauthProxy: false, password: this._credentials.password };
|
||||
|
||||
if (altDomain) data.altDomain = altDomain;
|
||||
|
||||
var res = request.post(this._origin + '/api/v1/apps/' + appId + '/configure').query({ access_token: this._credentials.accessToken }).send(data).end();
|
||||
common.verifyResponse2xx(res, 'App could not be configured');
|
||||
|
||||
console.log('App moved to different location'.green);
|
||||
|
@ -18,7 +18,7 @@ if ! ./node_modules/.bin/mocha --bail test/before.js > "logs/before.log" 2>&1; t
|
||||
fi
|
||||
|
||||
# run tests
|
||||
readonly tests=(app-flow-test app-update-test cloudron-button-test cloudron-user-test new-user-test cloudron-backup-test custom-domain-test cloudron-update-sfo1-test cloudron-update-ams3-test)
|
||||
readonly tests=(app-flow-test app-update-test alt-domain-test cloudron-button-test cloudron-user-test new-user-test cloudron-backup-test custom-domain-test cloudron-update-sfo1-test cloudron-update-ams3-test)
|
||||
for t in "${tests[@]}"; do
|
||||
./node_modules/.bin/mocha --bail "test/${t}.js" > "logs/${t}.log" 2>&1 &
|
||||
test_pids+=("$!")
|
||||
|
124
test/alt-domain-test.js
Normal file
124
test/alt-domain-test.js
Normal file
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* This tests if setting an alternate domain works
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var AppStore = require('../appstore.js'),
|
||||
assert = require('assert'),
|
||||
async = require('async'),
|
||||
AWS = require('aws-sdk'),
|
||||
Cloudron = require('../cloudron.js'),
|
||||
common = require('../common.js'),
|
||||
request = require('superagent-sync');
|
||||
|
||||
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';
|
||||
|
||||
describe('Custom domain test', function () {
|
||||
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);
|
||||
});
|
||||
|
||||
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 () {
|
||||
cloudron.populateAddons(location);
|
||||
});
|
||||
|
||||
it('can check the addons', function () {
|
||||
cloudron.checkAddons(location, owner);
|
||||
});
|
||||
|
||||
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 () {
|
||||
cloudron.checkAddons(location, owner);
|
||||
});
|
||||
|
||||
it('can reboot the cloudron', function () {
|
||||
cloudron.reboot();
|
||||
});
|
||||
|
||||
it('can check the addons', function () {
|
||||
cloudron.checkAddons(location, owner);
|
||||
});
|
||||
|
||||
it('can uninstall app', function () {
|
||||
cloudron.uninstallApp(appId);
|
||||
});
|
||||
|
||||
it('can delete the cloudron', function () {
|
||||
appStore.deleteCloudron(box);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user