90 lines
2.4 KiB
JavaScript
90 lines
2.4 KiB
JavaScript
/*
|
|
* This tests installation of appBundle
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
var AppStore = require('../appstore.js'),
|
|
assert = require('assert'),
|
|
async = require('async'),
|
|
Cloudron = require('../cloudron.js'),
|
|
common = require('../common.js'),
|
|
dns = require('dns'),
|
|
request = require('superagent-sync'),
|
|
sleep = require('sleep').sleep;
|
|
|
|
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);
|
|
});
|
|
});
|