feat: Deprecation DEPPS12: Database option allowPublicExplain defaults to false (#9975)
BREAKING CHANGE: This release changes the MongoDB database option `allowPublicExplain` default to `false` (Deprecation DEPPS12).
This commit is contained in:
@@ -47,7 +47,7 @@ describe('Deprecator', () => {
|
||||
});
|
||||
|
||||
it('logs deprecation for nested option key with dot notation', async () => {
|
||||
deprecations = [{ optionKey: 'databaseOptions.allowPublicExplain', changeNewDefault: 'false' }];
|
||||
deprecations = [{ optionKey: 'databaseOptions.testOption', changeNewDefault: 'false' }];
|
||||
|
||||
spyOn(Deprecator, '_getDeprecations').and.callFake(() => deprecations);
|
||||
const logger = require('../lib/logger').logger;
|
||||
@@ -60,14 +60,14 @@ describe('Deprecator', () => {
|
||||
});
|
||||
|
||||
it('does not log deprecation for nested option key if option is set manually', async () => {
|
||||
deprecations = [{ optionKey: 'databaseOptions.allowPublicExplain', changeNewDefault: 'false' }];
|
||||
deprecations = [{ optionKey: 'databaseOptions.testOption', changeNewDefault: 'false' }];
|
||||
|
||||
spyOn(Deprecator, '_getDeprecations').and.callFake(() => deprecations);
|
||||
const logSpy = spyOn(Deprecator, '_logOption').and.callFake(() => {});
|
||||
const Config = require('../lib/Config');
|
||||
const config = Config.get('test');
|
||||
// Directly test scanParseServerOptions with nested option set
|
||||
Deprecator.scanParseServerOptions({ databaseOptions: { allowPublicExplain: true } });
|
||||
Deprecator.scanParseServerOptions({ databaseOptions: { testOption: true } });
|
||||
expect(logSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5369,7 +5369,7 @@ describe('Parse.Query testing', () => {
|
||||
const query = new Parse.Query('_User');
|
||||
query.equalTo('objectId', user.id);
|
||||
query.explain();
|
||||
const result = await query.find();
|
||||
const result = await query.find({ useMasterKey: true });
|
||||
// Validate
|
||||
expect(result.executionStats).not.toBeUndefined();
|
||||
});
|
||||
@@ -5533,11 +5533,8 @@ describe('Parse.Query testing', () => {
|
||||
);
|
||||
|
||||
it_id('c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f')(it_only_db('mongo'))(
|
||||
'explain works with and without master key by default',
|
||||
'explain requires master key by default',
|
||||
async () => {
|
||||
const logger = require('../lib/logger').logger;
|
||||
const logSpy = spyOn(logger, 'warn').and.callFake(() => {});
|
||||
|
||||
await reconfigureServer({
|
||||
databaseAdapter: undefined,
|
||||
databaseURI: 'mongodb://localhost:27017/parse',
|
||||
@@ -5546,21 +5543,20 @@ describe('Parse.Query testing', () => {
|
||||
},
|
||||
});
|
||||
|
||||
// Verify deprecation warning is logged when allowPublicExplain is not explicitly set
|
||||
expect(logSpy).toHaveBeenCalledWith(
|
||||
jasmine.stringMatching(/DeprecationWarning.*databaseOptions\.allowPublicExplain.*false/)
|
||||
);
|
||||
|
||||
const obj = new TestObject({ foo: 'bar' });
|
||||
await obj.save();
|
||||
|
||||
// Without master key
|
||||
// Without master key - should fail
|
||||
const query = new Parse.Query(TestObject);
|
||||
query.explain();
|
||||
const resultWithoutMasterKey = await query.find();
|
||||
expect(resultWithoutMasterKey).toBeDefined();
|
||||
await expectAsync(query.find()).toBeRejectedWith(
|
||||
new Parse.Error(
|
||||
Parse.Error.INVALID_QUERY,
|
||||
'Using the explain query parameter requires the master key'
|
||||
)
|
||||
);
|
||||
|
||||
// With master key
|
||||
// With master key - should succeed
|
||||
const queryWithMasterKey = new Parse.Query(TestObject);
|
||||
queryWithMasterKey.explain();
|
||||
const resultWithMasterKey = await queryWithMasterKey.find({ useMasterKey: true });
|
||||
|
||||
Reference in New Issue
Block a user