translate port bindings after validation

This commit is contained in:
Girish Ramakrishnan
2024-02-27 13:19:19 +01:00
parent 1e85c86e74
commit 5927f397a3
2 changed files with 25 additions and 28 deletions
+16 -16
View File
@@ -38,33 +38,33 @@ describe('Apps', function () {
describe('validatePortBindings', function () {
it('does not allow invalid host port', function () {
expect(apps._validatePortBindings({ port: -1 }, { tcpPorts: { port: 5000 } })).to.be.an(Error);
expect(apps._validatePortBindings({ port: 0 }, { tcpPorts: { port: 5000 } })).to.be.an(Error);
expect(apps._validatePortBindings({ port: 'text' }, { tcpPorts: { port: 5000 } })).to.be.an(Error);
expect(apps._validatePortBindings({ port: 65536 }, { tcpPorts: { port: 5000 } })).to.be.an(Error);
expect(apps._validatePortBindings({ port: 470 }, { tcpPorts: { port: 5000 } })).to.be.an(Error);
expect(apps._validatePortBindings({ PORT: -1 }, { tcpPorts: { PORT: 5000 } })).to.be.an(Error);
expect(apps._validatePortBindings({ PORT: 0 }, { tcpPorts: { PORT: 5000 } })).to.be.an(Error);
expect(apps._validatePortBindings({ PORT: 'text' }, { tcpPorts: { PORT: 5000 } })).to.be.an(Error);
expect(apps._validatePortBindings({ PORT: 65536 }, { tcpPorts: { PORT: 5000 } })).to.be.an(Error);
expect(apps._validatePortBindings({ PORT: 470 }, { tcpPorts: { PORT: 5000 } })).to.be.an(Error);
});
it('does not allow ports not as part of manifest', function () {
expect(apps._validatePortBindings({ port: 1567 }, { tcpPorts: { } })).to.be.an(Error);
expect(apps._validatePortBindings({ port: 1567 }, { tcpPorts: { port3: null } })).to.be.an(Error);
expect(apps._validatePortBindings({ PORT: 1567 }, { tcpPorts: { } })).to.be.an(Error);
expect(apps._validatePortBindings({ PORT: 1567 }, { tcpPorts: { port3: null } })).to.be.an(Error);
});
it('does not allow reserved ports', function () {
expect(apps._validatePortBindings({ port: 443 }, { tcpPorts: { port: 5000 } })).to.be.an(Error);
expect(apps._validatePortBindings({ port: 50000 }, { tcpPorts: { port: 5000 } })).to.be.an(Error);
expect(apps._validatePortBindings({ port: 51000 }, { tcpPorts: { port: 5000 } })).to.be.an(Error);
expect(apps._validatePortBindings({ port: 50100 }, { tcpPorts: { port: 5000 } })).to.be.an(Error);
expect(apps._validatePortBindings({ PORT: 443 }, { tcpPorts: { PORT: 5000 } })).to.be.an(Error);
expect(apps._validatePortBindings({ PORT: 50000 }, { tcpPorts: { PORT: 5000 } })).to.be.an(Error);
expect(apps._validatePortBindings({ PORT: 51000 }, { tcpPorts: { PORT: 5000 } })).to.be.an(Error);
expect(apps._validatePortBindings({ PORT: 50100 }, { tcpPorts: { PORT: 5000 } })).to.be.an(Error);
});
it('allows valid bindings', function () {
expect(apps._validatePortBindings({ port: 1024 }, { tcpPorts: { port: 5000 } })).to.be(null);
expect(apps._validatePortBindings({ PORT: 1024 }, { tcpPorts: { PORT: 5000 } })).to.be(null);
expect(apps._validatePortBindings({
port1: 4033,
port2: 3242,
port3: 1234
}, { tcpPorts: { port1: {}, port2: {}, port3: {} } })).to.be(null);
PORT1: 4033,
PORT2: 3242,
PORT3: 1234
}, { tcpPorts: { PORT1: {}, PORT2: {}, PORT3: {} } })).to.be(null);
});
});