2019-02-24 20:37:11 +03:00
|
|
|
const should = require('should');
|
|
|
|
const supertest = require('supertest');
|
2019-09-20 18:02:45 +03:00
|
|
|
const testUtils = require('../../utils');
|
2019-02-24 20:37:11 +03:00
|
|
|
const localUtils = require('./utils');
|
2020-05-27 20:47:53 +03:00
|
|
|
const config = require('../../../core/shared/config');
|
2021-11-11 21:07:19 +03:00
|
|
|
const configUtils = require('../../utils/configUtils');
|
2019-02-24 20:37:11 +03:00
|
|
|
|
|
|
|
describe('Config API', function () {
|
2020-11-30 17:25:22 +03:00
|
|
|
let request;
|
|
|
|
|
|
|
|
before(async function () {
|
2021-11-18 11:55:35 +03:00
|
|
|
await localUtils.startGhost();
|
2020-11-30 17:25:22 +03:00
|
|
|
request = supertest.agent(config.get('url'));
|
|
|
|
await localUtils.doAuth(request);
|
2019-02-24 20:37:11 +03:00
|
|
|
});
|
|
|
|
|
2021-11-11 21:07:19 +03:00
|
|
|
afterEach(function () {
|
2021-11-30 14:27:10 +03:00
|
|
|
configUtils.set('tenor:publicReadOnlyApiKey', undefined);
|
2021-11-11 21:07:19 +03:00
|
|
|
});
|
|
|
|
|
2020-11-30 17:25:22 +03:00
|
|
|
it('can retrieve config and all expected properties', async function () {
|
2021-11-11 21:07:19 +03:00
|
|
|
// set any non-default keys so we can be sure they're exposed
|
2021-11-30 14:27:10 +03:00
|
|
|
configUtils.set('tenor:publicReadOnlyApiKey', 'TENOR_KEY');
|
2021-11-11 21:07:19 +03:00
|
|
|
|
2020-11-30 17:25:22 +03:00
|
|
|
const res = await request
|
2019-02-24 20:37:11 +03:00
|
|
|
.get(localUtils.API.getApiQuery('config/'))
|
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
2020-11-30 17:25:22 +03:00
|
|
|
.expect(200);
|
|
|
|
|
|
|
|
localUtils.API.checkResponse(res.body.config, 'config');
|
2019-02-24 20:37:11 +03:00
|
|
|
|
2020-11-30 17:25:22 +03:00
|
|
|
// full version
|
|
|
|
res.body.config.version.should.match(/\d+\.\d+\.\d+/);
|
2019-02-24 20:37:11 +03:00
|
|
|
});
|
2022-01-17 21:06:52 +03:00
|
|
|
|
|
|
|
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');
|
|
|
|
});
|
|
|
|
});
|
2019-02-24 20:37:11 +03:00
|
|
|
});
|