RUBY-3392 Add QE range auto-encryption unified spec tests - #3095
Merged
comandeo-mongo merged 3 commits intoJul 29, 2026
Conversation
The unified test runner must drop enxcol_.<coll>.esc/.ecoc alongside the data collection so QE __safeContent__ tag counts are reproducible for exact matching, as required by the unified test format spec. Without this the QE-Text matching query fixtures fail on __safeContent__ comparison.
RUBY-3392 removed the old fle2v2-Range-* (rangePreview) fixtures but never added the fle2v2-Rangev2-* replacements, so QE range auto encryption has had no spec-driven coverage since. Import all 46 fixtures. Running them required three unified runner corrections the format mandates: - Parse fixtures in :bson mode so $numberLong/$date keep their types. The server rejects a range field whose min/max type differs from the field type. - Match errorContains case-insensitively. - Compare numbers by value across BSON integer widths, so BSON::Int64(3) equals 3. Parsing in :bson mode means autoEncryptOpts maps arrive already converted, so convert_client_options takes a parsed flag to skip re-parsing them; the legacy crud and transactions runners still pass raw extended JSON and are unchanged.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds unified spec coverage for Queryable Encryption (FLE2v2) Rangev2 auto-encryption by introducing the missing fle2v2-Rangev2-* fixtures and updating the unified spec runner to meet the unified test format requirements (BSON-mode parsing, errorContains matching, numeric comparisons, and initialData cleanup for QE metadata collections).
Changes:
- Add the Rangev2 unified YAML fixtures for QE range auto-encryption coverage.
- Update unified runner to parse fixtures in BSON mode, drop QE metadata collections during
initialDatasetup, and matcherrorContainscase-insensitively. - Normalize BSON integer wrappers in unified assertions so int32/int64 compare by numeric value.
Reviewed changes
Copilot reviewed 49 out of 49 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| spec/support/utils.rb | Add parsed: flag to avoid re-parsing already-BSON-typed autoEncryptOpts maps. |
| spec/runners/unified/test.rb | Unified runner fixes: drop QE metadata collections in initialData, pass parsed: true for autoEncryptOpts, and case-insensitive errorContains. |
| spec/runners/unified/test_group.rb | Parse unified fixtures in mode: :bson to preserve BSON numeric/date types. |
| spec/runners/unified/assertions.rb | Compare BSON int32/int64 wrappers by numeric value during result matching. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Compact.yml | Rangev2 compactStructuredEncryptionData unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Defaults.yml | Rangev2 defaults unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-WrongType.yml | Rangev2 wrong-type error-path unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Int-Aggregate.yml | Rangev2 int aggregate unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Int-Correctness.yml | Rangev2 int correctness unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Int-Delete.yml | Rangev2 int delete unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Int-FindOneAndUpdate.yml | Rangev2 int findOneAndUpdate unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Int-InsertFind.yml | Rangev2 int insert/find unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Int-Update.yml | Rangev2 int update unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Long-Aggregate.yml | Rangev2 long aggregate unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Long-Correctness.yml | Rangev2 long correctness unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Long-Delete.yml | Rangev2 long delete unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Long-FindOneAndUpdate.yml | Rangev2 long findOneAndUpdate unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Long-InsertFind.yml | Rangev2 long insert/find unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Long-Update.yml | Rangev2 long update unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Date-Aggregate.yml | Rangev2 date aggregate unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Date-Correctness.yml | Rangev2 date correctness unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Date-Delete.yml | Rangev2 date delete unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Date-FindOneAndUpdate.yml | Rangev2 date findOneAndUpdate unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Date-InsertFind.yml | Rangev2 date insert/find unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Date-Update.yml | Rangev2 date update unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Double-Aggregate.yml | Rangev2 double aggregate unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Double-Correctness.yml | Rangev2 double correctness unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Double-Delete.yml | Rangev2 double delete unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Double-FindOneAndUpdate.yml | Rangev2 double findOneAndUpdate unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Double-InsertFind.yml | Rangev2 double insert/find unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Double-Update.yml | Rangev2 double update unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DoublePrecision-Aggregate.yml | Rangev2 double-with-precision aggregate unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DoublePrecision-Correctness.yml | Rangev2 double-with-precision correctness unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DoublePrecision-Delete.yml | Rangev2 double-with-precision delete unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DoublePrecision-FindOneAndUpdate.yml | Rangev2 double-with-precision findOneAndUpdate unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DoublePrecision-InsertFind.yml | Rangev2 double-with-precision insert/find unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DoublePrecision-Update.yml | Rangev2 double-with-precision update unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Decimal-Aggregate.yml | Rangev2 decimal aggregate unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Decimal-Correctness.yml | Rangev2 decimal correctness unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Decimal-Delete.yml | Rangev2 decimal delete unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Decimal-FindOneAndUpdate.yml | Rangev2 decimal findOneAndUpdate unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Decimal-InsertFind.yml | Rangev2 decimal insert/find unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Decimal-Update.yml | Rangev2 decimal update unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DecimalPrecision-Aggregate.yml | Rangev2 decimal-with-precision aggregate unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DecimalPrecision-Correctness.yml | Rangev2 decimal-with-precision correctness unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DecimalPrecision-Delete.yml | Rangev2 decimal-with-precision delete unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DecimalPrecision-FindOneAndUpdate.yml | Rangev2 decimal-with-precision findOneAndUpdate unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DecimalPrecision-InsertFind.yml | Rangev2 decimal-with-precision insert/find unified fixture. |
| spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DecimalPrecision-Update.yml | Rangev2 decimal-with-precision update unified fixture. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jamis
approved these changes
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds the 46
fle2v2-Rangev2-*unified fixtures, giving QE range auto encryptionspec-driven coverage for the first time.
RUBY-3392 (#2894) removed the old
fle2v2-Range-*(rangePreview) fixtures but neveradded the Rangev2 replacements, so range auto encryption has had no unified coverage
since Aug 2024. Range GA shipped under RUBY-3457 on top of that gap.
Runner corrections
The fixtures do not pass without three unified-runner fixes the test format mandates:
:bsonmode so$numberLong/$datekeep their types. The serverrejects a range field whose
min/maxtype differs from the field type.errorContainscase-insensitively.BSON::Int64(3)equals3.Parsing in
:bsonmode means theautoEncryptOptsmaps arrive already converted, soUtils.convert_client_optionstakes aparsed:flag to skip re-parsing them. Withoutthis,
_apply_encrypted_fields_mapparsed them a second time and raisedUnknown value type: BSON::Int64infle2v2-InsertFind-keyAltName.yml. The legacy crudand transactions runners still pass raw extended JSON and are unchanged.
Dependency on #3088
The first commit (
drop enxcol_ metadata collections in unified initialData setup) ischerry-picked patch-identical from #3088, where it is also needed. Without it these
fixtures fail on exact
__safeContent__byte assertions, because value countsaccumulate in the
enxcol_.<coll>.esc/.ecocmetadata collections across runs. Rebasingafter #3088 merges will drop the duplicate automatically.
Testing
Local 9.0.0-rc0 replica set, crypt_shared 8.2.6, libmongocrypt-helper 1.20.1:
The pre-existing 76 and 588 failures are cloud-KMS credential env gaps, unaffected here.
RuboCop clean.