check port expose

This commit is contained in:
Girish Ramakrishnan 2016-05-05 15:14:46 -07:00
parent 2a708ab77c
commit c854bf1989
2 changed files with 19 additions and 2 deletions

View File

@ -458,3 +458,4 @@ Cloudron.prototype.setDnsConfig = function (dnsConfig) {
var res = request.post(this._origin + '/api/v1/settings/dns_config').query({ access_token: this._credentials.accessToken }).send(dnsConfig).end();
common.verifyResponse2xx(res, 'Could not set dns config');
};

View File

@ -9,7 +9,7 @@ var AppStore = require('../appstore.js'),
assert = require('assert'),
Cloudron = require('../cloudron.js'),
common = require('../common.js'),
request = require('superagent-sync');
net = require('net');
require('colors');
@ -56,7 +56,7 @@ describe('Application flow test', function () {
var location = 'test' + (Math.random() * 10000).toFixed();
it('can install app', function () {
var manifest = appStore.getManifest(common.TESTAPP_ID, common.TESTAPP_VERSION);
appId = cloudron.installApp(location, manifest);
appId = cloudron.installApp(location, manifest, { ECHO_SERVER_PORT: 5151 );
});
it('can populate the addons', function () {
@ -67,6 +67,22 @@ describe('Application flow test', function () {
cloudron.checkAddons(cloudron.appFqdn(location), owner);
});
it('can access exposed port', function (done) {
var client = new net.Socket();
var data = [ ];
client.connect(5151, cloudron.appFqdn(location), function() {
console.log('connected to 5151');
});
client.on('data', function (chunk) { data.push(chunk); });
client.on('close', function () {
var response = Buffer.concat(data).toString('utf8');
if (response === 'ECHO_SERVER_PORT=5151') return done();
console.log('unexpected response:', response);
done(new Error('bad response'));
});
client.on('error', done);
});
it('displays app graphs', function () {
cloudron.checkAppGraphs(appId);
});