rename location to subdomain
the primary subdomain was previously called 'location'. but the alias/secondary/redirect
subdomain is called 'subdomain'. this makes it all consistent.
location terminology is now used for { subdomain, domain } pair
This commit is contained in:
@@ -49,8 +49,8 @@ const DOMAIN_0 = {
|
||||
};
|
||||
|
||||
var APP_STORE_ID = 'test', APP_ID;
|
||||
var APP_LOCATION = 'appslocation';
|
||||
var APP_LOCATION_NEW = 'appslocationnew';
|
||||
var APP_SUBDOMAIN = 'appssubdomain';
|
||||
var APP_SUBDOMAIN_NEW = 'appssubdomainnew';
|
||||
|
||||
var APP_MANIFEST = JSON.parse(fs.readFileSync(__dirname + '/../../../../test-app/CloudronManifest.json', 'utf8'));
|
||||
APP_MANIFEST.dockerImage = TEST_IMAGE;
|
||||
@@ -288,7 +288,7 @@ describe('App API', function () {
|
||||
it('app install fails - missing domain', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/install')
|
||||
.query({ access_token: token })
|
||||
.send({ manifest: APP_MANIFEST, location: 'some', accessRestriction: null })
|
||||
.send({ manifest: APP_MANIFEST, subdomain: 'some', accessRestriction: null })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(400);
|
||||
expect(res.body.message).to.eql('domain is required');
|
||||
@@ -299,7 +299,7 @@ describe('App API', function () {
|
||||
it('app install fails - non-existing domain', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/install')
|
||||
.query({ access_token: token })
|
||||
.send({ manifest: APP_MANIFEST, location: 'some', accessRestriction: null, domain: 'doesnotexist.com' })
|
||||
.send({ manifest: APP_MANIFEST, subdomain: 'some', accessRestriction: null, domain: 'doesnotexist.com' })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(400);
|
||||
expect(res.body.message).to.eql('No such domain');
|
||||
@@ -307,21 +307,21 @@ describe('App API', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('app install fails - invalid location type', function (done) {
|
||||
it('app install fails - invalid subdomain type', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/install')
|
||||
.query({ access_token: token })
|
||||
.send({ manifest: APP_MANIFEST, location: 42, accessRestriction: null, domain: DOMAIN_0.domain })
|
||||
.send({ manifest: APP_MANIFEST, subdomain: 42, accessRestriction: null, domain: DOMAIN_0.domain })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(400);
|
||||
expect(res.body.message).to.eql('location is required');
|
||||
expect(res.body.message).to.eql('subdomain is required');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('app install fails - reserved admin location', function (done) {
|
||||
it('app install fails - reserved admin subdomain', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/install')
|
||||
.query({ access_token: token })
|
||||
.send({ manifest: APP_MANIFEST, location: 'my', accessRestriction: null, domain: DOMAIN_0.domain })
|
||||
.send({ manifest: APP_MANIFEST, subdomain: 'my', accessRestriction: null, domain: DOMAIN_0.domain })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(400);
|
||||
expect(res.body.message).to.contain('my is reserved');
|
||||
@@ -329,10 +329,10 @@ describe('App API', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('app install fails - reserved smtp location', function (done) {
|
||||
it('app install fails - reserved smtp subdomain', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/install')
|
||||
.query({ access_token: token })
|
||||
.send({ manifest: APP_MANIFEST, location: constants.SMTP_LOCATION, accessRestriction: null, domain: DOMAIN_0.domain })
|
||||
.send({ manifest: APP_MANIFEST, subdomain: constants.SMTP_LOCATION, accessRestriction: null, domain: DOMAIN_0.domain })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(400);
|
||||
expect(res.body.message).to.contain(constants.SMTP_LOCATION + ' is reserved');
|
||||
@@ -343,7 +343,7 @@ describe('App API', function () {
|
||||
it('app install fails - portBindings must be object', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/install')
|
||||
.query({ access_token: token })
|
||||
.send({ manifest: APP_MANIFEST, location: APP_LOCATION, portBindings: 23, accessRestriction: null, domain: DOMAIN_0.domain })
|
||||
.send({ manifest: APP_MANIFEST, subdomain: APP_SUBDOMAIN, portBindings: 23, accessRestriction: null, domain: DOMAIN_0.domain })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(400);
|
||||
expect(res.body.message).to.contain('portBindings must be an object');
|
||||
@@ -354,7 +354,7 @@ describe('App API', function () {
|
||||
it('app install fails - accessRestriction is required', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/install')
|
||||
.query({ access_token: token })
|
||||
.send({ manifest: APP_MANIFEST, location: APP_LOCATION, portBindings: {}, domain: DOMAIN_0.domain })
|
||||
.send({ manifest: APP_MANIFEST, subdomain: APP_SUBDOMAIN, portBindings: {}, domain: DOMAIN_0.domain })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(400);
|
||||
expect(res.body.message).to.contain('accessRestriction is required');
|
||||
@@ -365,7 +365,7 @@ describe('App API', function () {
|
||||
it('app install fails - accessRestriction type is wrong', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/install')
|
||||
.query({ access_token: token })
|
||||
.send({ manifest: APP_MANIFEST, location: APP_LOCATION, portBindings: {}, accessRestriction: '', domain: DOMAIN_0.domain })
|
||||
.send({ manifest: APP_MANIFEST, subdomain: APP_SUBDOMAIN, portBindings: {}, accessRestriction: '', domain: DOMAIN_0.domain })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(400);
|
||||
expect(res.body.message).to.contain('accessRestriction is required');
|
||||
@@ -376,7 +376,7 @@ describe('App API', function () {
|
||||
it('app install fails for non admin', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/install')
|
||||
.query({ access_token: token_1 })
|
||||
.send({ manifest: APP_MANIFEST, location: APP_LOCATION, portBindings: null, accessRestriction: null, domain: DOMAIN_0.domain })
|
||||
.send({ manifest: APP_MANIFEST, subdomain: APP_SUBDOMAIN, portBindings: null, accessRestriction: null, domain: DOMAIN_0.domain })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(403);
|
||||
done();
|
||||
@@ -388,7 +388,7 @@ describe('App API', function () {
|
||||
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/install')
|
||||
.query({ access_token: token })
|
||||
.send({ appStoreId: APP_STORE_ID, location: APP_LOCATION, portBindings: null, domain: DOMAIN_0.domain, accessRestriction: { users: [ 'someuser' ], groups: [] } })
|
||||
.send({ appStoreId: APP_STORE_ID, subdomain: APP_SUBDOMAIN, portBindings: null, domain: DOMAIN_0.domain, accessRestriction: { users: [ 'someuser' ], groups: [] } })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(404);
|
||||
expect(fake.isDone()).to.be.ok();
|
||||
@@ -401,7 +401,7 @@ describe('App API', function () {
|
||||
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/install')
|
||||
.query({ access_token: token })
|
||||
.send({ appStoreId: APP_STORE_ID, location: APP_LOCATION, domain: DOMAIN_0.domain, portBindings: null, accessRestriction: null })
|
||||
.send({ appStoreId: APP_STORE_ID, subdomain: APP_SUBDOMAIN, domain: DOMAIN_0.domain, portBindings: null, accessRestriction: null })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(402);
|
||||
expect(fake1.isDone()).to.be.ok();
|
||||
@@ -417,7 +417,7 @@ describe('App API', function () {
|
||||
|
||||
const res = await superagent.post(SERVER_URL + '/api/v1/apps/install')
|
||||
.query({ access_token: token })
|
||||
.send({ appStoreId: APP_STORE_ID, location: APP_LOCATION, domain: DOMAIN_0.domain, portBindings: { ECHO_SERVER_PORT: 7171 }, accessRestriction: { users: [ 'someuser' ], groups: [] } })
|
||||
.send({ appStoreId: APP_STORE_ID, subdomain: APP_SUBDOMAIN, domain: DOMAIN_0.domain, portBindings: { ECHO_SERVER_PORT: 7171 }, accessRestriction: { users: [ 'someuser' ], groups: [] } })
|
||||
|
||||
expect(res.statusCode).to.equal(202);
|
||||
expect(res.body.id).to.be.a('string');
|
||||
@@ -427,10 +427,10 @@ describe('App API', function () {
|
||||
taskId = res.body.taskId;
|
||||
});
|
||||
|
||||
it('app install fails because of conflicting location', function (done) {
|
||||
it('app install fails because of conflicting subdomain', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/install')
|
||||
.query({ access_token: token })
|
||||
.send({ manifest: APP_MANIFEST, location: APP_LOCATION, domain: DOMAIN_0.domain, portBindings: null, accessRestriction: null })
|
||||
.send({ manifest: APP_MANIFEST, subdomain: APP_SUBDOMAIN, domain: DOMAIN_0.domain, portBindings: null, accessRestriction: null })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(409);
|
||||
done();
|
||||
@@ -446,7 +446,7 @@ describe('App API', function () {
|
||||
expect(res.statusCode).to.equal(200);
|
||||
expect(res.body.id).to.eql(APP_ID);
|
||||
expect(res.body.installationState).to.be.ok();
|
||||
expect(res.body.mailboxName).to.be(APP_LOCATION + '.app');
|
||||
expect(res.body.mailboxName).to.be(APP_SUBDOMAIN + '.app');
|
||||
expect(res.body.mailboxDomain).to.be(DOMAIN_0.domain);
|
||||
done();
|
||||
});
|
||||
@@ -522,10 +522,10 @@ describe('App API', function () {
|
||||
expect(data.Config.Env).to.contain('CLOUDRON_WEBADMIN_ORIGIN=' + settings.dashboardOrigin());
|
||||
expect(data.Config.Env).to.contain('CLOUDRON_API_ORIGIN=' + settings.dashboardOrigin());
|
||||
expect(data.Config.Env).to.contain('CLOUDRON=1');
|
||||
expect(data.Config.Env).to.contain('CLOUDRON_APP_ORIGIN=https://' + APP_LOCATION + '.' + DOMAIN_0.domain);
|
||||
expect(data.Config.Env).to.contain('CLOUDRON_APP_DOMAIN=' + APP_LOCATION + '.' + DOMAIN_0.domain);
|
||||
// Hostname must not be set of app fqdn or app location!
|
||||
expect(data.Config.Hostname).to.not.contain(APP_LOCATION);
|
||||
expect(data.Config.Env).to.contain('CLOUDRON_APP_ORIGIN=https://' + APP_SUBDOMAIN + '.' + DOMAIN_0.domain);
|
||||
expect(data.Config.Env).to.contain('CLOUDRON_APP_DOMAIN=' + APP_SUBDOMAIN + '.' + DOMAIN_0.domain);
|
||||
// Hostname must not be set of app fqdn or app subdomain!
|
||||
expect(data.Config.Hostname).to.not.contain(APP_SUBDOMAIN);
|
||||
expect(data.Config.Env).to.contain('ECHO_SERVER_PORT=7171');
|
||||
expect(data.HostConfig.PortBindings['7778/tcp'][0].HostPort).to.eql('7171');
|
||||
done();
|
||||
@@ -533,7 +533,7 @@ describe('App API', function () {
|
||||
});
|
||||
|
||||
it('nginx config', function (done) {
|
||||
expect(fs.existsSync(paths.NGINX_APPCONFIG_DIR + '/' + APP_LOCATION + '.conf'));
|
||||
expect(fs.existsSync(paths.NGINX_APPCONFIG_DIR + '/' + APP_SUBDOMAIN + '.conf'));
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -857,7 +857,7 @@ describe('App API', function () {
|
||||
it('cannot set only the cert, no key', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/cert')
|
||||
.query({ access_token: token })
|
||||
.send({ location: APP_LOCATION, domain: DOMAIN_0.domain, cert: CERT })
|
||||
.send({ subdomain: APP_SUBDOMAIN, domain: DOMAIN_0.domain, cert: CERT })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(400);
|
||||
done();
|
||||
@@ -867,7 +867,7 @@ describe('App API', function () {
|
||||
it('cannot reconfigure app with only the key, no cert', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/cert')
|
||||
.query({ access_token: token })
|
||||
.send({ location: APP_LOCATION, domain: DOMAIN_0.domain, key: KEY })
|
||||
.send({ subdomain: APP_SUBDOMAIN, domain: DOMAIN_0.domain, key: KEY })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(400);
|
||||
done();
|
||||
@@ -877,7 +877,7 @@ describe('App API', function () {
|
||||
it('cannot set invalid cert', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/cert')
|
||||
.query({ access_token: token })
|
||||
.send({ location: APP_LOCATION, domain: DOMAIN_0.domain, cert: 'x' + CERT, key: KEY })
|
||||
.send({ subdomain: APP_SUBDOMAIN, domain: DOMAIN_0.domain, cert: 'x' + CERT, key: KEY })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(400);
|
||||
done();
|
||||
@@ -887,7 +887,7 @@ describe('App API', function () {
|
||||
it('can set cert', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/cert')
|
||||
.query({ access_token: token })
|
||||
.send({ location: APP_LOCATION, domain: DOMAIN_0.domain, cert: CERT, key: KEY })
|
||||
.send({ subdomain: APP_SUBDOMAIN, domain: DOMAIN_0.domain, cert: CERT, key: KEY })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(200);
|
||||
done();
|
||||
@@ -897,7 +897,7 @@ describe('App API', function () {
|
||||
it('can reset cert', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/cert')
|
||||
.query({ access_token: token })
|
||||
.send({ location: APP_LOCATION, domain: DOMAIN_0.domain, cert: null, key: null })
|
||||
.send({ subdomain: APP_SUBDOMAIN, domain: DOMAIN_0.domain, cert: null, key: null })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(200);
|
||||
done();
|
||||
@@ -1015,21 +1015,21 @@ describe('App API', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('configure location', function () {
|
||||
describe('configure subdomain', function () {
|
||||
it('cannot reconfigure app with missing domain', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/location')
|
||||
.query({ access_token: token })
|
||||
.send({ location: 'hellothre' })
|
||||
.send({ subdomain: 'hellothre' })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(400);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('cannot reconfigure app with bad location', function (done) {
|
||||
it('cannot reconfigure app with bad subdomain', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/location')
|
||||
.query({ access_token: token })
|
||||
.send({ location: 1234, domain: DOMAIN_0.domain })
|
||||
.send({ subdomain: 1234, domain: DOMAIN_0.domain })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(400);
|
||||
done();
|
||||
@@ -1039,17 +1039,17 @@ describe('App API', function () {
|
||||
it('non admin cannot reconfigure app', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/location')
|
||||
.query({ access_token: token_1 })
|
||||
.send({ location: APP_LOCATION_NEW, domain: DOMAIN_0.domain, portBindings: { ECHO_SERVER_PORT: 7172 }, accessRestriction: null })
|
||||
.send({ subdomain: APP_SUBDOMAIN_NEW, domain: DOMAIN_0.domain, portBindings: { ECHO_SERVER_PORT: 7172 }, accessRestriction: null })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(403);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
xit('can change location', function (done) {
|
||||
xit('can change subdomain', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/location')
|
||||
.query({ access_token: token })
|
||||
.send({ location: APP_LOCATION_NEW, domain: DOMAIN_0.domain, portBindings: { ECHO_SERVER_PORT: 7172 } })
|
||||
.send({ subdomain: APP_SUBDOMAIN_NEW, domain: DOMAIN_0.domain, portBindings: { ECHO_SERVER_PORT: 7172 } })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(202);
|
||||
taskId = res.body.taskId;
|
||||
@@ -1061,18 +1061,18 @@ describe('App API', function () {
|
||||
waitForTask(taskId, done);
|
||||
});
|
||||
|
||||
xit('did change location', function (done) {
|
||||
xit('did change subdomain', function (done) {
|
||||
apps.get(APP_ID, function (error, app) {
|
||||
if (error) return done(error);
|
||||
|
||||
expect(app.mailboxName).to.be(APP_LOCATION_NEW + '.app'); // must follow location change
|
||||
expect(app.mailboxName).to.be(APP_SUBDOMAIN_NEW + '.app'); // must follow subdomain change
|
||||
expect(app.mailboxDomain).to.be(DOMAIN_0.domain);
|
||||
|
||||
docker.getContainer(app.containerId).inspect(function (error, data) {
|
||||
expect(error).to.not.be.ok();
|
||||
expect(data.Config.Env).to.contain('CLOUDRON_APP_ORIGIN=https://' + APP_LOCATION_NEW + '.' + DOMAIN_0.domain);
|
||||
expect(data.Config.Env).to.contain('CLOUDRON_APP_DOMAIN=' + APP_LOCATION_NEW + '.' + DOMAIN_0.domain);
|
||||
expect(data.Config.Hostname).to.not.contain(APP_LOCATION_NEW);
|
||||
expect(data.Config.Env).to.contain('CLOUDRON_APP_ORIGIN=https://' + APP_SUBDOMAIN_NEW + '.' + DOMAIN_0.domain);
|
||||
expect(data.Config.Env).to.contain('CLOUDRON_APP_DOMAIN=' + APP_SUBDOMAIN_NEW + '.' + DOMAIN_0.domain);
|
||||
expect(data.Config.Hostname).to.not.contain(APP_SUBDOMAIN_NEW);
|
||||
expect(data.Config.Env).to.contain('ECHO_SERVER_PORT=7172');
|
||||
expect(data.HostConfig.PortBindings['7778/tcp'][0].HostPort).to.eql('7172');
|
||||
done();
|
||||
@@ -1314,7 +1314,7 @@ describe('App API', function () {
|
||||
|
||||
docker.getContainer(app.containerId).inspect(function (error, data) {
|
||||
expect(error).to.not.be.ok();
|
||||
expect(data.Config.Env).to.not.contain('CLOUDRON_MAIL_FROM=' + app.location + '@' + app.domain + '.app');
|
||||
expect(data.Config.Env).to.not.contain('CLOUDRON_MAIL_FROM=' + app.subdomain + '@' + app.domain + '.app');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -1553,7 +1553,7 @@ describe('App API', function () {
|
||||
});
|
||||
|
||||
it('removed nginx', function (done) {
|
||||
expect(!fs.existsSync(paths.NGINX_APPCONFIG_DIR + '/' + APP_LOCATION + '.conf'));
|
||||
expect(!fs.existsSync(paths.NGINX_APPCONFIG_DIR + '/' + APP_SUBDOMAIN + '.conf'));
|
||||
done();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user