summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2021-12-13 11:21:33 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-12-16 18:53:43 +0000
commit817e61d303996e944c4c14e8df14b73f1eb15381 (patch)
tree1e87701c1b9e86ff20d6986ca487e7dfb2681c30
parent6b0aa52bef51b2a48909269f1b2e71015b3e83e7 (diff)
downloadmongo-817e61d303996e944c4c14e8df14b73f1eb15381.tar.gz
SERVER-61846 add redaction test for small fields
(cherry picked from commit c8de2a7f419f2486780fed5ae06ade4e78aa2a5d)
-rw-r--r--src/mongo/logv2/redaction_test.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mongo/logv2/redaction_test.cpp b/src/mongo/logv2/redaction_test.cpp
index e6feb6de33c..8ab293822c2 100644
--- a/src/mongo/logv2/redaction_test.cpp
+++ b/src/mongo/logv2/redaction_test.cpp
@@ -154,5 +154,18 @@ TEST(RedactBSONTest, BSONWithArrays) {
testBSONCases(testCases);
}
+
+TEST(RedactBSONTest, RedactCausesBSONTooLarge) {
+ logv2::setShouldRedactLogs(true);
+ BSONObjBuilder bob;
+ for (int i = 0; i < 1024 * 1024; i++) {
+ auto fieldName = "abcdefg";
+ // The value of each field is smaller than the size of the kRedactionDefaultMask.
+ bob.append(fieldName, 1);
+ }
+ const auto obj = bob.obj();
+ // Demonstrates it is possible to grow a BSON too large by redacting fields.
+ ASSERT_THROWS_CODE(redact(obj), DBException, ErrorCodes::BSONObjectTooLarge);
+}
} // namespace
} // namespace mongo