Check for portBindings with range outside the db constraint for now

This commit is contained in:
Johannes Zellner
2024-02-28 14:56:04 +01:00
parent d87460a3cd
commit dec7bc3ca3
2 changed files with 73 additions and 0 deletions
+33
View File
@@ -19,6 +19,39 @@ describe('Apps', function () {
before(domainSetup);
after(cleanup);
describe('checkForPortBindingConflict', function () {
before(async function () {
await apps.add(app.id, app.appStoreId, app.manifest, app.subdomain, app.domain, [{ hostPort: 40000, type: 'tcp', portCount: 100 }, { hostPort: 50000, type: 'udp', portCount: 1 }], app);
});
after(async function () {
await apps.del(app.id);
});
it('throws on exact conflict', async function () {
let [error] = await safe(apps._checkForPortBindingConflict([{ hostPort: 40000, type: 'tcp', portCount: 1 }]));
expect(error.reason).to.equal(BoxError.CONFLICT);
[error] = await safe(apps._checkForPortBindingConflict([{ hostPort: 50000, type: 'udp', portCount: 1 }]));
expect(error.reason).to.equal(BoxError.CONFLICT);
});
it('throws on range conflict', async function () {
let [error] = await safe(apps._checkForPortBindingConflict([{ hostPort: 40080, type: 'tcp', portCount: 40 }]));
expect(error.reason).to.equal(BoxError.CONFLICT);
[error] = await safe(apps._checkForPortBindingConflict([{ hostPort: 49995, type: 'udp', portCount: 20 }]));
expect(error.reason).to.equal(BoxError.CONFLICT);
});
it('succeeds without conflict', async function () {
await apps._checkForPortBindingConflict([{ hostPort: 39995, type: 'tcp', portCount: 2 }]);
await apps._checkForPortBindingConflict([{ hostPort: 45000, type: 'tcp', portCount: 1 }]);
await apps._checkForPortBindingConflict([{ hostPort: 49995, type: 'udp', portCount: 2 }]);
await apps._checkForPortBindingConflict([{ hostPort: 50001, type: 'udp', portCount: 1 }]);
});
});
describe('validateLocations', function () {
it('does not allow reserved subdomain', async function () {
let location = new Location('my', domain.domain, Location.TYPE_ALIAS);