summaryrefslogtreecommitdiff
path: root/jstests/disk
diff options
context:
space:
mode:
authorRichard Hausman <richard.hausman@mongodb.com>2022-08-02 13:45:56 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-08-02 14:41:11 +0000
commitfc5d35bb08d81f0cd165296760c4ab7506fcff1c (patch)
tree4b2cdaea5e6ad42abe4b1df8f24288e484472218 /jstests/disk
parentb7cebdc9e7ea7b1c9be1bbfa8a9b52689c0bb450 (diff)
downloadmongo-fc5d35bb08d81f0cd165296760c4ab7506fcff1c.tar.gz
SERVER-67877 : Check for UUID validity in BSON documents.
Diffstat (limited to 'jstests/disk')
-rw-r--r--jstests/disk/validate_bson_inconsistency.js29
1 files changed, 28 insertions, 1 deletions
diff --git a/jstests/disk/validate_bson_inconsistency.js b/jstests/disk/validate_bson_inconsistency.js
index 9de62f5e501..d29ae740f8c 100644
--- a/jstests/disk/validate_bson_inconsistency.js
+++ b/jstests/disk/validate_bson_inconsistency.js
@@ -34,8 +34,35 @@ resetDbpath(dbpath);
let res = assert.commandWorked(testColl.validate());
assert(res.valid, tojson(res));
- // TODO: Check the warnings that the documents with duplicate field names are detected.
+ MongoRunner.stopMongod(mongod, null, {skipValidation: true});
+})();
+(function validateDocumentsInvalidUUIDLength() {
+ let mongod = startMongodOnExistingPath(dbpath);
+ let db = mongod.getDB(baseName);
+ const collName = collNamePrefix + count++;
+ db.createCollection(collName);
+ let coll = db[collName];
+
+ jsTestLog(
+ "Checks that warnings are triggered when validating UUIDs that are either too short or too long.");
+ coll.insert({u: HexData(4, "deadbeefdeadbeefdeadbeefdeadbeef")});
+ coll.insert({u: HexData(4, "deadbeef")});
+ coll.insert({
+ u: HexData(
+ 4,
+ "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef")
+ });
+
+ let res = coll.validate({checkBSONConsistency: true});
+ assert(res.valid, tojson(res));
+ assert.eq(res.nNonCompliantDocuments, 2);
+ assert.eq(res.warnings.length, 1);
+
+ res = coll.validate({checkBSONConsistency: false});
+ assert(res.valid, tojson(res));
+ assert.eq(res.nNonCompliantDocuments, 2);
+ assert.eq(res.warnings.length, 1);
MongoRunner.stopMongod(mongod, null, {skipValidation: true});
})();