diff options
author | Adam Midvidy <amidvidy@gmail.com> | 2015-04-06 18:49:59 -0400 |
---|---|---|
committer | Adam Midvidy <amidvidy@gmail.com> | 2015-04-06 18:49:59 -0400 |
commit | d6cd29d1fc0594657fcb2b69ce8334df85f9ba54 (patch) | |
tree | 2c3b8bc2d3726dbde6e1abdb97d3bcb53808cd90 /jstests/auth | |
parent | 7ea3fc90c6c1f175da1e76ff79b1e6ae09377141 (diff) | |
download | mongo-d6cd29d1fc0594657fcb2b69ce8334df85f9ba54.tar.gz |
SERVER-7775 add killOp command
Diffstat (limited to 'jstests/auth')
-rw-r--r-- | jstests/auth/auth3.js | 2 | ||||
-rw-r--r-- | jstests/auth/basic_role_auth.js | 3 | ||||
-rw-r--r-- | jstests/auth/lib/commands_lib.js | 33 | ||||
-rw-r--r-- | jstests/auth/pseudo_commands.js | 45 |
4 files changed, 37 insertions, 46 deletions
diff --git a/jstests/auth/auth3.js b/jstests/auth/auth3.js index a148b936153..b22c86b87b4 100644 --- a/jstests/auth/auth3.js +++ b/jstests/auth/auth3.js @@ -13,7 +13,7 @@ assert.eq(x.err, "unauthorized", tojson(x)); x = admin.killOp(123); assert(!("info" in x), tojson(x)); -assert.eq(x.err, "unauthorized", tojson(x)); +assert.eq(x.code, errorCodeUnauthorized, tojson(x)); x = admin.fsyncUnlock(); assert(x.errmsg != "not locked", tojson(x)); diff --git a/jstests/auth/basic_role_auth.js b/jstests/auth/basic_role_auth.js index 95b18050116..1122951fd25 100644 --- a/jstests/auth/basic_role_auth.js +++ b/jstests/auth/basic_role_auth.js @@ -149,9 +149,10 @@ var testOps = function(db, allowedActions) { }); checkErr(allowedActions.hasOwnProperty('killOp'), function() { + var errorCodeUnauthorized = 13; var res = db.killOp(1); - if (res.err == 'unauthorized') { + if (res.code == errorCodeUnauthorized) { throw Error("unauthorized killOp"); } }); diff --git a/jstests/auth/lib/commands_lib.js b/jstests/auth/lib/commands_lib.js index 8e8f22b2363..25827201154 100644 --- a/jstests/auth/lib/commands_lib.js +++ b/jstests/auth/lib/commands_lib.js @@ -1463,6 +1463,39 @@ var authCommandsLib = { ] }, { + testname: "killOp", // standalone version + command: {killOp: 1, op: 123}, + skipSharded: true, + testcases : [ + { + runOnDb: adminDbName, + roles: roles_hostManager, + privileges: [ + { resource: {cluster: true}, actions: ["killop"] } + ] + }, + { runOnDb: firstDbName, roles: {} }, + { runOnDb: secondDbName, roles: {} } + ] + }, + { + testname: "killOp", // sharded version + command: {killOp: 1, op: "shard1:123"}, + skipStandalone: true, + testcases : [ + { + runOnDb: adminDbName, + roles: roles_hostManager, + privileges: [ + { resource: {cluster: true}, actions: ["killop"] } + ], + expectFail: true // we won't be able to find the shardId + }, + { runOnDb: firstDbName, roles: {} }, + { runOnDb: secondDbName, roles: {} } + ] + }, + { testname: "listCommands", command: {listCommands: 1}, testcases: [ diff --git a/jstests/auth/pseudo_commands.js b/jstests/auth/pseudo_commands.js index 17cbf25a8e1..006d84e147d 100644 --- a/jstests/auth/pseudo_commands.js +++ b/jstests/auth/pseudo_commands.js @@ -119,59 +119,16 @@ function runTest(conn) { } var res = db.killOp(opid); printjson(res); - passed = !res.err && !res['$err']; + passed = res.ok && !res.errmsg && !res.err && !res['$err']; } catch (e) { passed = false; } - assert.eq(shouldPass, passed); } testProperAuthorization(testFunc, roles, privilege); })(); - (function testKillop() { - jsTestLog("Testing killOp"); - - var roles = {read: false, - readAnyDatabase: false, - readWrite: false, - readWriteAnyDatabase: false, - dbAdmin: false, - dbAdminAnyDatabase: false, - dbOwner: false, - clusterMonitor: false, - clusterManager: false, - hostManager: true, - clusterAdmin: true, - root: true, - __system: true - }; - - var privilege = { resource: {cluster: true}, actions: ['killop'] }; - - var testFunc = function(shouldPass) { - var passed = true; - try { - var opid; - if (isMongos(db)) { // opid format different between mongos and mongod - opid = "shard0000:1234"; - } else { - opid = 1234; - } - var res = db.killOp(opid); - printjson(res); - passed = !res.err && !res['$err']; - } catch (e) { - passed = false; - } - - assert.eq(shouldPass, passed); - } - - testProperAuthorization(testFunc, roles, privilege); - })(); - (function testUnlock() { if (isMongos(db)) { return; // unlock doesn't work on mongos |