@@ -3774,7 +3774,7 @@ 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-text .json ` as ` encryptedFields ` .
3777
+ Load the file ` encryptedFields-prefix-suffix .json ` as ` encryptedFields ` .
3778
3778
3779
3779
Load the file
3780
3780
[key1 - document .json ](https :// github.com/mongodb/specifications/tree/master/source/client-side-encryption/etc/data/keys/key1-document.json)
@@ -3812,27 +3812,41 @@ class AutoEncryptionOpts {
3812
3812
` ` `
3813
3813
3814
3814
The remaining tasks require setting ` TextOpts ` . [Test Setup : TextOpts ](#test - setup - textopts ) lists the values to use
3815
- for ` RangeOpts ` for each of the supported data types .
3815
+ for ` TextOpts ` for each of the supported data types .
3816
3816
3817
3817
#### Test Setup : TextOpts
3818
3818
3819
- This section lists the values to use for ` TextOpts ` for each query type .
3819
+ This section lists the values to use for ` TextOpts ` for each query type . Include the matching options in the following
3820
+ ` EncryptOpts ` for each query :
3821
+
3822
+ ` ` ` typescript
3823
+ class EncryptOpts {
3824
+ keyId : <key1ID>,
3825
+ algorithm: "TextPreview",
3826
+ contentionFactor: 0,
3827
+ textOpts: TextOpts {
3828
+ caseSensitive: true,
3829
+ diacriticSensitive: true,
3830
+ <prefix/suffix/substring>: <matching opts>
3831
+ },
3832
+ }
3833
+ ` ` `
3820
3834
3821
3835
1. Prefix
3822
3836
3823
3837
` ` ` typescript
3824
3838
class PrefixOpts {
3825
- strMaxQueryLength: 3 ,
3826
- strMinQueryLength: 1 ,
3839
+ strMaxQueryLength: 10 ,
3840
+ strMinQueryLength: 2 ,
3827
3841
}
3828
3842
` ` `
3829
3843
3830
3844
2. Suffix
3831
3845
3832
3846
` ` ` typescript
3833
3847
class SuffixOpts {
3834
- strMaxQueryLength: 3 ,
3835
- strMinQueryLength: 1 ,
3848
+ strMaxQueryLength: 10 ,
3849
+ strMinQueryLength: 2 ,
3836
3850
}
3837
3851
` ` `
3838
3852
@@ -3841,12 +3855,12 @@ This section lists the values to use for `TextOpts` for each query type.
3841
3855
` ` ` typescript
3842
3856
class SubstringOpts {
3843
3857
strMaxLength: 10,
3844
- strMaxQueryLength: 3 ,
3845
- strMinQueryLength: 1 ,
3858
+ strMaxQueryLength: 10 ,
3859
+ strMinQueryLength: 2 ,
3846
3860
}
3847
3861
` ` `
3848
3862
3849
- Use ` clientEncryption ` to encrypt the string " foobarbaz" .
3863
+ Use ` clientEncryption ` to encrypt the string ` "foobarbaz" ` .
3850
3864
3851
3865
Encrypt using the following ` EncryptOpts ` :
3852
3866
@@ -3872,12 +3886,12 @@ Use `encryptedClient` to insert the following document into `db.explicit_encrypt
3872
3886
3873
3887
#### Case 1 : can find a document by prefix
3874
3888
3875
- Use ` clientEncryption.encryptExpression() ` to encrypt this query :
3889
+ Use ` clientEncryption.encrypt() ` to encrypt the string ` "foo" ` :
3890
+
3891
+ Store this query in ` findPayload ` .
3876
3892
` ` ` javascript
3877
- { "$expr": { "$encStrStartsWith": {"input": "encryptedText", "prefix": "foo"}, } }
3893
+ { "$expr": { "$encStrStartsWith": {"input": "encryptedText", "prefix": <encrypted "foo"> }, } }
3878
3894
` ` `
3879
-
3880
- Store the result in ` findPayload ` .
3881
3895
Use ` encryptedClient ` to run a " find" operation on the ` db.explicit_encryption ` collection with the filter ` findPayload ` .
3882
3896
3883
3897
Assert the following document is returned :
@@ -3888,9 +3902,11 @@ Assert the following document is returned:
3888
3902
3889
3903
#### Case 2 : can find a document by suffix
3890
3904
3891
- Use ` clientEncryption.encryptExpression() ` to encrypt this query :
3905
+ Use ` clientEncryption.encrypt() ` to encrypt the string ` "baz" ` :
3906
+
3907
+ Store this query in ` findPayload ` .
3892
3908
` ` ` javascript
3893
- { "$expr": { "$encStrEndsWith ": {"input": "encryptedText", "suffix ": "baz"}, } }
3909
+ { "$expr": { "$encStrStartsWith ": {"input": "encryptedText", "prefix ": <encrypted "baz"> }, } }
3894
3910
` ` `
3895
3911
3896
3912
Store the result in ` findPayload ` .
@@ -3904,9 +3920,11 @@ Assert the following document is returned:
3904
3920
3905
3921
#### Case 3 : assert no document found by prefix
3906
3922
3907
- Use ` clientEncryption.encryptExpression() ` to encrypt this query :
3923
+ Use ` clientEncryption.encrypt() ` to encrypt the string ` "baz" ` :
3924
+
3925
+ Store this query in ` findPayload ` .
3908
3926
` ` ` javascript
3909
- { "$expr": { "$encStrStartsWith": {"input": "encryptedText", "prefix": "baz"}, } }
3927
+ { "$expr": { "$encStrStartsWith": {"input": "encryptedText", "prefix": <encrypted "baz"> }, } }
3910
3928
` ` `
3911
3929
3912
3930
Store the result in ` findPayload ` .
@@ -3916,9 +3934,74 @@ Assert that no documents are returned.
3916
3934
3917
3935
#### Case 4 : assert no document found by suffix
3918
3936
3919
- Use ` clientEncryption.encryptExpression() ` to encrypt this query :
3937
+ Use ` clientEncryption.encrypt() ` to encrypt the string ` "foo" ` :
3938
+
3939
+ Store this query in ` findPayload ` .
3940
+ ` ` ` javascript
3941
+ { "$expr": { "$encStrStartsWith": {"input": "encryptedText", "suffix": <encrypted "foo">}, } }
3942
+ ` ` `
3943
+
3944
+ Store the result in ` findPayload ` .
3945
+ Use ` encryptedClient ` to run a " find" operation on the ` db.explicit_encryption ` collection with the filter ` findPayload ` .
3946
+
3947
+ Assert that no documents are returned .
3948
+
3949
+ #### Substring test setup
3950
+ Load the file ` encryptedFields-substring.json ` as ` encryptedFields ` .
3951
+
3952
+ Load the file
3953
+ [key1 - document .json ](https :// github.com/mongodb/specifications/tree/master/source/client-side-encryption/etc/data/keys/key1-document.json)
3954
+ as ` key1Document ` .
3955
+
3956
+ Drop and create the collection ` db.explicit_encryption ` using ` encryptedFields ` as an option .
3957
+
3958
+ Use ` clientEncryption ` to encrypt the string ` "foobarbaz" ` .
3959
+
3960
+ Encrypt using the following ` EncryptOpts ` :
3961
+
3962
+ ` ` ` typescript
3963
+ class EncryptOpts {
3964
+ keyId : <key1ID>,
3965
+ algorithm: "TextPreview",
3966
+ contentionFactor: 0,
3967
+ textOpts: TextOpts {
3968
+ caseSensitive: true,
3969
+ diacriticSensitive: true,
3970
+ substring: <SubstringOpts>
3971
+ },
3972
+ }
3973
+ ` ` `
3974
+
3975
+ Use ` encryptedClient ` to insert the following document into ` db.explicit_encryption ` :
3976
+
3977
+ ` ` ` javascript
3978
+ { "_id": 0, "encryptedText": <encrypted "foobarbaz"> }
3979
+ ` ` `
3980
+
3981
+ #### Case 5 : can find a document by substring
3982
+ Use ` clientEncryption.encrypt() ` to encrypt the string ` "bar" ` :
3983
+
3984
+ Store this query in ` findPayload ` .
3985
+ ` ` ` javascript
3986
+ { "$expr": { "$encStrStartsWith": {"input": "encryptedText", "prefix": <encrypted "bar">}, } }
3987
+ ` ` `
3988
+
3989
+ Store the result in ` findPayload ` .
3990
+ Use ` encryptedClient ` to run a " find" operation on the ` db.explicit_encryption ` collection with the filter ` findPayload ` .
3991
+
3992
+ Assert the following document is returned :
3993
+
3994
+ ` ` ` javascript
3995
+ { "_id": 0, "encryptedText": "foobarbaz" }
3996
+ ` ` `
3997
+
3998
+ #### Case 6 : assert no document found by substring
3999
+
4000
+ Use ` clientEncryption.encrypt() ` to encrypt the string ` "qux" ` :
4001
+
4002
+ Store this query in ` findPayload ` .
3920
4003
` ` ` javascript
3921
- { "$expr": { "$encStrEndsWith ": {"input": "encryptedText", "suffix ": "baz" }, } }
4004
+ { "$expr": { "$encStrStartsWith ": {"input": "encryptedText", "prefix ": <encrypted "qux"> }, } }
3922
4005
` ` `
3923
4006
3924
4007
Store the result in ` findPayload ` .
0 commit comments