Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(NODE-4556): attempt to use exported BSON #443

Merged
merged 1 commit into from
Aug 19, 2022
Merged

Conversation

durran
Copy link
Member

@durran durran commented Aug 17, 2022

This updates the Node bindings to first attempt to use the exported BSON from the mongodb module before falling back to the old behaviour. This means that:

  • Driver 4.9.0 and higher will use the exported BSON from the driver itself.
  • Driver 4.x before 4.9.0 and driver 3.x will continue to use the bson object passed in the options or on client.topology

This allows driver 4.9.0 and higher to not need a connected client to be able to user csfle.

Main of the Node driver is now pinning on the latest commit in this PR and passing, running all live tests: https://spruce.mongodb.com/task/mongo_node_driver_next_ubuntu1804_custom_dependency_tests_run_custom_csfle_tests_latest_pinned_commit_40d485c292a14f8251a4e3724d1bb5f8cf11577c_22_08_17_20_53_00/tests?execution=0&sortBy=STATUS&sortDir=ASC

The patch build shows this works (since the tests pass and bson is no longer a dev dependency) but the dev dependency on mongodb will need to bump to the next release once mongodb/node-mongodb-native#3367 is merged.

Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

bindings/node/lib/autoEncrypter.js Outdated Show resolved Hide resolved
@durran durran changed the title fix(NODE-4516): attempt to use exported BSON fix(NODE-4556): attempt to use exported BSON Aug 17, 2022
@durran durran force-pushed the NODE-4516 branch 3 times, most recently from d773cf7 to 45e6ba7 Compare August 18, 2022 21:06
// This case is driver 4.9.0 and higher.
context('when mongodb exports BSON', function () {
context('when a bson option is provided', function () {
const bson = Object.assign({}, BSON);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We clone the original BSON module and use the clone as the bson option so it does not have object equality and then matches.

);

it('uses the mongodb exported BSON', function () {
expect(encrypter._bson).to.equal(BSON);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we provide no bson option we use the exported BSON from the driver.

const encrypter = new AutoEncrypter(
{},
{
bson: bson,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We ensure here we use the bson option.

});

context('when a bson option is not provided', function () {
const mongoNoBson = { ...mongodb, BSON: undefined };
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to ensure BSON is not exported by the module we inject.

@durran
Copy link
Member Author

durran commented Aug 19, 2022

This has also been rebased/squashed.

@baileympearson
Copy link
Contributor

filed a flakey test ticket for socks5 tests and restarted the run - https://jira.mongodb.org/browse/NODE-4567

@durran durran requested a review from nbbeeken August 19, 2022 18:24
@baileympearson baileympearson merged commit c071d5a into master Aug 19, 2022
@baileympearson baileympearson deleted the NODE-4516 branch August 19, 2022 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants