'use strict'; var debug = require('debug')('e2e:common'), path = require('path'), safe = require('safetydance'), util = require('util'), _ = require('underscore'); exports = module.exports = { TESTAPP_ID: 'io.cloudron.testapp', PREV_TESTAPP_VERSION : '9.0.0', TESTAPP_VERSION : '10.0.0', cloudronDomain: cloudronDomain, verifyResponse2: verifyResponse2, getOwner: getOwner, getAdmin: getAdmin, stripeSecret: stripeSecret, stripUnreachable: stripUnreachable }; var gEcosystem = safe.require(path.join(__dirname, '../secrets/e2e-test/ecosystem-staging.json')); function cloudronDomain(filename) { return 't' + path.basename(filename.replace(/-/g,''), 'test.js') + '.selfhost.io'; } function stripUnreachable(releases) { var reachableVersions = [ ]; var curVersion = '0.0.1'; while (true) { reachableVersions.push(curVersion); var nextVersion = releases[curVersion].next; if (!nextVersion) break; curVersion = nextVersion; } return _.pick(releases, reachableVersions); } function verifyResponse2(res, args) { if (res.statusCode < 200 || res.statusCode > 399) { debug('Response error statusCode:%s error:%s body:%j', res.statusCode, res.error, res.body); var errorMessage = util.format.apply(util, Array.prototype.slice.call(arguments, 1)); debug(errorMessage.red); throw new Error(errorMessage); } } function getOwner() { return { username: process.env.APPSTORE_USERNAME || gEcosystem.env.APPSTORE_USERNAME, password: process.env.APPSTORE_PASSWORD || gEcosystem.env.APPSTORE_PASSWORD, email: process.env.APPSTORE_EMAIL || gEcosystem.env.APPSTORE_EMAIL }; } function getAdmin() { return { username: process.env.APPSTORE_ADMIN_USERNAME || gEcosystem.env.APPSTORE_ADMIN_USERNAME, password: process.env.APPSTORE_ADMIN_PASSWORD || gEcosystem.env.APPSTORE_ADMIN_PASSWORD, email: process.env.APPSTORE_ADMIN_EMAIL || gEcosystem.env.APPSTORE_ADMIN_EMAIL }; } function stripeSecret() { return process.env.STRIPE_SECRET || gEcosystem.env.STRIPE_SECRET; }