summaryrefslogtreecommitdiff
path: root/jstests/auth
diff options
context:
space:
mode:
authorSpencer Jackson <spencer.jackson@mongodb.com>2018-09-21 10:20:19 -0400
committerSpencer Jackson <spencer.jackson@mongodb.com>2018-11-21 11:45:52 -0500
commitebd39fc0df856937c0be9d5c686f841ef02abb55 (patch)
tree2e3a4087b501924528fbddf244de30c5ffc84c56 /jstests/auth
parent925d776b081b02b0034094d8c1277946f43a4f56 (diff)
downloadmongo-ebd39fc0df856937c0be9d5c686f841ef02abb55.tar.gz
SERVER-36829: Let users kill their own cursors
Diffstat (limited to 'jstests/auth')
-rw-r--r--jstests/auth/kill_cursors.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/jstests/auth/kill_cursors.js b/jstests/auth/kill_cursors.js
index 3264bbcc15b..dc49c7dba59 100644
--- a/jstests/auth/kill_cursors.js
+++ b/jstests/auth/kill_cursors.js
@@ -53,12 +53,35 @@
}
doKill({});
+
if ((authUsers.length === 1) && (killUsers.length === 1)) {
// Session variant only makes sense with single auth'd users.
doKill({lsid: {id: BinData(4, "QlLfPHTySm6tqfuV+EOsVA==")}});
}
}
+ function trySelfKill(user) {
+ const db = user[1];
+ assert(db.auth(user[0], 'pass'));
+
+ assert.commandWorked(db.runCommand({startSession: 1}));
+
+ const cmd = {
+ aggregate: 1,
+ pipeline: [{$listLocalSessions: {}}],
+ cursor: {batchSize: 0}
+ };
+ const res = assert.commandWorked(db.runCommand(cmd));
+ print(tojson(res));
+ const id = res.cursor.id;
+ assert.neq(id, 0, "Invalid cursor ID");
+
+ const killCmdRes = db.runCommand({killCursors: db.getName() + ".$cmd", cursors: [id]});
+ db.logout();
+
+ assert.commandWorked(killCmdRes, "Unable to kill cursor");
+ }
+
/**
* Create user1/user2 in testA, and user3/user4 in testB.
* Create two 101 element collections in testA and testB.
@@ -81,6 +104,7 @@
testA.createUser({user: 'user2', pwd: 'pass', roles: jsTest.basicUserRoles});
testB.createUser({user: 'user3', pwd: 'pass', roles: jsTest.basicUserRoles});
testB.createUser({user: 'user4', pwd: 'pass', roles: jsTest.basicUserRoles});
+ testB.createUser({user: 'user5', pwd: 'pass', roles: []});
admin.logout();
// Create a collection with batchable data
@@ -98,6 +122,9 @@
tryKill(testA, [['user2', testA]], [['user2', testA]], true);
tryKill(testB, [['user3', testB]], [['user3', testB]], true);
tryKill(testB, [['user4', testB]], [['user4', testB]], true);
+ trySelfKill(['user1', testA]);
+ trySelfKill(['user5', testB]);
+ trySelfKill(['admin', admin]);
// A user cannot kill someone else's cursor.
tryKill(testA, [['user1', testA]], [['user2', testA]], false);