forked from mongodb/mongo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist_commands.js
45 lines (39 loc) · 1.52 KB
/
list_commands.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Test for listCommands.
// @tags: [multiversion_incompatible]
var commands = db.runCommand({listCommands: 1});
assert.commandWorked(commands);
// Test that result is sorted.
function isSorted(obj) {
var previousProperty;
for (var property in obj["commands"]) {
if (previousProperty && (previousProperty > property)) {
return false;
}
previousProperty = property;
}
return true;
}
assert(isSorted(commands));
// Test that result contains basic commands.
assert(commands.hasOwnProperty("commands"));
assert(commands["commands"].hasOwnProperty("hello"));
assert(commands["commands"].hasOwnProperty("isMaster"));
assert(commands["commands"].hasOwnProperty("insert"));
assert(commands["commands"].hasOwnProperty("ping"));
// Test that commands listed have required properties
const hello = commands["commands"]["hello"];
assert(hello.hasOwnProperty("help"));
assert(hello.hasOwnProperty("secondaryOk"));
assert(hello.hasOwnProperty("adminOnly"));
assert(hello.hasOwnProperty("requiresAuth"));
// Test that commands listed have required properties
const isMaster = commands["commands"]["isMaster"];
assert(isMaster.hasOwnProperty("help"));
assert(isMaster.hasOwnProperty("secondaryOk"));
assert(isMaster.hasOwnProperty("adminOnly"));
assert(isMaster.hasOwnProperty("requiresAuth"));
// Test that requiresAuth outputs correct value
const insert = commands["commands"]["insert"];
assert(hello["requiresAuth"] === false);
assert(isMaster["requiresAuth"] === false);
assert(insert["requiresAuth"] === true);