mail: 'my' location is available as mail location

move the reserve domains check to app location validation code
This commit is contained in:
Girish Ramakrishnan
2023-08-01 19:33:59 +05:30
parent 7d929aca54
commit ee836e6646
4 changed files with 28 additions and 14 deletions

View File

@@ -9,16 +9,32 @@ const apps = require('../apps.js'),
AuditSource = require('../auditsource.js'),
BoxError = require('../boxerror.js'),
common = require('./common.js'),
constants = require('../constants.js'),
expect = require('expect.js'),
safe = require('safetydance');
describe('Apps', function () {
const { domainSetup, cleanup, app, admin, user } = common;
const { domainSetup, cleanup, app, admin, user , domain } = common;
before(domainSetup);
after(cleanup);
describe('validateLocations', function () {
it('does not allow reserved subdomain', async function () {
let location = { type: apps.LOCATION_TYPE_ALIAS, subdomain: 'my', domain: domain.domain };
expect(await apps._validateLocations([location])).to.be.an(Error);
});
it('does not allow unknown domain', async function () {
let location = { type: apps.LOCATION_TYPE_PRIMARY, subdomain: 'my2', domain: domain.domain + 'x' };
expect(await apps._validateLocations([location])).to.be.an(Error);
});
it('allows valid locations', async function () {
let location = { type: apps.LOCATION_TYPE_SECONDARY, subdomain: 'my2', domain: domain.domain };
expect(await apps._validateLocations([location])).to.be(null);
});
});
describe('validatePortBindings', function () {
it('does not allow invalid host port', function () {
expect(apps._validatePortBindings({ port: -1 }, { tcpPorts: { port: 5000 } })).to.be.an(Error);

View File

@@ -18,10 +18,6 @@ describe('DNS', function () {
after(cleanup);
describe('validateHostname', function () {
it('does not allow admin subdomain', function () {
expect(dns.validateHostname('my', domain)).to.be.an(Error);
});
it('cannot have >63 length subdomains', function () {
const s = Array(64).fill('s').join('');
expect(dns.validateHostname(s, domain)).to.be.an(Error);