2016-04-20 22:11:52 +00:00
|
|
|
/*
|
|
|
|
* This tests installation of appBundle
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var AppStore = require('../appstore.js'),
|
2016-04-20 23:24:46 +00:00
|
|
|
assert = require('assert'),
|
2016-04-20 22:11:52 +00:00
|
|
|
Cloudron = require('../cloudron.js'),
|
|
|
|
common = require('../common.js'),
|
2016-04-20 22:50:32 +00:00
|
|
|
request = require('superagent-sync'),
|
2016-06-30 14:18:10 +00:00
|
|
|
sleep = require('../shell.js').sleep;
|
2016-04-20 22:11:52 +00:00
|
|
|
|
|
|
|
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();
|
2016-06-30 14:18:10 +00:00
|
|
|
var cloudron, box;
|
2016-04-20 22:11:52 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|