diff --git a/src/apps.js b/src/apps.js index c3f3f1c3c..e3b9d02a2 100644 --- a/src/apps.js +++ b/src/apps.js @@ -129,6 +129,8 @@ function validateHostname(location, fqdn) { // validate the port bindings function validatePortBindings(portBindings, tcpPorts) { + assert.strictEqual(typeof portBindings, 'object'); + // keep the public ports in sync with firewall rules in scripts/initializeBaseUbuntuImage.sh // these ports are reserved even if we listen only on 127.0.0.1 because we setup HostIp to be 127.0.0.1 // for custom tcp ports diff --git a/src/test/apps-test.js b/src/test/apps-test.js index 825f43653..feb38ea31 100644 --- a/src/test/apps-test.js +++ b/src/test/apps-test.js @@ -168,20 +168,21 @@ describe('Apps', function () { describe('validatePortBindings', function () { it('does not allow invalid host port', function () { - expect(apps._validatePortBindings({ port: -1 })).to.be.an(Error); - expect(apps._validatePortBindings({ port: 0 })).to.be.an(Error); - expect(apps._validatePortBindings({ port: 'text' })).to.be.an(Error); - expect(apps._validatePortBindings({ port: 65536 })).to.be.an(Error); - expect(apps._validatePortBindings({ port: 1024 })).to.be.an(Error); + expect(apps._validatePortBindings({ port: -1 }, { port: 5000 })).to.be.an(Error); + expect(apps._validatePortBindings({ port: 0 }, { port: 5000 })).to.be.an(Error); + expect(apps._validatePortBindings({ port: 'text' }, { port: 5000 })).to.be.an(Error); + expect(apps._validatePortBindings({ port: 65536 }, { port: 5000 })).to.be.an(Error); + expect(apps._validatePortBindings({ port: 470 }, { port: 5000 })).to.be.an(Error); }); it('does not allow ports not as part of manifest', function () { - expect(apps._validatePortBindings({ port: 1567 })).to.be.an(Error); + expect(apps._validatePortBindings({ port: 1567 }, { })).to.be.an(Error); expect(apps._validatePortBindings({ port: 1567 }, { port3: null })).to.be.an(Error); }); it('allows valid bindings', function () { - expect(apps._validatePortBindings({ port: 1025 }, { port: null })).to.be(null); + expect(apps._validatePortBindings({ port: 1024 }, { port: 5000 })).to.be(null); + expect(apps._validatePortBindings({ port1: 4033, port2: 3242,