🐛 Fixed config API not returning boolean

no-issue

The mailgunIsConfigured config should be a boolean, rather than a string/undefined/null.
This commit is contained in:
Fabien "egg" O'Carroll 2022-01-17 20:06:52 +02:00
parent ce0e1b8b0c
commit 26ef4afdb9
3 changed files with 34 additions and 2 deletions

View File

@ -15,7 +15,7 @@ module.exports = function getConfigProperties() {
clientExtensions: config.get('clientExtensions') || {},
enableDeveloperExperiments: config.get('enableDeveloperExperiments') || false,
stripeDirect: config.get('stripeDirect'),
mailgunIsConfigured: config.get('bulkEmail') && config.get('bulkEmail').mailgun,
mailgunIsConfigured: !!(config.get('bulkEmail') && config.get('bulkEmail').mailgun),
emailAnalytics: config.get('emailAnalytics'),
hostSettings: config.get('hostSettings'),
tenor: config.get('tenor')

View File

@ -34,4 +34,36 @@ describe('Config API', function () {
// full version
res.body.config.version.should.match(/\d+\.\d+\.\d+/);
});
describe('mailgunIsConfigured', function () {
it('is a boolean when it is configured', async function () {
// set any non-default keys so we can be sure they're exposed
configUtils.set('bulkEmail', {
mailgun: 'exists'
});
const res = await request
.get(localUtils.API.getApiQuery('config/'))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200);
should.equal(typeof res.body.config.mailgunIsConfigured, 'boolean');
});
it('is a boolean when it is not configured', async function () {
// set any non-default keys so we can be sure they're exposed
configUtils.set('bulkEmail', {});
const res = await request
.get(localUtils.API.getApiQuery('config/'))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200);
should.equal(typeof res.body.config.mailgunIsConfigured, 'boolean');
});
});
});

View File

@ -29,7 +29,7 @@ const expectedProperties = {
action: ['id', 'resource_type', 'actor_type', 'event', 'created_at', 'actor'],
config: ['version', 'environment', 'database', 'mail', 'labs', 'clientExtensions', 'enableDeveloperExperiments', 'useGravatar', 'stripeDirect', 'emailAnalytics', 'tenor'],
config: ['version', 'environment', 'database', 'mail', 'labs', 'clientExtensions', 'enableDeveloperExperiments', 'useGravatar', 'stripeDirect', 'emailAnalytics', 'tenor', 'mailgunIsConfigured'],
post: [
'id',