2020-07-10 13:22:07 +03:00
|
|
|
const db = require('../../../core/server/data/db');
|
|
|
|
const testUtils = require('../../utils');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @NOTE
|
|
|
|
*
|
|
|
|
* If this test fails for you, you have modified the default settings.
|
|
|
|
* When you make a change or add new setting, please ensure that:
|
2022-04-19 13:01:19 +03:00
|
|
|
* - If a new `core` setting is added/removed/renamed, update the allowlist below
|
2020-07-10 13:22:07 +03:00
|
|
|
* - If a new non-`core` setting is added, it includes corresponding migration to populate its `group` and `flags`
|
|
|
|
*/
|
|
|
|
|
|
|
|
describe('Settings', function () {
|
2022-03-16 16:56:34 +03:00
|
|
|
before(testUtils.setup());
|
2020-07-10 13:22:07 +03:00
|
|
|
|
2020-09-07 12:54:55 +03:00
|
|
|
// Allowlist: Only this list needs updating when a core setting is added/removed/renamed
|
2020-07-10 13:22:07 +03:00
|
|
|
const coreSettingKeys = [
|
|
|
|
'db_hash',
|
2020-09-07 12:54:55 +03:00
|
|
|
'routes_hash',
|
2020-07-10 13:22:07 +03:00
|
|
|
'next_update_check',
|
|
|
|
'notifications',
|
2022-04-21 05:48:21 +03:00
|
|
|
'version_notifications',
|
2022-05-12 17:07:05 +03:00
|
|
|
'admin_session_secret',
|
2020-07-10 13:22:07 +03:00
|
|
|
'theme_session_secret',
|
|
|
|
'ghost_public_key',
|
|
|
|
'ghost_private_key',
|
|
|
|
'members_public_key',
|
|
|
|
'members_private_key',
|
2020-07-10 17:26:06 +03:00
|
|
|
'members_email_auth_secret',
|
|
|
|
'members_stripe_webhook_id',
|
|
|
|
'members_stripe_webhook_secret'
|
2020-07-10 13:22:07 +03:00
|
|
|
];
|
|
|
|
// If this test is failing, then it is likely a new setting has been added without group migration
|
2020-09-07 12:54:55 +03:00
|
|
|
// In case of `core` setting modifications, allowlist above needs to be updated
|
2020-07-10 13:22:07 +03:00
|
|
|
it('should not modify core keys without fixing this test', function () {
|
|
|
|
return db.knex('settings')
|
|
|
|
.where('group', 'core')
|
|
|
|
.whereNotIn('key', coreSettingKeys)
|
|
|
|
.count('*')
|
|
|
|
.then(function (data) {
|
|
|
|
const countResult = data[0]['count(*)'];
|
|
|
|
countResult.should.eql(0);
|
|
|
|
})
|
|
|
|
.catch(function (err) {
|
|
|
|
// CASE: table does not exist
|
|
|
|
if (err.errno === 1146) {
|
|
|
|
return Promise.resolve();
|
|
|
|
}
|
|
|
|
throw err;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|