Skip to content

Commit 73719ca

Browse files
committed
PHPLIB-1393: Update spec tests for QE range protocol V2
Synced with mongodb/specifications@9bfa512 Also updates prose test links to the new README.md file
1 parent 95df33d commit 73719ca

File tree

52 files changed

+738
-694
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+738
-694
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"php": "^7.4 || ^8.0",
1414
"ext-hash": "*",
1515
"ext-json": "*",
16-
"ext-mongodb": "^1.19.0",
16+
"ext-mongodb": "^1.20.0",
1717
"composer-runtime-api": "^2.0",
1818
"psr/log": "^1.1.4|^2|^3",
1919
"symfony/polyfill-php80": "^1.27",

tests/SpecTests/ClientSideEncryption/Prose22_RangeExplicitEncryptionTest.php

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/**
2525
* Prose test 22: Range Explicit Encryption
2626
*
27-
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.rst#range-explicit-encryption
27+
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.md#22-range-explicit-encryption
2828
* @group csfle
2929
* @group serverless
3030
*/
@@ -43,8 +43,7 @@ public function setUp(): void
4343
$this->markTestSkipped('Range explicit encryption tests require replica sets');
4444
}
4545

46-
$this->skipIfServerVersion('<', '7.0.0', 'Range explicit encryption tests require MongoDB 7.0 or later');
47-
$this->skipIfServerVersion('>=', '8.0.0', 'Range explicit encryption tests require MongoDB 8.0 or earlier');
46+
$this->skipIfServerVersion('<', '8.0.0', 'Range explicit encryption tests require MongoDB 8.0 or later');
4847

4948
$client = static::createTestClient();
5049

@@ -92,7 +91,7 @@ public function setUpWithTypeAndRangeOpts(string $type, array $rangeOpts): void
9291

9392
$encryptOpts = [
9493
'keyId' => $this->key1Id,
95-
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
94+
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
9695
'contentionFactor' => 0,
9796
'rangeOpts' => $rangeOpts,
9897
];
@@ -117,7 +116,7 @@ public function tearDown(): void
117116
$this->encryptedClient = null;
118117
}
119118

120-
/** @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.rst#test-setup-rangeopts */
119+
/** @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.md#test-setup-rangeopts */
121120
public static function provideTypeAndRangeOpts(): Generator
122121
{
123122
// TODO: skip DecimalNoPrecision test on mongos
@@ -180,7 +179,7 @@ public static function provideTypeAndRangeOpts(): Generator
180179
}
181180

182181
/**
183-
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.rst#case-1-can-decrypt-a-payload
182+
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.md#case-1-can-decrypt-a-payload
184183
* @dataProvider provideTypeAndRangeOpts
185184
*/
186185
public function testCase1_CanDecryptAPayload(string $type, array $rangeOpts): void
@@ -189,7 +188,7 @@ public function testCase1_CanDecryptAPayload(string $type, array $rangeOpts): vo
189188

190189
$encryptOpts = [
191190
'keyId' => $this->key1Id,
192-
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
191+
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
193192
'contentionFactor' => 0,
194193
'rangeOpts' => $rangeOpts,
195194
];
@@ -214,7 +213,7 @@ public function testCase1_CanDecryptAPayload(string $type, array $rangeOpts): vo
214213
}
215214

216215
/**
217-
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.rst#case-2-can-find-encrypted-range-and-return-the-maximum
216+
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.md#case-2-can-find-encrypted-range-and-return-the-maximum
218217
* @dataProvider provideTypeAndRangeOpts
219218
*/
220219
public function testCase2_CanFindEncryptedRangeAndReturnTheMaximum(string $type, array $rangeOpts): void
@@ -223,8 +222,8 @@ public function testCase2_CanFindEncryptedRangeAndReturnTheMaximum(string $type,
223222

224223
$encryptOpts = [
225224
'keyId' => $this->key1Id,
226-
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
227-
'queryType' => ClientEncryption::QUERY_TYPE_RANGE_PREVIEW,
225+
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
226+
'queryType' => ClientEncryption::QUERY_TYPE_RANGE,
228227
'contentionFactor' => 0,
229228
'rangeOpts' => $rangeOpts,
230229
];
@@ -252,7 +251,7 @@ public function testCase2_CanFindEncryptedRangeAndReturnTheMaximum(string $type,
252251
}
253252

254253
/**
255-
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.rst#case-3-can-find-encrypted-range-and-return-the-minimum
254+
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.md#case-3-can-find-encrypted-range-and-return-the-minimum
256255
* @dataProvider provideTypeAndRangeOpts
257256
*/
258257
public function testCase3_CanFindEncryptedRangeAndReturnTheMinimum(string $type, array $rangeOpts): void
@@ -261,8 +260,8 @@ public function testCase3_CanFindEncryptedRangeAndReturnTheMinimum(string $type,
261260

262261
$encryptOpts = [
263262
'keyId' => $this->key1Id,
264-
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
265-
'queryType' => ClientEncryption::QUERY_TYPE_RANGE_PREVIEW,
263+
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
264+
'queryType' => ClientEncryption::QUERY_TYPE_RANGE,
266265
'contentionFactor' => 0,
267266
'rangeOpts' => $rangeOpts,
268267
];
@@ -289,7 +288,7 @@ public function testCase3_CanFindEncryptedRangeAndReturnTheMinimum(string $type,
289288
}
290289

291290
/**
292-
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.rst#case-4-can-find-encrypted-range-with-an-open-range-query
291+
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.md#case-4-can-find-encrypted-range-with-an-open-range-query
293292
* @dataProvider provideTypeAndRangeOpts
294293
*/
295294
public function testCase4_CanFindEncryptedRangeWithAnOpenRangeQuery(string $type, array $rangeOpts): void
@@ -298,8 +297,8 @@ public function testCase4_CanFindEncryptedRangeWithAnOpenRangeQuery(string $type
298297

299298
$encryptOpts = [
300299
'keyId' => $this->key1Id,
301-
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
302-
'queryType' => ClientEncryption::QUERY_TYPE_RANGE_PREVIEW,
300+
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
301+
'queryType' => ClientEncryption::QUERY_TYPE_RANGE,
303302
'contentionFactor' => 0,
304303
'rangeOpts' => $rangeOpts,
305304
];
@@ -317,7 +316,7 @@ public function testCase4_CanFindEncryptedRangeWithAnOpenRangeQuery(string $type
317316
}
318317

319318
/**
320-
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.rst#case-5-can-run-an-aggregation-expression-inside-expr
319+
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.md#case-5-can-run-an-aggregation-expression-inside-expr
321320
* @dataProvider provideTypeAndRangeOpts
322321
*/
323322
public function testCase5_CanRunAnAggregationExpressionInsideExpr(string $type, array $rangeOpts): void
@@ -326,8 +325,8 @@ public function testCase5_CanRunAnAggregationExpressionInsideExpr(string $type,
326325

327326
$encryptOpts = [
328327
'keyId' => $this->key1Id,
329-
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
330-
'queryType' => ClientEncryption::QUERY_TYPE_RANGE_PREVIEW,
328+
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
329+
'queryType' => ClientEncryption::QUERY_TYPE_RANGE,
331330
'contentionFactor' => 0,
332331
'rangeOpts' => $rangeOpts,
333332
];
@@ -350,7 +349,7 @@ public function testCase5_CanRunAnAggregationExpressionInsideExpr(string $type,
350349
}
351350

352351
/**
353-
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.rst#case-6-encrypting-a-document-greater-than-the-maximum-errors
352+
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.md#case-6-encrypting-a-document-greater-than-the-maximum-errors
354353
* @dataProvider provideTypeAndRangeOpts
355354
*/
356355
public function testCase6_EncryptingADocumentGreaterThanTheMaximumErrors(string $type, array $rangeOpts): void
@@ -363,7 +362,7 @@ public function testCase6_EncryptingADocumentGreaterThanTheMaximumErrors(string
363362

364363
$encryptOpts = [
365364
'keyId' => $this->key1Id,
366-
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
365+
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
367366
'contentionFactor' => 0,
368367
'rangeOpts' => $rangeOpts,
369368
];
@@ -376,7 +375,7 @@ public function testCase6_EncryptingADocumentGreaterThanTheMaximumErrors(string
376375
}
377376

378377
/**
379-
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.rst#case-7-encrypting-a-value-of-a-different-type-errors
378+
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.md#case-7-encrypting-a-value-of-a-different-type-errors
380379
* @dataProvider provideTypeAndRangeOpts
381380
*/
382381
public function testCase7_EncryptingAValueOfADifferentTypeErrors(string $type, array $rangeOpts): void
@@ -391,7 +390,7 @@ public function testCase7_EncryptingAValueOfADifferentTypeErrors(string $type, a
391390

392391
$encryptOpts = [
393392
'keyId' => $this->key1Id,
394-
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
393+
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
395394
'contentionFactor' => 0,
396395
'rangeOpts' => $rangeOpts,
397396
];
@@ -404,7 +403,7 @@ public function testCase7_EncryptingAValueOfADifferentTypeErrors(string $type, a
404403
}
405404

406405
/**
407-
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.rst#case-8-setting-precision-errors-if-the-type-is-not-double-or-decimal128
406+
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.md#case-8-setting-precision-errors-if-the-type-is-not-double-or-decimal128
408407
* @dataProvider provideTypeAndRangeOpts
409408
*/
410409
public function testCase8_SettingPrecisionErrorsIfTheTypeIsNotDoubleOrDecimal128(string $type, array $rangeOpts): void
@@ -417,7 +416,7 @@ public function testCase8_SettingPrecisionErrorsIfTheTypeIsNotDoubleOrDecimal128
417416

418417
$encryptOpts = [
419418
'keyId' => $this->key1Id,
420-
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
419+
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
421420
'contentionFactor' => 0,
422421
'rangeOpts' => $rangeOpts + ['precision' => 2],
423422
];

tests/SpecTests/client-side-encryption/etc/data/range-encryptedFields-Date.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
"path": "encryptedDate",
1111
"bsonType": "date",
1212
"queries": {
13-
"queryType": "rangePreview",
13+
"queryType": "range",
1414
"contention": {
1515
"$numberLong": "0"
1616
},
17+
"trimFactor": {
18+
"$numberInt": "1"
19+
},
1720
"sparsity": {
1821
"$numberLong": "1"
1922
},
@@ -30,4 +33,4 @@
3033
}
3134
}
3235
]
33-
}
36+
}

tests/SpecTests/client-side-encryption/etc/data/range-encryptedFields-DecimalNoPrecision.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@
1010
"path": "encryptedDecimalNoPrecision",
1111
"bsonType": "decimal",
1212
"queries": {
13-
"queryType": "rangePreview",
13+
"queryType": "range",
1414
"contention": {
1515
"$numberLong": "0"
1616
},
17+
"trimFactor": {
18+
"$numberInt": "1"
19+
},
1720
"sparsity": {
1821
"$numberLong": "1"
1922
}
2023
}
2124
}
2225
]
23-
}
26+
}

tests/SpecTests/client-side-encryption/etc/data/range-encryptedFields-DecimalPrecision.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
"path": "encryptedDecimalPrecision",
1111
"bsonType": "decimal",
1212
"queries": {
13-
"queryType": "rangePreview",
13+
"queryType": "range",
1414
"contention": {
1515
"$numberLong": "0"
1616
},
17+
"trimFactor": {
18+
"$numberInt": "1"
19+
},
1720
"sparsity": {
1821
"$numberLong": "1"
1922
},
@@ -29,4 +32,4 @@
2932
}
3033
}
3134
]
32-
}
35+
}

tests/SpecTests/client-side-encryption/etc/data/range-encryptedFields-DoubleNoPrecision.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@
1010
"path": "encryptedDoubleNoPrecision",
1111
"bsonType": "double",
1212
"queries": {
13-
"queryType": "rangePreview",
13+
"queryType": "range",
1414
"contention": {
1515
"$numberLong": "0"
1616
},
17+
"trimFactor": {
18+
"$numberInt": "1"
19+
},
1720
"sparsity": {
1821
"$numberLong": "1"
1922
}
2023
}
2124
}
2225
]
23-
}
26+
}

tests/SpecTests/client-side-encryption/etc/data/range-encryptedFields-DoublePrecision.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
"path": "encryptedDoublePrecision",
1111
"bsonType": "double",
1212
"queries": {
13-
"queryType": "rangePreview",
13+
"queryType": "range",
1414
"contention": {
1515
"$numberLong": "0"
1616
},
17+
"trimFactor": {
18+
"$numberInt": "1"
19+
},
1720
"sparsity": {
1821
"$numberLong": "1"
1922
},
@@ -29,4 +32,4 @@
2932
}
3033
}
3134
]
32-
}
35+
}

tests/SpecTests/client-side-encryption/etc/data/range-encryptedFields-Int.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
"path": "encryptedInt",
1111
"bsonType": "int",
1212
"queries": {
13-
"queryType": "rangePreview",
13+
"queryType": "range",
1414
"contention": {
1515
"$numberLong": "0"
1616
},
17+
"trimFactor": {
18+
"$numberInt": "1"
19+
},
1720
"sparsity": {
1821
"$numberLong": "1"
1922
},
@@ -26,4 +29,4 @@
2629
}
2730
}
2831
]
29-
}
32+
}

tests/SpecTests/client-side-encryption/etc/data/range-encryptedFields-Long.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
"path": "encryptedLong",
1111
"bsonType": "long",
1212
"queries": {
13-
"queryType": "rangePreview",
13+
"queryType": "range",
1414
"contention": {
1515
"$numberLong": "0"
1616
},
17+
"trimFactor": {
18+
"$numberInt": "1"
19+
},
1720
"sparsity": {
1821
"$numberLong": "1"
1922
},
@@ -26,4 +29,4 @@
2629
}
2730
}
2831
]
29-
}
32+
}

0 commit comments

Comments
 (0)