diff options
Diffstat (limited to 'jstests/noPassthroughWithMongod')
-rw-r--r-- | jstests/noPassthroughWithMongod/disallow_system_views_rename.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/jstests/noPassthroughWithMongod/disallow_system_views_rename.js b/jstests/noPassthroughWithMongod/disallow_system_views_rename.js new file mode 100644 index 00000000000..c9bc901041e --- /dev/null +++ b/jstests/noPassthroughWithMongod/disallow_system_views_rename.js @@ -0,0 +1,24 @@ +(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'}}] +})); +})(); |