summaryrefslogtreecommitdiff
path: root/jstests/auth
diff options
context:
space:
mode:
authorIan Boros <puppyofkosh@gmail.com>2019-05-10 18:14:36 -0400
committerIan Boros <puppyofkosh@gmail.com>2019-05-15 12:26:19 -0400
commit757caf626b23571954c0ca1cbbf97e50b1e60d83 (patch)
tree09f4c72be46ea20477fb823e2d11147eb5aabaf1 /jstests/auth
parentdfedea7a2ab7de40f984210fa8381664cbe37be9 (diff)
downloadmongo-757caf626b23571954c0ca1cbbf97e50b1e60d83.tar.gz
SERVER-409050 auth test for searchBeta agg stage
Diffstat (limited to 'jstests/auth')
-rw-r--r--jstests/auth/lib/commands_lib.js49
1 files changed, 45 insertions, 4 deletions
diff --git a/jstests/auth/lib/commands_lib.js b/jstests/auth/lib/commands_lib.js
index 96970cdef91..2580ebe6635 100644
--- a/jstests/auth/lib/commands_lib.js
+++ b/jstests/auth/lib/commands_lib.js
@@ -5933,6 +5933,46 @@ var authCommandsLib = {
}
},
{
+ testname: "aggregate_$searchBeta",
+ command: {
+ aggregate: "foo",
+ cursor: {},
+ pipeline: [{
+ $searchBeta: {
+ // empty query
+ }
+ }]
+ },
+ skipSharded: false,
+ // Only enterprise knows of this aggregation stage.
+ skipTest:
+ (conn) =>
+ !conn.getDB("admin").runCommand({buildInfo: 1}).modules.includes("enterprise"),
+ testcases: [
+ {
+ runOnDb: firstDbName,
+ roles: roles_read,
+ privileges: [{resource: {db: firstDbName, collection: "foo"}, actions: ["find"]}]
+ },
+ {
+ runOnDb: secondDbName,
+ roles: roles_readAny,
+ privileges:
+ [{resource: {db: secondDbName, collection: "foo"}, actions: ["find"]}]
+ }
+ ],
+ setup: function(db) {
+ // Configure the $searchBeta stage to always return EOF so we can avoid the hassle
+ // of giving mongod a host and port for mongot.
+ const cmd = {configureFailPoint: "searchBetaReturnEofImmediately", mode: "alwaysOn"};
+ FixtureHelpers.runCommandOnEachPrimary({db: db.getSiblingDB("admin"), cmdObj: cmd});
+ },
+ teardown: function(db) {
+ const cmd = {configureFailPoint: "searchBetaReturnEofImmediately", mode: "off"};
+ FixtureHelpers.runCommandOnEachPrimary({db: db.getSiblingDB("admin"), cmdObj: cmd});
+ }
+ },
+ {
testname: "startRecordingTraffic",
command: {startRecordingTraffic: 1, filename: "notARealPath"},
testcases: [
@@ -5979,18 +6019,18 @@ var authCommandsLib = {
* An array of strings. Each string in the array reports
* a particular test error.
*/
- runOneTest: function(conn, t, impls) {
+ runOneTest: function(conn, t, impls, isMongos) {
jsTest.log("Running test: " + t.testname);
if (t.skipTest && t.skipTest(conn)) {
return [];
}
// some tests shouldn't run in a sharded environment
- if (t.skipSharded && this.isMongos(conn)) {
+ if (t.skipSharded && isMongos) {
return [];
}
// others shouldn't run in a standalone environment
- if (t.skipUnlessSharded && !this.isMongos(conn)) {
+ if (t.skipUnlessSharded && !isMongos) {
return [];
}
// some tests require replica sets to be enabled.
@@ -6043,8 +6083,9 @@ var authCommandsLib = {
var failures = [];
+ const isMongos = this.isMongos(conn);
for (var i = 0; i < this.tests.length; i++) {
- res = this.runOneTest(conn, this.tests[i], impls);
+ res = this.runOneTest(conn, this.tests[i], impls, isMongos);
failures = failures.concat(res);
}