@@ -3774,15 +3774,20 @@ Before running each of the following test cases, perform the following Test Setu
3774
3774
3775
3775
#### Test Setup
3776
3776
3777
- Load the file `encryptedFields-prefix-suffix.json` as `encryptedFields`.
3777
+ Load the file `encryptedFields-prefix-suffix.json` as `encryptedFields-prefix-suffix`.
3778
+
3779
+ Load the file `encryptedFields-substring.json` as `encryptedFields-substring`.
3778
3780
3779
3781
Load the file
3780
3782
[key1-document.json](https://github.com/mongodb/specifications/tree/master/source/client-side-encryption/etc/data/keys/key1-document.json)
3781
3783
as `key1Document`.
3782
3784
3783
3785
Read the `"_id"` field of `key1Document` as `key1ID`.
3784
3786
3785
- Drop and create the collection `db.explicit_encryption` using `encryptedFields` as an option. See
3787
+ Drop and create the collection `db.prefix-suffix` using `encryptedFields-prefix-suffix` as an option. See
3788
+ [QE CreateCollection() and Collection.Drop()](../client-side-encryption.md#create-collection-helper).
3789
+
3790
+ Drop and create the collection `db.substring` using `encryptedFields-substring` as an option. See
3786
3791
[QE CreateCollection() and Collection.Drop()](../client-side-encryption.md#create-collection-helper).
3787
3792
3788
3793
Drop and create the collection `keyvault.datakeys`.
@@ -3829,7 +3834,30 @@ class EncryptOpts {
3829
3834
}
3830
3835
```
3831
3836
3832
- Use `encryptedClient` to insert the following document into `db.explicit_encryption`:
3837
+ Use `encryptedClient` to insert the following document into `db.prefix-suffix`:
3838
+
3839
+ ```javascript
3840
+ { "_id": 0, "encryptedText": <encrypted "foobarbaz"> }
3841
+ ```
3842
+
3843
+ Use `clientEncryption` to encrypt the string `"foobarbaz"`.
3844
+
3845
+ Encrypt using the following `EncryptOpts`:
3846
+
3847
+ ```typescript
3848
+ class EncryptOpts {
3849
+ keyId : <key1ID>,
3850
+ algorithm: "TextPreview",
3851
+ contentionFactor: 0,
3852
+ textOpts: TextOpts {
3853
+ caseSensitive: true,
3854
+ diacriticSensitive: true,
3855
+ substring: <SubstringOpts>
3856
+ },
3857
+ }
3858
+ ```
3859
+
3860
+ Use `encryptedClient` to insert the following document into `db.substring`:
3833
3861
3834
3862
```javascript
3835
3863
{ "_id": 0, "encryptedText": <encrypted "foobarbaz"> }
@@ -3887,17 +3915,14 @@ class EncryptOpts {
3887
3915
3888
3916
#### Case 1: can find a document by prefix
3889
3917
3890
- Use `clientEncryption.encrypt()` to encrypt the string `"foo"`:
3918
+ Use `clientEncryption.encrypt()` to encrypt the string `"foo"`. Store the resulting payload in `findPayload`.
3891
3919
3892
- Store this query in `findPayload`.
3920
+ Use `encryptedClient` to run a "find" operation on the `db.prefix-suffix` collection with the following filter:
3893
3921
3894
3922
```javascript
3895
- { "$expr": { "$encStrStartsWith": {"input": "$encryptedText", "prefix": <encrypted "foo" >}, } }
3923
+ { "$expr": { "$encStrStartsWith": {"input": "$encryptedText", "prefix": <findPayload >}, } }
3896
3924
```
3897
3925
3898
- Use `encryptedClient` to run a "find" operation on the `db.explicit_encryption` collection with the filter
3899
- `findPayload`.
3900
-
3901
3926
Assert the following document is returned:
3902
3927
3903
3928
```javascript
@@ -3906,17 +3931,14 @@ Assert the following document is returned:
3906
3931
3907
3932
#### Case 2: can find a document by suffix
3908
3933
3909
- Use `clientEncryption.encrypt()` to encrypt the string `"baz"`:
3934
+ Use `clientEncryption.encrypt()` to encrypt the string `"foo"`. Store the resulting payload in `findPayload`.
3910
3935
3911
- Store this query in `findPayload`.
3936
+ Use `encryptedClient` to run a "find" operation on the `db.prefix-suffix` collection with the following filter:
3912
3937
3913
3938
```javascript
3914
- { "$expr": { "$encStrStartsWith": {"input": "$encryptedText", "prefix": <encrypted "baz" >}, } }
3939
+ { "$expr": { "$encStrStartsWith": {"input": "$encryptedText", "prefix": <findPayload >}, } }
3915
3940
```
3916
3941
3917
- Store the result in `findPayload`. Use `encryptedClient` to run a "find" operation on the `db.explicit_encryption`
3918
- collection with the filter `findPayload`.
3919
-
3920
3942
Assert the following document is returned:
3921
3943
3922
3944
```javascript
@@ -3925,80 +3947,38 @@ Assert the following document is returned:
3925
3947
3926
3948
#### Case 3: assert no document found by prefix
3927
3949
3928
- Use `clientEncryption.encrypt()` to encrypt the string `"baz"`:
3950
+ Use `clientEncryption.encrypt()` to encrypt the string `"foo"`. Store the resulting payload in `findPayload`.
3929
3951
3930
- Store this query in `findPayload`.
3952
+ Use `encryptedClient` to run a "find" operation on the `db.prefix-suffix` collection with the following filter:
3931
3953
3932
3954
```javascript
3933
- { "$expr": { "$encStrStartsWith": {"input": "$encryptedText", "prefix": <encrypted "baz" >}, } }
3955
+ { "$expr": { "$encStrStartsWith": {"input": "$encryptedText", "prefix": <findPayload >}, } }
3934
3956
```
3935
3957
3936
- Store the result in `findPayload`. Use `encryptedClient` to run a "find" operation on the `db.explicit_encryption`
3937
- collection with the filter `findPayload`.
3938
-
3939
3958
Assert that no documents are returned.
3940
3959
3941
3960
#### Case 4: assert no document found by suffix
3942
3961
3943
- Use `clientEncryption.encrypt()` to encrypt the string `"foo"`:
3962
+ Use `clientEncryption.encrypt()` to encrypt the string `"foo"`. Store the resulting payload in `findPayload`.
3944
3963
3945
- Store this query in `findPayload`.
3964
+ Use `encryptedClient` to run a "find" operation on the `db.prefix-suffix` collection with the following filter:
3946
3965
3947
3966
```javascript
3948
- { "$expr": { "$encStrStartsWith": {"input": "$encryptedText", "suffix": <encrypted "foo" >}, } }
3967
+ { "$expr": { "$encStrStartsWith": {"input": "$encryptedText", "suffix": <findPayload >}, } }
3949
3968
```
3950
3969
3951
- Store the result in `findPayload`. Use `encryptedClient` to run a "find" operation on the `db.explicit_encryption`
3952
- collection with the filter `findPayload`.
3953
-
3954
3970
Assert that no documents are returned.
3955
3971
3956
- #### Substring test setup
3957
-
3958
- Load the file `encryptedFields-substring.json` as `encryptedFields`.
3959
-
3960
- Load the file
3961
- [key1-document.json](https://github.com/mongodb/specifications/tree/master/source/client-side-encryption/etc/data/keys/key1-document.json)
3962
- as `key1Document`.
3963
-
3964
- Drop and create the collection `db.explicit_encryption` using `encryptedFields` as an option.
3965
-
3966
- Use `clientEncryption` to encrypt the string `"foobarbaz"`.
3967
-
3968
- Encrypt using the following `EncryptOpts`:
3969
-
3970
- ```typescript
3971
- class EncryptOpts {
3972
- keyId : <key1ID>,
3973
- algorithm: "TextPreview",
3974
- contentionFactor: 0,
3975
- textOpts: TextOpts {
3976
- caseSensitive: true,
3977
- diacriticSensitive: true,
3978
- substring: <SubstringOpts>
3979
- },
3980
- }
3981
- ```
3982
-
3983
- Use `encryptedClient` to insert the following document into `db.explicit_encryption`:
3984
-
3985
- ```javascript
3986
- { "_id": 0, "encryptedText": <encrypted "foobarbaz"> }
3987
- ```
3988
-
3989
3972
#### Case 5: can find a document by substring
3990
3973
3991
- Use `clientEncryption.encrypt()` to encrypt the string `"bar"`:
3974
+ Use `clientEncryption.encrypt()` to encrypt the string `"foo"`. Store the resulting payload in `findPayload`.
3992
3975
3993
- Store this query in `findPayload`.
3976
+ Use `encryptedClient` to run a "find" operation on the `db.substring` collection with the following filter:
3994
3977
3995
3978
```javascript
3996
- { "$expr": { "$encStrStartsWith": {"input": "$encryptedText", "prefix": <encrypted "bar" >}, } }
3979
+ { "$expr": { "$encStrStartsWith": {"input": "$encryptedText", "prefix": <findPayload >}, } }
3997
3980
```
3998
3981
3999
- Store the result in `findPayload`. Use `encryptedClient` to run a "find" operation on the `db.explicit_encryption`
4000
- collection with the filter `findPayload`.
4001
-
4002
3982
Assert the following document is returned:
4003
3983
4004
3984
```javascript
@@ -4007,15 +3987,12 @@ Assert the following document is returned:
4007
3987
4008
3988
#### Case 6: assert no document found by substring
4009
3989
4010
- Use `clientEncryption.encrypt()` to encrypt the string `"qux"`:
3990
+ Use `clientEncryption.encrypt()` to encrypt the string `"qux"`. Store the resulting payload in `findPayload`.
4011
3991
4012
- Store this query in `findPayload`.
3992
+ Use `encryptedClient` to run a "find" operation on the `db.substring` collection with the following filter:
4013
3993
4014
3994
```javascript
4015
- { "$expr": { "$encStrStartsWith": {"input": "$encryptedText", "prefix": <encrypted "qux" >}, } }
3995
+ { "$expr": { "$encStrStartsWith": {"input": "$encryptedText", "prefix": <findPayload >}, } }
4016
3996
```
4017
3997
4018
- Store the result in `findPayload`. Use `encryptedClient` to run a "find" operation on the `db.explicit_encryption`
4019
- collection with the filter `findPayload`.
4020
-
4021
3998
Assert that no documents are returned.
0 commit comments