mongodb / specifications

Specifications related to MongoDB
http://specifications.readthedocs.io/en/latest
Other
389 stars 242 forks source link

DRIVERS-2619 Remove null values from `command_started_event` in fle2v2-CreateCollection.yml #1429

Closed kevinAlbs closed 1 year ago

kevinAlbs commented 1 year ago

Summary

The C driver incorrectly allows extra fields in subdocuments of the command. With this behavior fixed, the updated fle2v2-CreateCollection.yml test was run in this patch

Background & Motivation

DRIVERS-2524 added a legacy Client Side Encryption (CSE) test with embedded null fields in a command_started_event in fle2v2-CreateCollection.yml:

        - command_started_event:
            command:
              create: *encrypted_collection_name
              encryptedFields: &encrypted_fields_expectation {
                # Expect state collections are not included in the encryptedFields sent to the server.
                "escCollection": null,
                "ecocCollection": null,
                "eccCollection": null,

The null fields are intended to assert that escCollection, ecocCollection and eccCollection are not present in the encryptedFields document.

The legacy CSE format is based on the legacy Transactions test format. The legacy Transaction test README references the Command Monitoring Spec Tests runner:

If the test includes a list of command-started events in expectations, compare them to the actual command-started events using the same logic as the Command Monitoring Spec Tests runner, plus the rules in the Command-Started Events instructions below.

The legacy Command Monitoring Spec test format README was removed in https://github.com/mongodb/specifications/commit/c51e7373aab211ed673061bd6fdb542f655e413d#diff-5c0a965655147652fef540421431fb48533cd30c9120331276a7776ecc5171e2L62 and included:

The driver MUST assert the expected data is present and also MUST allow for additional data to be present as well at the top level of the command document or reply document.

However, if there are fields in command subdocuments that are not mentioned in the YAML, then the command does not pass the test

This suggests test runners are expected not to allow extra fields in subdocuments of the command. Test runners are not expected to handle null values specially for subdocuments of the command.

This resulted in necessary workarounds in the pymongo test runner.


Please complete the following before merging: