jstests/fle2/libs/encrypted_client_util.js
/**
     * Assert the number of documents in the EDC and state collections is correct.
     *
     * @param {object} collection Collection object for EDC
     * @param {number} edc Number of documents in EDC
     * @param {number} esc Number of documents in ESC
     * @param {number} ecc Number of documents in ECC
     * @param {number} ecoc Number of documents in ECOC
     */
Assert the number of documents in the EDC and state collections is correct.
Assert the number of documents in the EDC and state collections is correct .
assertEncryptedCollectionCountsByObject(
        sessionDB, name, expectedEdc, expectedEsc, expectedEcc, expectedEcoc) {
        const cis = this._db.getCollectionInfos({"name": name});
        assert.eq(cis.length, 1, `Expected to find one collection named '${name}'`);
        const ci = cis[0];
        assert(ci.hasOwnProperty("options"), `Expected collection '${name}' to have 'options'`);
        const options = ci.options;
        assert(options.hasOwnProperty("encryptedFields"),
               `Expected collection '${name}' to have 'encryptedFields'`);
        const ef = options.encryptedFields;
        const actualEdc = sessionDB.getCollection(name).countDocuments({});
        assert.eq(actualEdc,
                  expectedEdc,
                  `EDC document count is wrong: Actual ${actualEdc} vs Expected ${expectedEdc}`);
        const actualEsc = sessionDB.getCollection(ef.escCollection).countDocuments({});
        assert.eq(actualEsc,
                  expectedEsc,
                  `ESC document count is wrong: Actual ${actualEsc} vs Expected ${expectedEsc}`);
        const actualEcc = sessionDB.getCollection(ef.eccCollection).countDocuments({});
        assert.eq(actualEcc,
                  expectedEcc,
                  `ECC document count is wrong: Actual ${actualEcc} vs Expected ${expectedEcc}`);
        const actualEcoc = sessionDB.getCollection(ef.ecocCollection).countDocuments({});
        assert.eq(actualEcoc,
                  expectedEcoc,
                  `ECOC document count is wrong: Actual ${actualEcoc} vs Expected ${expectedEcoc}`);
    }
assertEncryptedCollectionCountsByObject ( sessionDB , name , expectedEdc , expectedEsc , expectedEcc , expectedEcoc ) { const cis = this . _db . getCollectionInfos ( { "name" : name } ) ; assert . eq ( cis . length , 1 , ` ${ name } ` ) ; const ci = cis [ 0 ] ; assert ( ci . hasOwnProperty ( "options" ) , ` ${ name } ` ) ; const options = ci . options ; assert ( options . hasOwnProperty ( "encryptedFields" ) , ` ${ name } ` ) ; const ef = options . encryptedFields ; const actualEdc = sessionDB . getCollection ( name ) . countDocuments ( { } ) ; assert . eq ( actualEdc , expectedEdc , ` ${ actualEdc } ${ expectedEdc } ` ) ; const actualEsc = sessionDB . getCollection ( ef . escCollection ) . countDocuments ( { } ) ; assert . eq ( actualEsc , expectedEsc , ` ${ actualEsc } ${ expectedEsc } ` ) ; const actualEcc = sessionDB . getCollection ( ef . eccCollection ) . countDocuments ( { } ) ; assert . eq ( actualEcc , expectedEcc , ` ${ actualEcc } ${ expectedEcc } ` ) ; const actualEcoc = sessionDB . getCollection ( ef . ecocCollection ) . countDocuments ( { } ) ; assert . eq ( actualEcoc , expectedEcoc , ` ${ actualEcoc } ${ expectedEcoc } ` ) ; }
Assert the number of documents in the EDC and state collections is correct.
Assert the number of documents in the EDC and state collections is correct .