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 () {
|
|
|
|
await testUtils.startGhost();
|
|
|
|
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 () {
|
|
|
|
configUtils.set('tenorApiKey', undefined);
|
|
|
|
});
|
|
|
|
|
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
|
|
|
|
configUtils.set('tenorApiKey', 'TENOR_KEY');
|
|
|
|
|
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
|
|
|
});
|
|
|
|
});
|