Skip to content

Commit 0111a3a

Browse files
jmikolaalcaeus
authored andcommitted
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 bc83f86 commit 0111a3a

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
@@ -26,7 +26,7 @@
2626
/**
2727
* Prose test 22: Range Explicit Encryption
2828
*
29-
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.rst#range-explicit-encryption
29+
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.md#22-range-explicit-encryption
3030
* @group csfle
3131
* @group serverless
3232
*/
@@ -49,8 +49,7 @@ public function setUp(): void
4949
$this->markTestSkipped('Range explicit encryption tests require replica sets');
5050
}
5151

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

5554
$client = static::createTestClient();
5655

@@ -98,7 +97,7 @@ public function setUpWithTypeAndRangeOpts(string $type, array $rangeOpts): void
9897

9998
$encryptOpts = [
10099
'keyId' => $this->key1Id,
101-
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
100+
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
102101
'contentionFactor' => 0,
103102
'rangeOpts' => $rangeOpts,
104103
];
@@ -123,7 +122,7 @@ public function tearDown(): void
123122
$this->encryptedClient = null;
124123
}
125124

126-
/** @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.rst#test-setup-rangeopts */
125+
/** @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.md#test-setup-rangeopts */
127126
public static function provideTypeAndRangeOpts(): Generator
128127
{
129128
// TODO: skip DecimalNoPrecision test on mongos
@@ -186,7 +185,7 @@ public static function provideTypeAndRangeOpts(): Generator
186185
}
187186

188187
/**
189-
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.rst#case-1-can-decrypt-a-payload
188+
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.md#case-1-can-decrypt-a-payload
190189
* @dataProvider provideTypeAndRangeOpts
191190
*/
192191
public function testCase1_CanDecryptAPayload(string $type, array $rangeOpts): void
@@ -195,7 +194,7 @@ public function testCase1_CanDecryptAPayload(string $type, array $rangeOpts): vo
195194

196195
$encryptOpts = [
197196
'keyId' => $this->key1Id,
198-
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
197+
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
199198
'contentionFactor' => 0,
200199
'rangeOpts' => $rangeOpts,
201200
];
@@ -220,7 +219,7 @@ public function testCase1_CanDecryptAPayload(string $type, array $rangeOpts): vo
220219
}
221220

222221
/**
223-
* @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
222+
* @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
224223
* @dataProvider provideTypeAndRangeOpts
225224
*/
226225
public function testCase2_CanFindEncryptedRangeAndReturnTheMaximum(string $type, array $rangeOpts): void
@@ -229,8 +228,8 @@ public function testCase2_CanFindEncryptedRangeAndReturnTheMaximum(string $type,
229228

230229
$encryptOpts = [
231230
'keyId' => $this->key1Id,
232-
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
233-
'queryType' => ClientEncryption::QUERY_TYPE_RANGE_PREVIEW,
231+
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
232+
'queryType' => ClientEncryption::QUERY_TYPE_RANGE,
234233
'contentionFactor' => 0,
235234
'rangeOpts' => $rangeOpts,
236235
];
@@ -258,7 +257,7 @@ public function testCase2_CanFindEncryptedRangeAndReturnTheMaximum(string $type,
258257
}
259258

260259
/**
261-
* @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
260+
* @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
262261
* @dataProvider provideTypeAndRangeOpts
263262
*/
264263
public function testCase3_CanFindEncryptedRangeAndReturnTheMinimum(string $type, array $rangeOpts): void
@@ -267,8 +266,8 @@ public function testCase3_CanFindEncryptedRangeAndReturnTheMinimum(string $type,
267266

268267
$encryptOpts = [
269268
'keyId' => $this->key1Id,
270-
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
271-
'queryType' => ClientEncryption::QUERY_TYPE_RANGE_PREVIEW,
269+
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
270+
'queryType' => ClientEncryption::QUERY_TYPE_RANGE,
272271
'contentionFactor' => 0,
273272
'rangeOpts' => $rangeOpts,
274273
];
@@ -295,7 +294,7 @@ public function testCase3_CanFindEncryptedRangeAndReturnTheMinimum(string $type,
295294
}
296295

297296
/**
298-
* @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
297+
* @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
299298
* @dataProvider provideTypeAndRangeOpts
300299
*/
301300
public function testCase4_CanFindEncryptedRangeWithAnOpenRangeQuery(string $type, array $rangeOpts): void
@@ -304,8 +303,8 @@ public function testCase4_CanFindEncryptedRangeWithAnOpenRangeQuery(string $type
304303

305304
$encryptOpts = [
306305
'keyId' => $this->key1Id,
307-
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
308-
'queryType' => ClientEncryption::QUERY_TYPE_RANGE_PREVIEW,
306+
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
307+
'queryType' => ClientEncryption::QUERY_TYPE_RANGE,
309308
'contentionFactor' => 0,
310309
'rangeOpts' => $rangeOpts,
311310
];
@@ -323,7 +322,7 @@ public function testCase4_CanFindEncryptedRangeWithAnOpenRangeQuery(string $type
323322
}
324323

325324
/**
326-
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.rst#case-5-can-run-an-aggregation-expression-inside-expr
325+
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.md#case-5-can-run-an-aggregation-expression-inside-expr
327326
* @dataProvider provideTypeAndRangeOpts
328327
*/
329328
public function testCase5_CanRunAnAggregationExpressionInsideExpr(string $type, array $rangeOpts): void
@@ -332,8 +331,8 @@ public function testCase5_CanRunAnAggregationExpressionInsideExpr(string $type,
332331

333332
$encryptOpts = [
334333
'keyId' => $this->key1Id,
335-
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
336-
'queryType' => ClientEncryption::QUERY_TYPE_RANGE_PREVIEW,
334+
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
335+
'queryType' => ClientEncryption::QUERY_TYPE_RANGE,
337336
'contentionFactor' => 0,
338337
'rangeOpts' => $rangeOpts,
339338
];
@@ -356,7 +355,7 @@ public function testCase5_CanRunAnAggregationExpressionInsideExpr(string $type,
356355
}
357356

358357
/**
359-
* @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
358+
* @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
360359
* @dataProvider provideTypeAndRangeOpts
361360
*/
362361
public function testCase6_EncryptingADocumentGreaterThanTheMaximumErrors(string $type, array $rangeOpts): void
@@ -369,7 +368,7 @@ public function testCase6_EncryptingADocumentGreaterThanTheMaximumErrors(string
369368

370369
$encryptOpts = [
371370
'keyId' => $this->key1Id,
372-
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
371+
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
373372
'contentionFactor' => 0,
374373
'rangeOpts' => $rangeOpts,
375374
];
@@ -382,7 +381,7 @@ public function testCase6_EncryptingADocumentGreaterThanTheMaximumErrors(string
382381
}
383382

384383
/**
385-
* @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
384+
* @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
386385
* @dataProvider provideTypeAndRangeOpts
387386
*/
388387
public function testCase7_EncryptingAValueOfADifferentTypeErrors(string $type, array $rangeOpts): void
@@ -397,7 +396,7 @@ public function testCase7_EncryptingAValueOfADifferentTypeErrors(string $type, a
397396

398397
$encryptOpts = [
399398
'keyId' => $this->key1Id,
400-
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
399+
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
401400
'contentionFactor' => 0,
402401
'rangeOpts' => $rangeOpts,
403402
];
@@ -410,7 +409,7 @@ public function testCase7_EncryptingAValueOfADifferentTypeErrors(string $type, a
410409
}
411410

412411
/**
413-
* @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
412+
* @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
414413
* @dataProvider provideTypeAndRangeOpts
415414
*/
416415
public function testCase8_SettingPrecisionErrorsIfTheTypeIsNotDoubleOrDecimal128(string $type, array $rangeOpts): void
@@ -423,7 +422,7 @@ public function testCase8_SettingPrecisionErrorsIfTheTypeIsNotDoubleOrDecimal128
423422

424423
$encryptOpts = [
425424
'keyId' => $this->key1Id,
426-
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
425+
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
427426
'contentionFactor' => 0,
428427
'rangeOpts' => $rangeOpts + ['precision' => 2],
429428
];

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)