0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 17:10:48 +01:00
mongodb/jstests/noPassthroughWithMongod/disallow_system_views_rename.js

25 lines
918 B
JavaScript

(function() {
'use strict';
assert.commandWorked(db.runCommand({insert: 'a', documents: [{x: 1}]}));
// Disallow renaming to system.views
assert.commandFailedWithCode(db.adminCommand({renameCollection: 'test.a', to: 'test.system.views'}),
ErrorCodes.IllegalOperation);
assert.commandWorked(db.createView('viewA', 'a', []));
// Disallow renaming from system.views
assert.commandFailedWithCode(
db.adminCommand({renameCollection: 'test.system.views', to: 'test.aaabb'}),
ErrorCodes.IllegalOperation);
// User can still rename system.views (or to system.views) via applyOps command.
assert.commandWorked(db.adminCommand({
applyOps: [{op: 'c', ns: 'test.$cmd', o: {renameCollection: 'test.system.views', to: 'test.b'}}]
}));
assert.commandWorked(db.adminCommand({
applyOps: [{op: 'c', ns: 'test.$cmd', o: {renameCollection: 'test.b', to: 'test.system.views'}}]
}));
})();