diff options
author | Lingzhi Deng <lingzhi.deng@mongodb.com> | 2020-11-09 20:32:26 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-11-10 04:00:23 +0000 |
commit | a36a312b744a419a3e065df99abb8c232bc93267 (patch) | |
tree | 9fa36ab142ee4d7a15573a65f95595024acb27c4 /src/mongo/idl/idl_test.cpp | |
parent | 21b2bc7ecb9b16d1043b2a6fe845127637ea3467 (diff) | |
download | mongo-a36a312b744a419a3e065df99abb8c232bc93267.tar.gz |
SERVER-52679: Disallow null/undefined command parameter for IDL commands with {namespace: type}
Diffstat (limited to 'src/mongo/idl/idl_test.cpp')
-rw-r--r-- | src/mongo/idl/idl_test.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mongo/idl/idl_test.cpp b/src/mongo/idl/idl_test.cpp index 6bfb54782f9..206aa0b5aaf 100644 --- a/src/mongo/idl/idl_test.cpp +++ b/src/mongo/idl/idl_test.cpp @@ -2837,6 +2837,14 @@ TEST(IDLTypeCommand, TestStruct) { assert_same_types<decltype(testStruct.getCommandParameter()), mongo::idl::import::One_string&>(); + // Negative: Command with struct parameter should disallow 'undefined' input. + { + auto invalidDoc = BSON(CommandTypeStructCommand::kCommandName << BSONUndefined << "$db" + << "db"); + ASSERT_THROWS(CommandTypeStructCommand::parse(ctxt, makeOMR(invalidDoc)), + AssertionException); + } + // Positive: Test we can roundtrip from the just parsed document { BSONObjBuilder builder; |