Skip to content

test(NODE-4663): add csfle prose test 20 #4585

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

baileympearson
Copy link
Contributor

@baileympearson baileympearson commented Jul 16, 2025

Description

What is changing?

This PR adds CSFLE prose test 20.

Is there new documentation needed for these changes?

What is the motivation for this change?

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@baileympearson baileympearson marked this pull request as ready for review July 16, 2025 17:45
@baileympearson baileympearson requested a review from a team as a code owner July 16, 2025 17:45
@dariakp dariakp self-assigned this Jul 18, 2025
@dariakp dariakp added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Jul 18, 2025
let client: MongoClient;

beforeEach(function () {
if (!ClientSideEncryptionFilter.cryptShared) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious why we went with storing and accessing this info via static props instead of accessing it from the test suite context.

It looks like the ClientSideEncryptionFilter initialize method does add it to the context in addition to storing it on the class, so it wasn't immediately obvious to me why we need both.

    context.clientSideEncryption = {
      enabled: this.enabled,
      mongodbClientEncryption,
      version: ClientSideEncryptionFilter.version,
      libmongocrypt: ClientSideEncryptionFilter.libmongocrypt,
      cryptShared: ClientSideEncryptionFilter.cryptShared
    };

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't realize we also stored it on the test configuration. I can adjust the implementation, if you're prefer that approach.

Copy link
Contributor

Choose a reason for hiding this comment

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

I just think it's best to aim for consistency, though perhaps it's out of scope for this PR. What I see is that the ClientSideEncryptionFilter is the only filter that uses static properties in addition to setting context (compare to MongoDBVersionFilter or MongoDBTopologyFilter), and the tests that rely on that filter seem to primarily use those static accessors, with the notable exception of unified-utils, which reads the enabled property from the context instead.

So, if we want to be generally consistent with the rest of the filters, we'd probably want to remove the static accessors and rely on the context. But if we want to be consistent within the use of just this filter, then we'd want to remove the context setting and just use the static props.

It's a hard call because while I think that reading this info from context is somewhat more intuitive than reading it from the filters (since the filters are just one of the mechanisms of extracting environment info, and the rest of the environment info gets pushed onto the context), reading the info explicitly from the individual filters makes it easier to track relevant usage in our test code.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'm happy to make this change. I don't think it would be too much additional work.

Looking at the tests, I did find

export const cryptShared = (status: 'enabled' | 'disabled') => () => {
. This is used in tandem with the predicate filter to skip tests without requiring a beforeEach hook (which in turn requires a describe around it):

it(
    'should autoSpawn a mongocryptd on init by default',
    { requires: { clientSideEncryption: true, predicate: cryptShared('disabled') } },
    async function () {
     ...
    }
  );

this.configuration isn't available in the predicate, so we use the cryptShared static property instead.

Maybe it makes sense to

  1. remove all static properties from the ClientEncryption filter for consistency with other filters
  2. define a filter that filters for crypt shared loaded / not loaded (requires: { crypt_shared: 'loaded' })

Thoughts? I can make those changes if we want, I don't think it would take much effort or expand the scope of this work much.

Copy link
Contributor

Choose a reason for hiding this comment

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

That works for me, I support quick wins for consistency :)

@baileympearson baileympearson requested a review from dariakp July 18, 2025 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Primary Review In Review with primary reviewer, not yet ready for team's eyes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants