From 65dc4e1a0f1ef43c46eb878e2493326f7bafe297 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Fri, 19 Aug 2022 11:30:23 -0400 Subject: [PATCH] test(NODE-4556): address comments --- bindings/node/test/autoEncrypter.test.js | 10 ++++++---- bindings/node/test/clientEncryption.test.js | 20 ++++++++++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/bindings/node/test/autoEncrypter.test.js b/bindings/node/test/autoEncrypter.test.js index 9194486c9..8380739b5 100644 --- a/bindings/node/test/autoEncrypter.test.js +++ b/bindings/node/test/autoEncrypter.test.js @@ -111,8 +111,7 @@ describe('AutoEncrypter', function () { }); describe('#constructor', function () { - // This case is driver 4.9.0 and higher. - context('when mongodb exports BSON', function () { + context('when mongodb exports BSON (driver >= 4.9.0)', function () { context('when a bson option is provided', function () { const bson = Object.assign({}, BSON); const encrypter = new AutoEncrypter( @@ -144,10 +143,13 @@ describe('AutoEncrypter', function () { expect(encrypter._bson).to.equal(BSON); }); }); + + it('never uses bson from the topology', function () { + expect(() => new AutoEncrypter({}, {})).not.to.throw(); + }); }); - // This case is driver < 4.9.0. - context('when mongodb does not export BSON', function () { + context('when mongodb does not export BSON (driver < 4.9.0)', function () { context('when a bson option is provided', function () { const bson = Object.assign({}, BSON); const encrypter = new AutoEncrypter( diff --git a/bindings/node/test/clientEncryption.test.js b/bindings/node/test/clientEncryption.test.js index 52fafff11..cb482bcc1 100644 --- a/bindings/node/test/clientEncryption.test.js +++ b/bindings/node/test/clientEncryption.test.js @@ -63,8 +63,7 @@ describe('ClientEncryption', function () { } describe('#constructor', function () { - // This case is driver 4.9.0 and higher. - context('when mongodb exports BSON', function () { + context('when mongodb exports BSON (driver >= 4.9.0)', function () { context('when a bson option is provided', function () { const bson = Object.assign({}, BSON); const encrypter = new ClientEncryption( @@ -98,10 +97,23 @@ describe('ClientEncryption', function () { expect(encrypter._bson).to.equal(BSON); }); }); + + it('never uses bson from the topology', function () { + expect(() => { + new ClientEncryption( + {}, + { + keyVaultNamespace: 'client.encryption', + kmsProviders: { + local: { key: Buffer.alloc(96) } + } + } + ) + }).not.to.throw(); + }); }); - // This case is driver < 4.9.0. - context('when mongodb does not export BSON', function () { + context('when mongodb does not export BSON (driver < 4.9.0)', function () { context('when a bson option is provided', function () { const bson = Object.assign({}, BSON); const encrypter = new ClientEncryption(