From ab2632436410eea727b5125a048973caa6e8e865 Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Tue, 13 Sep 2016 10:19:18 +0200 Subject: [PATCH] Use the selfhosting domains from the ecosystem --- appstore.js | 2 +- cloudron.js | 2 +- test/new-user-test.js | 4 ++-- test/selfhost-digitalocean-test.js | 26 ++++++++++++++------------ test/selfhost-ec2-test.js | 20 +++++++++++--------- 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/appstore.js b/appstore.js index eaec6e5..d13871a 100644 --- a/appstore.js +++ b/appstore.js @@ -9,7 +9,7 @@ var common = require('./common.js'), exports = module.exports = AppStore; function AppStore(origin) { - this._origin = origin; + this._origin = origin || process.env.APPSTORE_API_ORIGIN; // credentials for api calls this._credentials = { diff --git a/cloudron.js b/cloudron.js index 12ea3e6..3ba069d 100644 --- a/cloudron.js +++ b/cloudron.js @@ -32,7 +32,7 @@ function Cloudron(box) { } Cloudron.prototype._setDomain = function (domain) { - this._isCustomDomain = domain === process.env.CUSTOM_DOMAIN || domain === process.env.SELFHOST_DOMAIN; + this._isCustomDomain = domain === process.env.CUSTOM_DOMAIN || domain === process.env.EC2_SELFHOST_DOMAIN || domain === process.env.DO_SELFHOST_DOMAIN; this._adminFqdn = this._isCustomDomain ? 'my.' + domain : 'my-' + domain; this._origin = this._isCustomDomain ? 'https://my.' + domain : 'https://my-' + domain; }; diff --git a/test/new-user-test.js b/test/new-user-test.js index d59ecca..dd4cb8a 100644 --- a/test/new-user-test.js +++ b/test/new-user-test.js @@ -22,7 +22,7 @@ var BOX_VERSION = process.env.BOX_VERSION; describe('Appstore new user flow', function () { this.timeout(0); - var appStore = new AppStore('https://api.staging.cloudron.io'); + var appStore = new AppStore(); var owner = common.getOwner(); var admin = common.getAdmin(); @@ -32,7 +32,7 @@ describe('Appstore new user flow', function () { user: process.env.IMAP_USERNAME, password: process.env.IMAP_PASSWORD, host: process.env.IMAP_HOST, - port: 993, // imap port + port: 993, // imap port tls: true, readOnly: true }); diff --git a/test/selfhost-digitalocean-test.js b/test/selfhost-digitalocean-test.js index 2e1fc7c..f6a01a2 100644 --- a/test/selfhost-digitalocean-test.js +++ b/test/selfhost-digitalocean-test.js @@ -1,6 +1,8 @@ /* - * This tests a flow for cloudron owner creating a selfhosted cloudron on ec2 + * + * This tests a flow for cloudron owner creating a selfhosted cloudron on digitalocean * Owner creates a cloudron, activates it, installs and app and deletes the cloudron eventually + * We use a us-east-1 (US standard) backup bucket here * */ @@ -23,14 +25,14 @@ require('colors'); process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; const BOX_VERSION = process.env.BOX_VERSION; -const SELFHOST_DOMAIN = 'smartserver.io'; +const DO_SELFHOST_DOMAIN = process.env.DO_SELFHOST_DOMAIN; const SSH_KEY = 'id_rsa_e2e_selfhost'; const DO_TYPE = '1gb'; -const DO_REGION = 'ams2'; +const DO_REGION = 'nyc3'; const DO_TOKEN = process.env.DIGITAL_OCEAN_TOKEN_STAGING; -const EC2_REGION = 'eu-central-1'; +const EC2_REGION = 'us-east-1'; const BACKUP_KEY = 'somesecret'; -const BACKUP_BUCKET = 'selfhost-test'; +const BACKUP_BUCKET = 'selfhost-test-' + EC2_REGION; const AWS_ACCESS_KEY = process.env.AWS_STAGING_ACCESS_KEY; const AWS_ACCESS_SECRET = process.env.AWS_STAGING_SECRET_KEY; @@ -54,7 +56,7 @@ function machine(args, options) { describe('Selfhost DigitalOcean Cloudron creation', function () { this.timeout(0); - var appStore = new AppStore('https://api.staging.cloudron.io'); + var appStore = new AppStore(); var owner = common.getOwner(); var cloudron, appId, backupInfo, instanceId, restoreInstanceId, migrateInstanceId; @@ -74,7 +76,7 @@ describe('Selfhost DigitalOcean Cloudron creation', function () { it('can create a cloudron', function () { var params = [ - '--fqdn ' + SELFHOST_DOMAIN, + '--fqdn ' + DO_SELFHOST_DOMAIN, '--type ' + DO_TYPE, '--token ' + DO_TOKEN, '--region ' + DO_REGION, @@ -100,7 +102,7 @@ describe('Selfhost DigitalOcean Cloudron creation', function () { console.log('New instance created with ID', instanceId); cloudron = new Cloudron({ - domain: SELFHOST_DOMAIN, + domain: DO_SELFHOST_DOMAIN, setupToken: null, version: toVersion, ip: null @@ -127,7 +129,7 @@ describe('Selfhost DigitalOcean Cloudron creation', function () { }); it('send mail to cloudron user', function (done) { - mailer.sendMailToCloudronUser(owner.username + '@' + SELFHOST_DOMAIN, done); + mailer.sendMailToCloudronUser(owner.username + '@' + DO_SELFHOST_DOMAIN, done); }); it('did receive mail', function (done) { @@ -152,7 +154,7 @@ describe('Selfhost DigitalOcean Cloudron creation', function () { cloudron.checkForUpdates(); var params = [ - SELFHOST_DOMAIN, + DO_SELFHOST_DOMAIN, '--yes', '--ssh-key ' + SSH_KEY, '--username ' + owner.username, @@ -203,7 +205,7 @@ describe('Selfhost DigitalOcean Cloudron creation', function () { it('can restore the box', function () { var params = [ - '--fqdn ' + SELFHOST_DOMAIN, + '--fqdn ' + DO_SELFHOST_DOMAIN, // THOSE SHOULD BE STASHED IN THE CONFIG // '--type ' + DO_TYPE, // '--token ' + DO_TOKEN, @@ -240,7 +242,7 @@ describe('Selfhost DigitalOcean Cloudron creation', function () { it('can migrate cloudron', function () { var params = [ - '--fqdn ' + SELFHOST_DOMAIN, + '--fqdn ' + DO_SELFHOST_DOMAIN, // THOSE SHOULD BE STASHED IN THE CONFIG // '--token ' + DO_TOKEN, // '--ssh-key ' + SSH_KEY diff --git a/test/selfhost-ec2-test.js b/test/selfhost-ec2-test.js index 918d5f8..2e42207 100644 --- a/test/selfhost-ec2-test.js +++ b/test/selfhost-ec2-test.js @@ -1,6 +1,8 @@ /* + * * This tests a flow for cloudron owner creating a selfhosted cloudron on ec2 * Owner creates a cloudron, activates it, installs and app and deletes the cloudron eventually + * We use a eu-central-1 backup bucket here * */ @@ -22,7 +24,7 @@ require('colors'); process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; const BOX_VERSION = process.env.BOX_VERSION; -const SELFHOST_DOMAIN = 'cloudron.club'; +const EC2_SELFHOST_DOMAIN = process.env.EC2_SELFHOST_DOMAIN; const EC2_TYPE = 't2.small'; const EC2_SIZE = 30; const EC2_REGION = 'eu-central-1'; @@ -30,7 +32,7 @@ const EC2_SSH_KEY = 'id_rsa_e2e_selfhost'; const EC2_SUBNET = 'subnet-801402e9'; const EC2_SECURITY_GROUP = 'sg-b9a473d1'; const BACKUP_KEY = 'somesecret'; -const BACKUP_BUCKET = 'selfhost-test'; +const BACKUP_BUCKET = 'selfhost-test-' + EC2_REGION; const AWS_ACCESS_KEY = process.env.AWS_STAGING_ACCESS_KEY; const AWS_ACCESS_SECRET = process.env.AWS_STAGING_SECRET_KEY; @@ -54,7 +56,7 @@ function machine(args, options) { describe('Selfhost EC2 Cloudron creation', function () { this.timeout(0); - var appStore = new AppStore('https://api.staging.cloudron.io'); + var appStore = new AppStore(); var ec2 = new AWS.EC2({ accessKeyId: AWS_ACCESS_KEY, secretAccessKey: AWS_ACCESS_SECRET, region: EC2_REGION }); var owner = common.getOwner(); @@ -75,7 +77,7 @@ describe('Selfhost EC2 Cloudron creation', function () { it('can create a cloudron', function () { var params = [ - '--fqdn ' + SELFHOST_DOMAIN, + '--fqdn ' + EC2_SELFHOST_DOMAIN, '--type ' + EC2_TYPE, '--disk-size ' + EC2_SIZE, '--region ' + EC2_REGION, @@ -102,7 +104,7 @@ describe('Selfhost EC2 Cloudron creation', function () { console.log('New instance created with ID', instanceId); cloudron = new Cloudron({ - domain: SELFHOST_DOMAIN, + domain: EC2_SELFHOST_DOMAIN, setupToken: null, version: toVersion, ip: null @@ -129,7 +131,7 @@ describe('Selfhost EC2 Cloudron creation', function () { }); it('send mail to cloudron user', function (done) { - mailer.sendMailToCloudronUser(owner.username + '@' + SELFHOST_DOMAIN, done); + mailer.sendMailToCloudronUser(owner.username + '@' + EC2_SELFHOST_DOMAIN, done); }); it('did receive mail', function (done) { @@ -154,7 +156,7 @@ describe('Selfhost EC2 Cloudron creation', function () { cloudron.checkForUpdates(); var params = [ - SELFHOST_DOMAIN, + EC2_SELFHOST_DOMAIN, '--yes', '--ssh-key ' + EC2_SSH_KEY, '--username ' + owner.username, @@ -205,7 +207,7 @@ describe('Selfhost EC2 Cloudron creation', function () { it('can restore the box', function () { var params = [ - '--fqdn ' + SELFHOST_DOMAIN, + '--fqdn ' + EC2_SELFHOST_DOMAIN, '--type ' + EC2_TYPE, '--disk-size ' + EC2_SIZE, '--region ' + EC2_REGION, @@ -242,7 +244,7 @@ describe('Selfhost EC2 Cloudron creation', function () { it('can migrate cloudron', function () { var params = [ - '--fqdn ' + SELFHOST_DOMAIN, + '--fqdn ' + EC2_SELFHOST_DOMAIN, '--ssh-key ' + EC2_SSH_KEY, '--access-key-id ' + AWS_ACCESS_KEY, '--secret-access-key ' + AWS_ACCESS_SECRET,