diff options
author | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2019-08-14 15:51:38 -0400 |
---|---|---|
committer | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2019-08-19 16:13:32 -0400 |
commit | ab5e8175f64c33606861c8b659e3708944177871 (patch) | |
tree | b30f60ed1150d8f32af7f2d822f677b0fc4af35f /jstests/noPassthroughWithMongod | |
parent | 54445c82d53a47b849247b22fc4e6ccbaf1a58d8 (diff) | |
download | mongo-ab5e8175f64c33606861c8b659e3708944177871.tar.gz |
SERVER-41947 Disallow using the system.views collection name as the source or target names in the rename command
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'}}] +})); +})(); |