test app bundle

This commit is contained in:
Girish Ramakrishnan 2016-04-20 15:11:52 -07:00
parent f3eeec7944
commit e00b39dac7
2 changed files with 88 additions and 1 deletions

View File

@ -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-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 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+=("$!")

View File

@ -0,0 +1,87 @@
/*
* This tests installation of appBundle
*/
'use strict';
var AppStore = require('../appstore.js'),
async = require('async'),
Cloudron = require('../cloudron.js'),
common = require('../common.js'),
dns = require('dns'),
request = require('superagent-sync');
require('colors');
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
var BOX_VERSION = process.env.BOX_VERSION;
describe('Appstore button', function () {
this.timeout(0);
var appStore = new AppStore('https://api.staging.cloudron.io');
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 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({
domain: common.cloudronDomain(__filename),
region: 'sfo1',
size: '1gb',
version: BOX_VERSION,
appBundle: [ { appstoreId: 'com.hastebin.cloudronapp', location: 'haste' } ]
});
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);
});
it('can access the appBundle app', function () {
process.stdout.write('Waiting for app to come up.');
var res;
for (var i = 0; i < 40; ++i) {
sleep(10);
process.stdout.write('.');
res = request.get('https://haste' + '-' + box.domain).end();
if (res.statusCode === 200) {
console.log();
break;
}
}
assert.strictEqual(res.statusCode, 200);
});
it('can delete the cloudron', function () {
appStore.deleteCloudron(box);
});
});