0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 17:10:48 +01:00

SERVER-35753 listCommands should include value for requiresAuth

This commit is contained in:
Adam Cooper 2019-07-24 16:54:44 -04:00
parent 9fd91d29a2
commit 2ff2b24ce6
2 changed files with 13 additions and 0 deletions

View File

@ -24,4 +24,16 @@
assert(commands["commands"].hasOwnProperty("isMaster"));
assert(commands["commands"].hasOwnProperty("insert"));
assert(commands["commands"].hasOwnProperty("ping"));
// Test that commands listed have required properties
const isMaster = commands["commands"]["isMaster"];
assert(isMaster.hasOwnProperty("help"));
assert(isMaster.hasOwnProperty("slaveOk"));
assert(isMaster.hasOwnProperty("adminOnly"));
assert(isMaster.hasOwnProperty("requiresAuth"));
// Test that requiresAuth outputs correct value
const insert = commands["commands"]["insert"];
assert(isMaster["requiresAuth"] === false);
assert(insert["requiresAuth"] === true);
})();

View File

@ -174,6 +174,7 @@ public:
for (const auto& c : commands) {
BSONObjBuilder temp(b.subobjStart(c->getName()));
temp.append("help", c->help());
temp.append("requiresAuth", c->requiresAuth());
temp.append("slaveOk",
c->secondaryAllowed(opCtx->getServiceContext()) ==
Command::AllowedOnSecondary::kAlways);