diff --git a/src/domains.js b/src/domains.js index f5e221e5a..cb3895cbf 100644 --- a/src/domains.js +++ b/src/domains.js @@ -131,7 +131,6 @@ async function add(domain, data, auditSource) { if (domain.endsWith('.')) throw new BoxError(BoxError.BAD_FIELD, 'Invalid domain', { field: 'domain' }); if (zoneName) { - console.log('THE ZONE', zoneName); if (!tld.isValid(zoneName)) throw new BoxError(BoxError.BAD_FIELD, 'Invalid zoneName', { field: 'zoneName' }); if (zoneName.endsWith('.')) throw new BoxError(BoxError.BAD_FIELD, 'Invalid zoneName', { field: 'zoneName' }); } else { diff --git a/src/routes/test/branding-test.js b/src/routes/test/branding-test.js index 5ab6ce688..8312ea352 100644 --- a/src/routes/test/branding-test.js +++ b/src/routes/test/branding-test.js @@ -6,6 +6,7 @@ /* global after:false */ const common = require('./common.js'), + constants = require('../../constants.js'), expect = require('expect.js'), fs = require('fs'), paths = require('../../paths.js'), @@ -166,4 +167,38 @@ describe('Branding API', function () { expect(response.body.blacklist).to.be(undefined); }); }); + + describe('footer', function () { + it('get default succeeds', async function () { + const response = await superagent.get(`${serverUrl}/api/v1/branding/footer`) + .query({ access_token: owner.token }); + + expect(response.statusCode).to.equal(200); + expect(response.body.footer).to.eql(constants.FOOTER); + }); + + it('cannot set without data', async function () { + const response = await superagent.post(`${serverUrl}/api/v1/branding/footer`) + .query({ access_token: owner.token }) + .ok(() => true); + + expect(response.statusCode).to.equal(400); + }); + + it('set succeeds', async function () { + const response = await superagent.post(`${serverUrl}/api/v1/branding/footer`) + .query({ access_token: owner.token }) + .send({ footer: 'BigFoot Inc' }); + + expect(response.statusCode).to.equal(200); + }); + + it('get succeeds', async function () { + const response = await superagent.get(`${serverUrl}/api/v1/branding/footer`) + .query({ access_token: owner.token }); + + expect(response.statusCode).to.equal(200); + expect(response.body.footer).to.eql('BigFoot Inc'); + }); + }); }); diff --git a/src/settings.js b/src/settings.js index 087348892..20f59cbed 100644 --- a/src/settings.js +++ b/src/settings.js @@ -146,7 +146,7 @@ const SETTINGS_FIELDS = [ 'name', 'value' ].join(','); const SETTINGS_BLOB_FIELDS = [ 'name', 'valueBlob' ].join(','); const gDefaults = (function () { - var result = { }; + const result = { }; result[exports.AUTOUPDATE_PATTERN_KEY] = cron.DEFAULT_AUTOUPDATE_PATTERN; result[exports.TIME_ZONE_KEY] = 'America/Los_Angeles'; result[exports.CLOUDRON_NAME_KEY] = 'Cloudron'; @@ -207,7 +207,7 @@ const gDefaults = (function () { submitTickets: true }; - result[exports.FOOTER_KEY] = ''; + result[exports.FOOTER_KEY] = constants.FOOTER; return result; })(); diff --git a/src/test/branding-test.js b/src/test/branding-test.js new file mode 100644 index 000000000..31c2c4081 --- /dev/null +++ b/src/test/branding-test.js @@ -0,0 +1,30 @@ +/* global it:false */ +/* global describe:false */ +/* global before:false */ +/* global after:false */ + +'use strict'; + +const branding = require('../branding.js'), + common = require('./common.js'), + constants = require('../constants.js'), + expect = require('expect.js'); + +describe('Branding', function () { + const { setup, cleanup } = common; + + before(setup); + after(cleanup); + + it('can render default footer', async function () { + expect(branding.renderFooter(constants.FOOTER)).to.contain('(https://cloudron.io)'); + }); + + it('can render footer', async function () { + expect(branding.renderFooter('BigFoot Inc')).to.be('BigFoot Inc'); + }); + + it('can render footer with YEAR', async function () { + expect(branding.renderFooter('BigFoot Inc %YEAR%')).to.be('BigFoot Inc 2021'); + }); +});