even more constness
This commit is contained in:
@@ -29,14 +29,14 @@ const apps = require('../../apps.js'),
|
||||
tokens = require('../../tokens.js'),
|
||||
url = require('url');
|
||||
|
||||
var SERVER_URL = 'http://localhost:' + constants.PORT;
|
||||
const SERVER_URL = 'http://localhost:' + constants.PORT;
|
||||
|
||||
const docker = new Docker({ socketPath: '/var/run/docker.sock' });
|
||||
|
||||
// Test image information
|
||||
var TEST_IMAGE_REPO = 'docker.io/cloudron/io.cloudron.testapp';
|
||||
var TEST_IMAGE_TAG = '20201121-223249-985e86ebb';
|
||||
var TEST_IMAGE = TEST_IMAGE_REPO + ':' + TEST_IMAGE_TAG;
|
||||
const TEST_IMAGE_REPO = 'docker.io/cloudron/io.cloudron.testapp';
|
||||
const TEST_IMAGE_TAG = '20201121-223249-985e86ebb';
|
||||
const TEST_IMAGE = TEST_IMAGE_REPO + ':' + TEST_IMAGE_TAG;
|
||||
|
||||
const DOMAIN_0 = {
|
||||
domain: 'example-apps-test.com',
|
||||
@@ -48,11 +48,12 @@ const DOMAIN_0 = {
|
||||
tlsConfig: { provider: 'fallback' }
|
||||
};
|
||||
|
||||
var APP_STORE_ID = 'test', APP_ID;
|
||||
var APP_SUBDOMAIN = 'appssubdomain';
|
||||
var APP_SUBDOMAIN_NEW = 'appssubdomainnew';
|
||||
const APP_STORE_ID = 'test';
|
||||
let APP_ID;
|
||||
const APP_SUBDOMAIN = 'appssubdomain';
|
||||
const APP_SUBDOMAIN_NEW = 'appssubdomainnew';
|
||||
|
||||
var APP_MANIFEST = JSON.parse(fs.readFileSync(__dirname + '/../../../../test-app/CloudronManifest.json', 'utf8'));
|
||||
const APP_MANIFEST = JSON.parse(fs.readFileSync(__dirname + '/../../../../test-app/CloudronManifest.json', 'utf8'));
|
||||
APP_MANIFEST.dockerImage = TEST_IMAGE;
|
||||
|
||||
const USERNAME = 'superadmin';
|
||||
@@ -62,17 +63,17 @@ const EMAIL ='admin@me.com';
|
||||
const USER_1_APPSTORE_TOKEN = 'appstoretoken';
|
||||
const USERNAME_1 = 'user';
|
||||
const EMAIL_1 ='user@me.com';
|
||||
var user_1_id = null;
|
||||
const user_1_id = null;
|
||||
|
||||
// authentication token
|
||||
var token = null;
|
||||
var token_1 = null;
|
||||
const token = null;
|
||||
const token_1 = null;
|
||||
|
||||
let KEY, CERT;
|
||||
let appstoreIconServer = hock.createHock({ throwOnUnmatched: false });
|
||||
|
||||
function checkRedis(containerId, done) {
|
||||
var redisIp, exportedRedisPort;
|
||||
let redisIp, exportedRedisPort;
|
||||
|
||||
docker.getContainer(containerId).inspect(function (error, data) {
|
||||
expect(error).to.not.be.ok();
|
||||
@@ -191,7 +192,7 @@ function startBox(done) {
|
||||
.get('/api/v1/apps/' + APP_STORE_ID + '/versions/' + APP_MANIFEST.version + '/icon')
|
||||
.replyWithFile(200, path.resolve(__dirname, '../../../assets/avatar.png'));
|
||||
|
||||
var port = parseInt(url.parse(settings.apiServerOrigin()).port, 10);
|
||||
const port = parseInt(url.parse(settings.apiServerOrigin()).port, 10);
|
||||
http.createServer(appstoreIconServer.handler).listen(port, callback);
|
||||
},
|
||||
|
||||
@@ -384,7 +385,7 @@ xdescribe('App API', function () {
|
||||
});
|
||||
|
||||
it('app install fails because manifest download fails', function (done) {
|
||||
var fake = nock(settings.apiServerOrigin()).get('/api/v1/apps/test').reply(404, {});
|
||||
const fake = nock(settings.apiServerOrigin()).get('/api/v1/apps/test').reply(404, {});
|
||||
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/install')
|
||||
.query({ access_token: token })
|
||||
@@ -397,7 +398,7 @@ xdescribe('App API', function () {
|
||||
});
|
||||
|
||||
it('app install fails due to purchase failure', function (done) {
|
||||
var fake1 = nock(settings.apiServerOrigin()).get('/api/v1/apps/test').reply(200, { manifest: APP_MANIFEST });
|
||||
const fake1 = nock(settings.apiServerOrigin()).get('/api/v1/apps/test').reply(200, { manifest: APP_MANIFEST });
|
||||
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/install')
|
||||
.query({ access_token: token })
|
||||
@@ -410,8 +411,8 @@ xdescribe('App API', function () {
|
||||
});
|
||||
|
||||
it('app install succeeds with purchase', async function () {
|
||||
var fake1 = nock(settings.apiServerOrigin()).get('/api/v1/apps/' + APP_STORE_ID).reply(200, { manifest: APP_MANIFEST });
|
||||
var fake2 = nock(settings.apiServerOrigin()).post(function (uri) { return uri.indexOf('/api/v1/cloudronapps') >= 0; }, (body) => body.appstoreId === APP_STORE_ID && body.manifestId === APP_MANIFEST.id && body.appId).reply(201, { });
|
||||
const fake1 = nock(settings.apiServerOrigin()).get('/api/v1/apps/' + APP_STORE_ID).reply(200, { manifest: APP_MANIFEST });
|
||||
const fake2 = nock(settings.apiServerOrigin()).post(function (uri) { return uri.indexOf('/api/v1/cloudronapps') >= 0; }, (body) => body.appstoreId === APP_STORE_ID && body.manifestId === APP_MANIFEST.id && body.appId).reply(201, { });
|
||||
|
||||
await settings.setAppstoreApiToken(USER_1_APPSTORE_TOKEN);
|
||||
|
||||
@@ -549,7 +550,7 @@ xdescribe('App API', function () {
|
||||
});
|
||||
|
||||
xit('tcp port mapping works', function (done) {
|
||||
var client = net.connect(7171);
|
||||
const client = net.connect(7171);
|
||||
client.on('data', function (data) {
|
||||
expect(data.toString()).to.eql('ECHO_SERVER_PORT=7171');
|
||||
done();
|
||||
@@ -586,7 +587,7 @@ xdescribe('App API', function () {
|
||||
.query({ access_token: token })
|
||||
.buffer(false)
|
||||
.end(function (err, res) {
|
||||
var data = '';
|
||||
const data = '';
|
||||
res.on('data', function (d) { data += d.toString('utf8'); });
|
||||
res.on('end', function () {
|
||||
expect(data.length).to.not.be(0);
|
||||
@@ -606,14 +607,14 @@ xdescribe('App API', function () {
|
||||
});
|
||||
|
||||
it('logStream - stream logs', function (done) {
|
||||
var options = {
|
||||
const options = {
|
||||
port: constants.PORT, host: 'localhost', path: '/api/v1/apps/' + APP_ID + '/logstream?access_token=' + token,
|
||||
headers: { 'Accept': 'text/event-stream', 'Connection': 'keep-alive' }
|
||||
};
|
||||
|
||||
// superagent doesn't work. maybe https://github.com/visionmedia/superagent/issues/420
|
||||
var req = http.get(options, function (res) {
|
||||
var data = '';
|
||||
const req = http.get(options, function (res) {
|
||||
const data = '';
|
||||
res.on('data', function (d) { data += d.toString('utf8'); });
|
||||
setTimeout(function checkData() {
|
||||
expect(data.length).to.not.be(0);
|
||||
@@ -1082,7 +1083,7 @@ xdescribe('App API', function () {
|
||||
|
||||
xit('port mapping works after reconfiguration', function (done) {
|
||||
setTimeout(function () {
|
||||
var client = net.connect(7172);
|
||||
const client = net.connect(7172);
|
||||
client.on('data', function (data) {
|
||||
expect(data.toString()).to.eql('ECHO_SERVER_PORT=7172');
|
||||
done();
|
||||
@@ -1499,8 +1500,8 @@ xdescribe('App API', function () {
|
||||
});
|
||||
|
||||
xit('can uninstall app', function (done) {
|
||||
var fake1 = nock(settings.apiServerOrigin()).get(function (uri) { return uri.indexOf('/api/v1/cloudronapps/') >= 0; }).reply(200, { });
|
||||
var fake2 = nock(settings.apiServerOrigin()).delete(function (uri) { return uri.indexOf('/api/v1/cloudronapps/') >= 0; }).reply(204, { });
|
||||
const fake1 = nock(settings.apiServerOrigin()).get(function (uri) { return uri.indexOf('/api/v1/cloudronapps/') >= 0; }).reply(200, { });
|
||||
const fake2 = nock(settings.apiServerOrigin()).delete(function (uri) { return uri.indexOf('/api/v1/cloudronapps/') >= 0; }).reply(204, { });
|
||||
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/uninstall')
|
||||
.query({ access_token: token })
|
||||
|
||||
Reference in New Issue
Block a user