Skip to content

Commit 7c3288b

Browse files
authored
Update payloads to new Queryable Encryption protocol (#1103)
JAVA-4891
1 parent 12275e4 commit 7c3288b

File tree

62 files changed

+218
-652
lines changed

Some content is hidden

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

62 files changed

+218
-652
lines changed

build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ ext {
5555
zstdVersion = '1.5.2-5'
5656
awsSdkV2Version = '2.18.9'
5757
awsSdkV1Version = '1.12.337'
58-
mongoCryptVersion = '1.7.3'
58+
mongoCryptVersion = '1.8.0-SNAPSHOT'
5959
projectReactorVersion = '2022.0.0'
6060
junitBomVersion = '5.8.2'
6161
gitVersion = getGitVersion()
@@ -82,12 +82,12 @@ configure(coreProjects) {
8282
mavenCentral()
8383

8484
// Uncomment this to test with a snapshot build of mongodb-crypt
85-
// maven {
86-
// url 'https://oss.sonatype.org/content/repositories/snapshots'
87-
// content {
88-
// includeGroup "org.mongodb"
89-
// }
90-
// }
85+
maven {
86+
url 'https://oss.sonatype.org/content/repositories/snapshots'
87+
content {
88+
includeGroup "org.mongodb"
89+
}
90+
}
9191
}
9292
}
9393

driver-core/src/test/resources/client-side-encryption/README.rst

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ Do the following before running spec tests:
163163

164164
Load each YAML (or JSON) file using a Canonical Extended JSON parser.
165165

166+
If the test file name matches the regular expression ``fle2\-Range\-.*\-Correctness``, drivers MAY skip the test on macOS. The ``fle2-Range`` tests are very slow on macOS and do not provide significant additional test coverage.
167+
166168
Then for each element in ``tests``:
167169

168170
#. If the ``skipReason`` field is present, skip this test completely.
@@ -1677,7 +1679,14 @@ Expect no error on construction.
16771679
12. Explicit Encryption
16781680
~~~~~~~~~~~~~~~~~~~~~~~
16791681

1680-
The Explicit Encryption tests require MongoDB server 6.0+. The tests must not run against a standalone.
1682+
The Explicit Encryption tests require MongoDB server 7.0+. The tests must not run against a standalone.
1683+
1684+
.. note::
1685+
MongoDB Server 7.0 introduced a backwards breaking change to the Queryable Encryption (QE) protocol: QEv2.
1686+
libmongocrypt 1.8.0 is configured to use the QEv2 protocol.
1687+
1688+
.. note::
1689+
Skip this test on Serverless until MongoDB Serverless enables the QEv2 protocol. Refer: `DRIVERS-2589 <https://jira.mongodb.org/browse/DRIVERS-2589>`_
16811690

16821691
Before running each of the following test cases, perform the following Test Setup.
16831692

@@ -2493,7 +2502,14 @@ The following tests that a mongocryptd client is not created when shared library
24932502
21. Automatic Data Encryption Keys
24942503
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24952504

2496-
The Automatic Data Encryption Keys tests require MongoDB server 6.0+. The tests must not run against a standalone.
2505+
The Automatic Data Encryption Keys tests require MongoDB server 7.0+. The tests must not run against a standalone.
2506+
2507+
.. note::
2508+
MongoDB Server 7.0 introduced a backwards breaking change to the Queryable Encryption (QE) protocol: QEv2.
2509+
libmongocrypt 1.8.0 is configured to use the QEv2 protocol.
2510+
2511+
.. note::
2512+
Skip this test on Serverless until MongoDB Serverless enables the QEv2 protocol. Refer: `DRIVERS-2589 <https://jira.mongodb.org/browse/DRIVERS-2589>`_
24972513

24982514
For each of the following test cases, assume `DB` is a valid open database
24992515
handle, and assume a ClientEncryption_ object `CE` created using the following
@@ -2504,9 +2520,24 @@ options::
25042520
keyVaultNamespace: "keyvault.datakeys",
25052521
kmsProviders: {
25062522
local: { key: base64Decode(LOCAL_MASTERKEY) },
2523+
aws: {
2524+
accessKeyId: <set from environment>,
2525+
secretAccessKey: <set from environment>
2526+
},
25072527
},
25082528
}
25092529

2530+
Run each test case with each of these KMS providers: ``aws``, ``local``. The KMS provider name is referred to as ``kmsProvider``.
2531+
When testing ``aws``, use the following as the ``masterKey`` option:
2532+
2533+
.. code:: javascript
2534+
2535+
{
2536+
region: "us-east-1",
2537+
key: "arn:aws:kms:us-east-1:579766882180:key/89fcc2c4-08b0-4bd9-9f25-e30687b580d0"
2538+
}
2539+
2540+
When testing ``local``, set ``masterKey`` to ``null``.
25102541

25112542
Case 1: Simple Creation and Validation
25122543
``````````````````````````````````````
@@ -2533,7 +2564,7 @@ rejects an attempt to insert plaintext in an encrypted fields.
25332564
}
25342565
}
25352566

2536-
2. Invoke `CreateEncryptedCollection(CE, DB, "testing1", Opts, "local", null)`
2567+
2. Invoke `CreateEncryptedCollection(CE, DB, "testing1", Opts, kmsProvider, masterKey)`
25372568
to obtain a new collection `Coll`. Expect success.
25382569
3. Attempt to insert the following document into `Coll`::
25392570

@@ -2557,7 +2588,7 @@ missing.
25572588

25582589
1. Create a new empty create-collection options `Opts`. (i.e. it must not
25592590
contain any ``encryptedFields`` options.)
2560-
2. Invoke `CreateEncryptedCollection(CE, DB, "testing1", Opts, "local", null)`.
2591+
2. Invoke `CreateEncryptedCollection(CE, DB, "testing1", Opts, kmsProvider, masterKey)`.
25612592
3. Expect the invocation to fail with an error indicating that
25622593
``encryptedFields`` is not defined for the collection, and expect that no
25632594
collection was created within the database. It would be *incorrect* for
@@ -2590,7 +2621,7 @@ when attempting to create a collection with such invalid settings.
25902621
}
25912622
}
25922623

2593-
2. Invoke `CreateEncryptedCollection(CE, DB, "testing1", Opts, "local", null)`.
2624+
2. Invoke `CreateEncryptedCollection(CE, DB, "testing1", Opts, kmsProvider, masterKey)`.
25942625
3. Expect an error from the server indicating a validation error at
25952626
``create.encryptedFields.fields.keyId``, which must be a UUID and not a
25962627
boolean value.
@@ -2613,7 +2644,7 @@ with encrypted value.
26132644
}
26142645
}
26152646

2616-
2. Invoke `CreateEncryptedCollection(CE, DB, "testing1", Opts, "local", null)`
2647+
2. Invoke `CreateEncryptedCollection(CE, DB, "testing1", Opts, kmsProvider, masterKey)`
26172648
to obtain a new collection `Coll` and data key `key1`. Expect success.
26182649
3. Use `CE` to explicitly encrypt the string "123-45-6789" using
26192650
algorithm `Unindexed` and data key `key1`. Refer result as `encryptedPayload`.
@@ -2627,7 +2658,14 @@ with encrypted value.
26272658

26282659
22. Range Explicit Encryption
26292660
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2630-
The Range Explicit Encryption tests require MongoDB server 6.2+. The tests must not run against a standalone.
2661+
The Range Explicit Encryption tests require MongoDB server 7.0+. The tests must not run against a standalone.
2662+
2663+
.. note::
2664+
MongoDB Server 7.0 introduced a backwards breaking change to the Queryable Encryption (QE) protocol: QEv2.
2665+
libmongocrypt 1.8.0 is configured to use the QEv2 protocol.
2666+
2667+
.. note::
2668+
Skip this test on Serverless until MongoDB Serverless enables the QEv2 protocol. Refer: `DRIVERS-2589 <https://jira.mongodb.org/browse/DRIVERS-2589>`_
26312669

26322670
Each of the following test cases must pass for each of the supported types (``DecimalNoPrecision``, ``DecimalPrecision``, ``DoublePrecision``, ``DoubleNoPrecision``, ``Date``, ``Int``, and ``Long``), unless it is stated the type should be skipped.
26332671

driver-core/src/test/resources/client-side-encryption/legacy/fle2-BypassQueryAnalysis.json renamed to driver-core/src/test/resources/client-side-encryption/legacy/fle2v2-BypassQueryAnalysis.json

Lines changed: 6 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"runOn": [
33
{
4-
"minServerVersion": "6.0.0",
4+
"minServerVersion": "7.0.0",
5+
"serverless": "forbid",
56
"topology": [
67
"replicaset",
78
"sharded",
@@ -75,36 +76,6 @@
7576
"masterKey": {
7677
"provider": "local"
7778
}
78-
},
79-
{
80-
"_id": {
81-
"$binary": {
82-
"base64": "q83vqxI0mHYSNBI0VniQEg==",
83-
"subType": "04"
84-
}
85-
},
86-
"keyMaterial": {
87-
"$binary": {
88-
"base64": "HBk9BWihXExNDvTp1lUxOuxuZK2Pe2ZdVdlsxPEBkiO1bS4mG5NNDsQ7zVxJAH8BtdOYp72Ku4Y3nwc0BUpIKsvAKX4eYXtlhv5zUQxWdeNFhg9qK7qb8nqhnnLeT0f25jFSqzWJoT379hfwDeu0bebJHr35QrJ8myZdPMTEDYF08QYQ48ShRBli0S+QzBHHAQiM2iJNr4svg2WR8JSeWQ==",
89-
"subType": "00"
90-
}
91-
},
92-
"creationDate": {
93-
"$date": {
94-
"$numberLong": "1648914851981"
95-
}
96-
},
97-
"updateDate": {
98-
"$date": {
99-
"$numberLong": "1648914851981"
100-
}
101-
},
102-
"status": {
103-
"$numberInt": "0"
104-
},
105-
"masterKey": {
106-
"provider": "local"
107-
}
10879
}
10980
],
11081
"tests": [
@@ -133,7 +104,7 @@
133104
"_id": 1,
134105
"encryptedIndexed": {
135106
"$binary": {
136-
"base64": "BHEBAAAFZAAgAAAAAHb62aV7+mqmaGcotPLdG3KP7S8diFwWMLM/5rYtqLrEBXMAIAAAAAAVJ6OWHRv3OtCozHpt3ZzfBhaxZirLv3B+G8PuaaO4EgVjACAAAAAAsZXWOWA+UiCBbrJNB6bHflB/cn7pWSvwWN2jw4FPeIUFcABQAAAAAMdD1nV2nqeI1eXEQNskDflCy8I7/HvvqDKJ6XxjhrPQWdLqjz+8GosGUsB7A8ee/uG9/guENuL25XD+Fxxkv1LLXtavHOlLF7iW0u9yabqqBXUAEAAAAAQSNFZ4EjSYdhI0EjRWeJASEHQAAgAAAAV2AE0AAAAAq83vqxI0mHYSNBI0VniQEkzZZBBDgeZh+h+gXEmOrSFtVvkUcnHWj/rfPW7iJ0G3UJ8zpuBmUM/VjOMJCY4+eDqdTiPIwX+/vNXegc8FZQAgAAAAAOuac/eRLYakKX6B0vZ1r3QodOQFfjqJD+xlGiPu4/PsAA==",
107+
"base64": "C18BAAAFZAAgAAAAANnt+eLTkv4GdDPl8IAfJOvTzArOgFJQ2S/DcLza4W0DBXMAIAAAAAD2u+omZme3P2gBPehMQyQHQ153tPN1+z7bksYA9jKTpAVwADAAAAAAUnCOQqIvmR65YKyYnsiVfVrg9hwUVO3RhhKExo3RWOzgaS0QdsBL5xKFS0JhZSoWBXUAEAAAAAQSNFZ4EjSYdhI0EjRWeJASEHQAAgAAAAV2AFAAAAAAEjRWeBI0mHYSNBI0VniQEpQbp/ZJpWBKeDtKLiXb0P2E9wvc0g3f373jnYQYlJquOrlPOoEy3ngsHPJuSUijvWDsrQzqYa349K7G/66qaXEFZQAgAAAAAOuac/eRLYakKX6B0vZ1r3QodOQFfjqJD+xlGiPu4/PsBWwAIAAAAACkm0o9bj6j0HuADKc0svbqO2UHj6GrlNdF6yKNxh63xRJrAAAAAAAAAAAAAA==",
137108
"subType": "06"
138109
}
139110
}
@@ -150,7 +121,7 @@
150121
"result": [
151122
{
152123
"_id": 1,
153-
"encryptedIndexed": "value123"
124+
"encryptedIndexed": "123"
154125
}
155126
]
156127
}
@@ -176,7 +147,7 @@
176147
"_id": 1,
177148
"encryptedIndexed": {
178149
"$binary": {
179-
"base64": "BHEBAAAFZAAgAAAAAHb62aV7+mqmaGcotPLdG3KP7S8diFwWMLM/5rYtqLrEBXMAIAAAAAAVJ6OWHRv3OtCozHpt3ZzfBhaxZirLv3B+G8PuaaO4EgVjACAAAAAAsZXWOWA+UiCBbrJNB6bHflB/cn7pWSvwWN2jw4FPeIUFcABQAAAAAMdD1nV2nqeI1eXEQNskDflCy8I7/HvvqDKJ6XxjhrPQWdLqjz+8GosGUsB7A8ee/uG9/guENuL25XD+Fxxkv1LLXtavHOlLF7iW0u9yabqqBXUAEAAAAAQSNFZ4EjSYdhI0EjRWeJASEHQAAgAAAAV2AE0AAAAAq83vqxI0mHYSNBI0VniQEkzZZBBDgeZh+h+gXEmOrSFtVvkUcnHWj/rfPW7iJ0G3UJ8zpuBmUM/VjOMJCY4+eDqdTiPIwX+/vNXegc8FZQAgAAAAAOuac/eRLYakKX6B0vZ1r3QodOQFfjqJD+xlGiPu4/PsAA==",
150+
"base64": "C18BAAAFZAAgAAAAANnt+eLTkv4GdDPl8IAfJOvTzArOgFJQ2S/DcLza4W0DBXMAIAAAAAD2u+omZme3P2gBPehMQyQHQ153tPN1+z7bksYA9jKTpAVwADAAAAAAUnCOQqIvmR65YKyYnsiVfVrg9hwUVO3RhhKExo3RWOzgaS0QdsBL5xKFS0JhZSoWBXUAEAAAAAQSNFZ4EjSYdhI0EjRWeJASEHQAAgAAAAV2AFAAAAAAEjRWeBI0mHYSNBI0VniQEpQbp/ZJpWBKeDtKLiXb0P2E9wvc0g3f373jnYQYlJquOrlPOoEy3ngsHPJuSUijvWDsrQzqYa349K7G/66qaXEFZQAgAAAAAOuac/eRLYakKX6B0vZ1r3QodOQFfjqJD+xlGiPu4/PsBWwAIAAAAACkm0o9bj6j0HuADKc0svbqO2UHj6GrlNdF6yKNxh63xRJrAAAAAAAAAAAAAA==",
180151
"subType": "06"
181152
}
182153
}
@@ -230,39 +201,6 @@
230201
},
231202
"command_name": "find"
232203
}
233-
},
234-
{
235-
"command_started_event": {
236-
"command": {
237-
"find": "datakeys",
238-
"filter": {
239-
"$or": [
240-
{
241-
"_id": {
242-
"$in": [
243-
{
244-
"$binary": {
245-
"base64": "q83vqxI0mHYSNBI0VniQEg==",
246-
"subType": "04"
247-
}
248-
}
249-
]
250-
}
251-
},
252-
{
253-
"keyAltNames": {
254-
"$in": []
255-
}
256-
}
257-
]
258-
},
259-
"$db": "keyvault",
260-
"readConcern": {
261-
"level": "majority"
262-
}
263-
},
264-
"command_name": "find"
265-
}
266204
}
267205
],
268206
"outcome": {
@@ -276,7 +214,7 @@
276214
"__safeContent__": [
277215
{
278216
"$binary": {
279-
"base64": "ThpoKfQ8AkOzkFfNC1+9PF0pY2nIzfXvRdxQgjkNbBw=",
217+
"base64": "31eCYlbQoVboc5zwC8IoyJVSkag9PxREka8dkmbXJeY=",
280218
"subType": "00"
281219
}
282220
}

driver-core/src/test/resources/client-side-encryption/legacy/fle2-Compact.json renamed to driver-core/src/test/resources/client-side-encryption/legacy/fle2v2-Compact.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"runOn": [
33
{
4-
"minServerVersion": "6.0.0",
4+
"minServerVersion": "7.0.0",
5+
"serverless": "forbid",
56
"topology": [
67
"replicaset",
78
"sharded",

driver-core/src/test/resources/client-side-encryption/legacy/fle2-CreateCollection.json renamed to driver-core/src/test/resources/client-side-encryption/legacy/fle2v2-CreateCollection.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"runOn": [
33
{
4-
"minServerVersion": "6.0.0",
4+
"minServerVersion": "7.0.0",
5+
"serverless": "forbid",
56
"topology": [
67
"replicaset",
78
"sharded",

driver-core/src/test/resources/client-side-encryption/legacy/fle2-DecryptExistingData.json renamed to driver-core/src/test/resources/client-side-encryption/legacy/fle2v2-DecryptExistingData.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"runOn": [
33
{
4-
"minServerVersion": "6.0.0",
4+
"minServerVersion": "7.0.0",
5+
"serverless": "forbid",
56
"topology": [
67
"replicaset",
78
"sharded",

driver-core/src/test/resources/client-side-encryption/legacy/fle2-Delete.json renamed to driver-core/src/test/resources/client-side-encryption/legacy/fle2v2-Delete.json

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"runOn": [
33
{
4-
"minServerVersion": "6.0.0",
4+
"minServerVersion": "7.0.0",
5+
"serverless": "forbid",
56
"topology": [
67
"replicaset",
78
"sharded",
@@ -226,7 +227,7 @@
226227
"encryptedIndexed": {
227228
"$eq": {
228229
"$binary": {
229-
"base64": "BbEAAAAFZAAgAAAAAPtVteJQAlgb2YMa/+7YWH00sbQPyt7L6Rb8OwBdMmL2BXMAIAAAAAAd44hgVKnEnTFlwNVC14oyc9OZOTspeymusqkRQj57nAVjACAAAAAA19X9v9NlWidu/wR5/C/7WUV54DfL5CkNmT5WYrhxdDcFZQAgAAAAAOuac/eRLYakKX6B0vZ1r3QodOQFfjqJD+xlGiPu4/PsEmNtAAAAAAAAAAAAAA==",
230+
"base64": "DIkAAAAFZAAgAAAAAPtVteJQAlgb2YMa/+7YWH00sbQPyt7L6Rb8OwBdMmL2BXMAIAAAAAAd44hgVKnEnTFlwNVC14oyc9OZOTspeymusqkRQj57nAVsACAAAAAAaZ9s3G+4znfxStxeOZwcZy1OhzjMGc5hjmdMN+b/w6kSY20AAAAAAAAAAAAA",
230231
"subType": "06"
231232
}
232233
}
@@ -271,24 +272,6 @@
271272
}
272273
]
273274
}
274-
},
275-
"deleteTokens": {
276-
"default.default": {
277-
"encryptedIndexed": {
278-
"e": {
279-
"$binary": {
280-
"base64": "65pz95EthqQpfoHS9nWvdCh05AV+OokP7GUaI+7j8+w=",
281-
"subType": "00"
282-
}
283-
},
284-
"o": {
285-
"$binary": {
286-
"base64": "noN+05JsuO1oDg59yypIGj45i+eFH6HOTXOPpeZ//Mk=",
287-
"subType": "00"
288-
}
289-
}
290-
}
291-
}
292275
}
293276
}
294277
},
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"runOn": [
33
{
4-
"minServerVersion": "6.0.0",
4+
"minServerVersion": "7.0.0",
5+
"serverless": "forbid",
56
"topology": [
67
"replicaset",
78
"sharded",

driver-core/src/test/resources/client-side-encryption/legacy/fle2-EncryptedFields-vs-jsonSchema.json renamed to driver-core/src/test/resources/client-side-encryption/legacy/fle2v2-EncryptedFields-vs-jsonSchema.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"runOn": [
33
{
4-
"minServerVersion": "6.0.0",
4+
"minServerVersion": "7.0.0",
5+
"serverless": "forbid",
56
"topology": [
67
"replicaset",
78
"sharded",
@@ -231,7 +232,7 @@
231232
"encryptedIndexed": {
232233
"$eq": {
233234
"$binary": {
234-
"base64": "BbEAAAAFZAAgAAAAAPGmZcUzdE/FPILvRSyAScGvZparGI2y9rJ/vSBxgCujBXMAIAAAAACi1RjmndKqgnXy7xb22RzUbnZl1sOZRXPOC0KcJkAxmQVjACAAAAAAWuidNu47c9A4Clic3DvFhn1AQJVC+FJtoE5bGZuz6PsFZQAgAAAAAOuac/eRLYakKX6B0vZ1r3QodOQFfjqJD+xlGiPu4/PsEmNtAAAAAAAAAAAAAA==",
235+
"base64": "DIkAAAAFZAAgAAAAAPGmZcUzdE/FPILvRSyAScGvZparGI2y9rJ/vSBxgCujBXMAIAAAAACi1RjmndKqgnXy7xb22RzUbnZl1sOZRXPOC0KcJkAxmQVsACAAAAAApJtKPW4+o9B7gAynNLL26jtlB4+hq5TXResijcYet8USY20AAAAAAAAAAAAA",
235236
"subType": "06"
236237
}
237238
}

driver-core/src/test/resources/client-side-encryption/legacy/fle2-EncryptedFieldsMap-defaults.json renamed to driver-core/src/test/resources/client-side-encryption/legacy/fle2v2-EncryptedFieldsMap-defaults.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"runOn": [
33
{
4-
"minServerVersion": "6.0.0",
4+
"minServerVersion": "7.0.0",
5+
"serverless": "forbid",
56
"topology": [
67
"replicaset",
78
"sharded",
@@ -75,7 +76,6 @@
7576
"default.default": {
7677
"fields": [],
7778
"escCollection": "enxcol_.default.esc",
78-
"eccCollection": "enxcol_.default.ecc",
7979
"ecocCollection": "enxcol_.default.ecoc"
8080
}
8181
}

0 commit comments

Comments
 (0)