summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/api_version_parameters_shell.js
diff options
context:
space:
mode:
authorNicholas Zolnierz <nicholas.zolnierz@mongodb.com>2021-10-12 20:40:45 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-10-12 21:21:26 +0000
commita8bb7e666abb24d8caa27b33d484e8d1e871c458 (patch)
treecd9645f00c23af72d0c479de99954912d78229cb /jstests/noPassthrough/api_version_parameters_shell.js
parent16e286d3e4bc3fdbfee99a965d3654335566c3ec (diff)
downloadmongo-a8bb7e666abb24d8caa27b33d484e8d1e871c458.tar.gz
SERVER-56905 Ban API params to aggregate/find/etc shell helpers
Diffstat (limited to 'jstests/noPassthrough/api_version_parameters_shell.js')
-rw-r--r--jstests/noPassthrough/api_version_parameters_shell.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/jstests/noPassthrough/api_version_parameters_shell.js b/jstests/noPassthrough/api_version_parameters_shell.js
index 894469159b6..77a4fee2094 100644
--- a/jstests/noPassthrough/api_version_parameters_shell.js
+++ b/jstests/noPassthrough/api_version_parameters_shell.js
@@ -191,6 +191,23 @@ if (m.adminCommand('buildinfo').modules.indexOf('enterprise') > -1) {
assert.eq(result, 0, `Error running shell with script '${testPrompt}'`);
}
+// Test that shell helpers which return a cursor do not accept API versioning parameters. This is to
+// avoid the potential pitfall of sending API parameters on the initial command but not on
+// subsequent getMore's.
+const coll = m.getDB("test").collection;
+assert.throws(() => coll.aggregate([], {apiVersion: 1}));
+assert.throws(() => coll.aggregate([], {apiStrict: true}));
+assert.throws(() => coll.aggregate([], {apiDeprecationErrors: true}));
+assert.throws(() => coll.find({}, {}, 1, 0, 1, {apiVersion: 1}));
+assert.throws(() => coll.find({}, {}, 1, 0, 1, {apiStrict: true}));
+assert.throws(() => coll.find({}, {}, 1, 0, 1, {apiDeprecationErrors: true}));
+assert.throws(() => coll.watch({}, {apiVersion: 1}));
+assert.throws(() => coll.watch({}, {apiStrict: true}));
+assert.throws(() => coll.watch({}, {apiDeprecationErrors: true}));
+assert.throws(() => coll.getDB().watch({}, {apiVersion: 1}));
+assert.throws(() => coll.getDB().watch({}, {apiStrict: true}));
+assert.throws(() => coll.getDB().watch({}, {apiDeprecationErrors: true}));
+
/*
* Mongo-specific tests.
*/