summaryrefslogtreecommitdiff
path: root/jstests/auth/explain_auth.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/auth/explain_auth.js')
-rw-r--r--jstests/auth/explain_auth.js73
1 files changed, 16 insertions, 57 deletions
diff --git a/jstests/auth/explain_auth.js b/jstests/auth/explain_auth.js
index a718ddf8653..70570324260 100644
--- a/jstests/auth/explain_auth.js
+++ b/jstests/auth/explain_auth.js
@@ -34,8 +34,7 @@ function testExplainAuth(authSpec) {
function assertCmdResult(result, expectSuccess) {
if (expectSuccess) {
assert.commandWorked(result);
- }
- else {
+ } else {
assert.commandFailedWithCode(result, 13);
}
}
@@ -49,58 +48,36 @@ function testExplainAuth(authSpec) {
assertCmdResult(cmdResult, authSpec.count);
// .group()
- cmdResult = db.runCommand({
- explain: {
- group: {
- ns: coll.getName(),
- key: "a",
- $reduce: function() { },
- initial: { }
- }
- }
- });
+ cmdResult = db.runCommand(
+ {explain: {group: {ns: coll.getName(), key: "a", $reduce: function() {}, initial: {}}}});
assertCmdResult(cmdResult, authSpec.group);
// .remove()
- cmdResult = db.runCommand({
- explain: {
- delete: coll.getName(),
- deletes: [ {q: {a: 1}, limit: 1} ]
- }
- });
+ cmdResult =
+ db.runCommand({explain: {delete: coll.getName(), deletes: [{q: {a: 1}, limit: 1}]}});
assertCmdResult(cmdResult, authSpec.remove);
// .update()
- cmdResult = db.runCommand({
- explain: {
- update: coll.getName(),
- updates: [ {q: {a: 1}, u: {$set: {b: 1}}} ]
- }
- });
+ cmdResult = db.runCommand(
+ {explain: {update: coll.getName(), updates: [{q: {a: 1}, u: {$set: {b: 1}}}]}});
assertCmdResult(cmdResult, authSpec.update);
}
// Create some user-defined roles which we will grant to the users below.
db.createRole({
role: "findOnly",
- privileges: [
- {resource: {db: db.getName(), collection: coll.getName()}, actions: ["find"]}
- ],
- roles: [ ]
+ privileges: [{resource: {db: db.getName(), collection: coll.getName()}, actions: ["find"]}],
+ roles: []
});
db.createRole({
role: "updateOnly",
- privileges: [
- {resource: {db: db.getName(), collection: coll.getName()}, actions: ["update"]}
- ],
- roles: [ ]
+ privileges: [{resource: {db: db.getName(), collection: coll.getName()}, actions: ["update"]}],
+ roles: []
});
db.createRole({
role: "removeOnly",
- privileges: [
- {resource: {db: db.getName(), collection: coll.getName()}, actions: ["remove"]}
- ],
- roles: [ ]
+ privileges: [{resource: {db: db.getName(), collection: coll.getName()}, actions: ["remove"]}],
+ roles: []
});
// Create three users:
@@ -116,31 +93,13 @@ admin.logout();
// The "find" action allows explain of read operations.
db.auth("findOnly", "pwd");
-testExplainAuth({
- find: true,
- count: true,
- group: true,
- remove: false,
- update: false
-});
+testExplainAuth({find: true, count: true, group: true, remove: false, update: false});
db.logout();
db.auth("updateOnly", "pwd");
-testExplainAuth({
- find: false,
- count: false,
- group: false,
- remove: false,
- update: true
-});
+testExplainAuth({find: false, count: false, group: false, remove: false, update: true});
db.logout();
db.auth("removeOnly", "pwd");
-testExplainAuth({
- find: false,
- count: false,
- group: false,
- remove: true,
- update: false
-});
+testExplainAuth({find: false, count: false, group: false, remove: true, update: false});
db.logout();