Skip to content

Commit

Permalink
PHPLIB-1393: Update spec tests for QE range protocol V2
Browse files Browse the repository at this point in the history
Synced with mongodb/specifications@9bfa512

Also updates prose test links to the new README.md file
  • Loading branch information
jmikola committed Jun 22, 2024
1 parent 95df33d commit 73719ca
Show file tree
Hide file tree
Showing 52 changed files with 738 additions and 694 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"php": "^7.4 || ^8.0",
"ext-hash": "*",
"ext-json": "*",
"ext-mongodb": "^1.19.0",
"ext-mongodb": "^1.20.0",
"composer-runtime-api": "^2.0",
"psr/log": "^1.1.4|^2|^3",
"symfony/polyfill-php80": "^1.27",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* Prose test 22: Range Explicit Encryption
*
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.rst#range-explicit-encryption
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.md#22-range-explicit-encryption
* @group csfle
* @group serverless
*/
Expand All @@ -43,8 +43,7 @@ public function setUp(): void
$this->markTestSkipped('Range explicit encryption tests require replica sets');
}

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

$client = static::createTestClient();

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

$encryptOpts = [
'keyId' => $this->key1Id,
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
'contentionFactor' => 0,
'rangeOpts' => $rangeOpts,
];
Expand All @@ -117,7 +116,7 @@ public function tearDown(): void
$this->encryptedClient = null;
}

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

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

$encryptOpts = [
'keyId' => $this->key1Id,
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
'contentionFactor' => 0,
'rangeOpts' => $rangeOpts,
];
Expand All @@ -214,7 +213,7 @@ public function testCase1_CanDecryptAPayload(string $type, array $rangeOpts): vo
}

/**
* @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
* @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
* @dataProvider provideTypeAndRangeOpts
*/
public function testCase2_CanFindEncryptedRangeAndReturnTheMaximum(string $type, array $rangeOpts): void
Expand All @@ -223,8 +222,8 @@ public function testCase2_CanFindEncryptedRangeAndReturnTheMaximum(string $type,

$encryptOpts = [
'keyId' => $this->key1Id,
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
'queryType' => ClientEncryption::QUERY_TYPE_RANGE_PREVIEW,
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
'queryType' => ClientEncryption::QUERY_TYPE_RANGE,
'contentionFactor' => 0,
'rangeOpts' => $rangeOpts,
];
Expand Down Expand Up @@ -252,7 +251,7 @@ public function testCase2_CanFindEncryptedRangeAndReturnTheMaximum(string $type,
}

/**
* @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
* @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
* @dataProvider provideTypeAndRangeOpts
*/
public function testCase3_CanFindEncryptedRangeAndReturnTheMinimum(string $type, array $rangeOpts): void
Expand All @@ -261,8 +260,8 @@ public function testCase3_CanFindEncryptedRangeAndReturnTheMinimum(string $type,

$encryptOpts = [
'keyId' => $this->key1Id,
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
'queryType' => ClientEncryption::QUERY_TYPE_RANGE_PREVIEW,
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
'queryType' => ClientEncryption::QUERY_TYPE_RANGE,
'contentionFactor' => 0,
'rangeOpts' => $rangeOpts,
];
Expand All @@ -289,7 +288,7 @@ public function testCase3_CanFindEncryptedRangeAndReturnTheMinimum(string $type,
}

/**
* @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
* @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
* @dataProvider provideTypeAndRangeOpts
*/
public function testCase4_CanFindEncryptedRangeWithAnOpenRangeQuery(string $type, array $rangeOpts): void
Expand All @@ -298,8 +297,8 @@ public function testCase4_CanFindEncryptedRangeWithAnOpenRangeQuery(string $type

$encryptOpts = [
'keyId' => $this->key1Id,
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
'queryType' => ClientEncryption::QUERY_TYPE_RANGE_PREVIEW,
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
'queryType' => ClientEncryption::QUERY_TYPE_RANGE,
'contentionFactor' => 0,
'rangeOpts' => $rangeOpts,
];
Expand All @@ -317,7 +316,7 @@ public function testCase4_CanFindEncryptedRangeWithAnOpenRangeQuery(string $type
}

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

$encryptOpts = [
'keyId' => $this->key1Id,
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
'queryType' => ClientEncryption::QUERY_TYPE_RANGE_PREVIEW,
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
'queryType' => ClientEncryption::QUERY_TYPE_RANGE,
'contentionFactor' => 0,
'rangeOpts' => $rangeOpts,
];
Expand All @@ -350,7 +349,7 @@ public function testCase5_CanRunAnAggregationExpressionInsideExpr(string $type,
}

/**
* @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
* @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
* @dataProvider provideTypeAndRangeOpts
*/
public function testCase6_EncryptingADocumentGreaterThanTheMaximumErrors(string $type, array $rangeOpts): void
Expand All @@ -363,7 +362,7 @@ public function testCase6_EncryptingADocumentGreaterThanTheMaximumErrors(string

$encryptOpts = [
'keyId' => $this->key1Id,
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
'contentionFactor' => 0,
'rangeOpts' => $rangeOpts,
];
Expand All @@ -376,7 +375,7 @@ public function testCase6_EncryptingADocumentGreaterThanTheMaximumErrors(string
}

/**
* @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
* @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
* @dataProvider provideTypeAndRangeOpts
*/
public function testCase7_EncryptingAValueOfADifferentTypeErrors(string $type, array $rangeOpts): void
Expand All @@ -391,7 +390,7 @@ public function testCase7_EncryptingAValueOfADifferentTypeErrors(string $type, a

$encryptOpts = [
'keyId' => $this->key1Id,
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
'contentionFactor' => 0,
'rangeOpts' => $rangeOpts,
];
Expand All @@ -404,7 +403,7 @@ public function testCase7_EncryptingAValueOfADifferentTypeErrors(string $type, a
}

/**
* @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
* @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
* @dataProvider provideTypeAndRangeOpts
*/
public function testCase8_SettingPrecisionErrorsIfTheTypeIsNotDoubleOrDecimal128(string $type, array $rangeOpts): void
Expand All @@ -417,7 +416,7 @@ public function testCase8_SettingPrecisionErrorsIfTheTypeIsNotDoubleOrDecimal128

$encryptOpts = [
'keyId' => $this->key1Id,
'algorithm' => ClientEncryption::ALGORITHM_RANGE_PREVIEW,
'algorithm' => ClientEncryption::ALGORITHM_RANGE,
'contentionFactor' => 0,
'rangeOpts' => $rangeOpts + ['precision' => 2],
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
"path": "encryptedDate",
"bsonType": "date",
"queries": {
"queryType": "rangePreview",
"queryType": "range",
"contention": {
"$numberLong": "0"
},
"trimFactor": {
"$numberInt": "1"
},
"sparsity": {
"$numberLong": "1"
},
Expand All @@ -30,4 +33,4 @@
}
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@
"path": "encryptedDecimalNoPrecision",
"bsonType": "decimal",
"queries": {
"queryType": "rangePreview",
"queryType": "range",
"contention": {
"$numberLong": "0"
},
"trimFactor": {
"$numberInt": "1"
},
"sparsity": {
"$numberLong": "1"
}
}
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
"path": "encryptedDecimalPrecision",
"bsonType": "decimal",
"queries": {
"queryType": "rangePreview",
"queryType": "range",
"contention": {
"$numberLong": "0"
},
"trimFactor": {
"$numberInt": "1"
},
"sparsity": {
"$numberLong": "1"
},
Expand All @@ -29,4 +32,4 @@
}
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@
"path": "encryptedDoubleNoPrecision",
"bsonType": "double",
"queries": {
"queryType": "rangePreview",
"queryType": "range",
"contention": {
"$numberLong": "0"
},
"trimFactor": {
"$numberInt": "1"
},
"sparsity": {
"$numberLong": "1"
}
}
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
"path": "encryptedDoublePrecision",
"bsonType": "double",
"queries": {
"queryType": "rangePreview",
"queryType": "range",
"contention": {
"$numberLong": "0"
},
"trimFactor": {
"$numberInt": "1"
},
"sparsity": {
"$numberLong": "1"
},
Expand All @@ -29,4 +32,4 @@
}
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
"path": "encryptedInt",
"bsonType": "int",
"queries": {
"queryType": "rangePreview",
"queryType": "range",
"contention": {
"$numberLong": "0"
},
"trimFactor": {
"$numberInt": "1"
},
"sparsity": {
"$numberLong": "1"
},
Expand All @@ -26,4 +29,4 @@
}
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
"path": "encryptedLong",
"bsonType": "long",
"queries": {
"queryType": "rangePreview",
"queryType": "range",
"contention": {
"$numberLong": "0"
},
"trimFactor": {
"$numberInt": "1"
},
"sparsity": {
"$numberLong": "1"
},
Expand All @@ -26,4 +29,4 @@
}
}
]
}
}
Loading

0 comments on commit 73719ca

Please sign in to comment.