Skip to content

Commit 78bdf53

Browse files
authored
CDRIVER-6061 sync auto encryption tests for QE text (#2069)
* fix override of crypt_shared path Always try to set the `cryptSharedLib`path override, regardless of whether `extraOptions` is set in the test. * sync tests * expose internal API to get loaded libmongocrypt version * partially support schema 1.25 * update required libmongocrypt version libmongocrypt 1.15.0 is needed for full QE text support.
1 parent 9dd72b8 commit 78bdf53

File tree

12 files changed

+1771
-9
lines changed

12 files changed

+1771
-9
lines changed

.evergreen/scripts/compile-libmongocrypt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ compile_libmongocrypt() {
99
# `src/kms-message`.
1010
#
1111
# Run `.evergreen/scripts/kms-divergence-check.sh` to ensure that there is no divergence in the copied files.
12-
declare -r version="1.13.0"
12+
declare -r version="1.15.1"
1313

1414
git clone -q --depth=1 https://github.com/mongodb/libmongocrypt --branch "${version:?}" || return
1515

NEWS

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
libmongoc 2.2.0 (Unreleased)
1+
libmongoc 2.2.0 (unreleased)
22
============================
33

4+
## Notes
5+
6+
* Raise required version of libmongocrypt from 1.13.0 to 1.15.0 to support In-Use Encryption (corresponds to the CMake option: `ENABLE_CLIENT_SIDE_ENCRYPTION`).
7+
48
## Deprecated
59

610
- Support for macOS 11 (EOL since September 2023) and macOS 12 (EOL since September 2024).

src/libmongoc/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,10 +489,10 @@ elseif (NOT ENABLE_CLIENT_SIDE_ENCRYPTION STREQUAL OFF)
489489
find_package (mongocrypt QUIET)
490490
endif ()
491491

492-
if (mongocrypt_FOUND AND "${mongocrypt_VERSION}" VERSION_LESS 1.13.0)
492+
if (mongocrypt_FOUND AND "${mongocrypt_VERSION}" VERSION_LESS 1.15.0)
493493
message (STATUS " libmongocrypt found at ${mongocrypt_DIR}")
494494
message (STATUS " libmongocrypt version ${mongocrypt_VERSION} found")
495-
message (STATUS " libmongocrypt version 1.13.0 is required to enable In-Use Encryption Support.")
495+
message (STATUS " libmongocrypt version 1.15.0 is required to enable In-Use Encryption Support.")
496496
set (REQUIRED_MONGOCRYPT_VERSION_FOUND OFF)
497497
elseif (mongocrypt_FOUND)
498498
set (REQUIRED_MONGOCRYPT_VERSION_FOUND ON)

src/libmongoc/src/mongoc/mongoc-crypt-private.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ typedef struct mc_kms_credentials_callback {
3434
/* For interacting with libmongocrypt */
3535
typedef struct __mongoc_crypt_t _mongoc_crypt_t;
3636

37+
// `_mongoc_crypt_libmongocrypt_version` returns the version of the loaded libmongocrypt.
38+
const char *
39+
_mongoc_crypt_get_libmongocrypt_version(void);
40+
3741
/*
3842
Creates a new handle into libmongocrypt.
3943
- schema_map may be NULL.

src/libmongoc/src/mongoc/mongoc-crypt.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040

4141
#include <mongocrypt/mongocrypt.h>
4242

43+
const char *
44+
_mongoc_crypt_get_libmongocrypt_version(void)
45+
{
46+
return mongocrypt_version(NULL);
47+
}
48+
4349
// `mcd_mapof_kmsid_to_tlsopts` maps a KMS ID (e.g. `aws` or `aws:myname`) to a
4450
// `mongoc_ssl_opt_t`. The acryonym TLS is preferred over SSL for
4551
// consistency with the CSE and URI specifications.
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
{
2+
"description": "QE-Text-cleanupStructuredEncryptionData",
3+
"schemaVersion": "1.25",
4+
"runOnRequirements": [
5+
{
6+
"minServerVersion": "8.2.0",
7+
"topologies": [
8+
"replicaset",
9+
"sharded",
10+
"load-balanced"
11+
],
12+
"csfle": {
13+
"minLibmongocryptVersion": "1.15.0"
14+
}
15+
}
16+
],
17+
"createEntities": [
18+
{
19+
"client": {
20+
"id": "client",
21+
"autoEncryptOpts": {
22+
"keyVaultNamespace": "keyvault.datakeys",
23+
"kmsProviders": {
24+
"local": {
25+
"key": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk"
26+
}
27+
}
28+
},
29+
"observeEvents": [
30+
"commandStartedEvent"
31+
]
32+
}
33+
},
34+
{
35+
"database": {
36+
"id": "db",
37+
"client": "client",
38+
"databaseName": "db"
39+
}
40+
},
41+
{
42+
"collection": {
43+
"id": "coll",
44+
"database": "db",
45+
"collectionName": "coll"
46+
}
47+
}
48+
],
49+
"initialData": [
50+
{
51+
"databaseName": "keyvault",
52+
"collectionName": "datakeys",
53+
"documents": [
54+
{
55+
"_id": {
56+
"$binary": {
57+
"base64": "q83vqxI0mHYSNBI0VniQEg==",
58+
"subType": "04"
59+
}
60+
},
61+
"keyMaterial": {
62+
"$binary": {
63+
"base64": "HBk9BWihXExNDvTp1lUxOuxuZK2Pe2ZdVdlsxPEBkiO1bS4mG5NNDsQ7zVxJAH8BtdOYp72Ku4Y3nwc0BUpIKsvAKX4eYXtlhv5zUQxWdeNFhg9qK7qb8nqhnnLeT0f25jFSqzWJoT379hfwDeu0bebJHr35QrJ8myZdPMTEDYF08QYQ48ShRBli0S+QzBHHAQiM2iJNr4svg2WR8JSeWQ==",
64+
"subType": "00"
65+
}
66+
},
67+
"creationDate": {
68+
"$date": {
69+
"$numberLong": "1648914851981"
70+
}
71+
},
72+
"updateDate": {
73+
"$date": {
74+
"$numberLong": "1648914851981"
75+
}
76+
},
77+
"status": {
78+
"$numberInt": "0"
79+
},
80+
"masterKey": {
81+
"provider": "local"
82+
}
83+
}
84+
]
85+
},
86+
{
87+
"databaseName": "db",
88+
"collectionName": "coll",
89+
"documents": [],
90+
"createOptions": {
91+
"encryptedFields": {
92+
"fields": [
93+
{
94+
"keyId": {
95+
"$binary": {
96+
"base64": "q83vqxI0mHYSNBI0VniQEg==",
97+
"subType": "04"
98+
}
99+
},
100+
"path": "encryptedText",
101+
"bsonType": "string",
102+
"queries": [
103+
{
104+
"queryType": "suffixPreview",
105+
"contention": {
106+
"$numberLong": "0"
107+
},
108+
"strMinQueryLength": {
109+
"$numberLong": "3"
110+
},
111+
"strMaxQueryLength": {
112+
"$numberLong": "30"
113+
},
114+
"caseSensitive": true,
115+
"diacriticSensitive": true
116+
}
117+
]
118+
}
119+
]
120+
}
121+
}
122+
}
123+
],
124+
"tests": [
125+
{
126+
"description": "QE Text cleanupStructuredEncryptionData works",
127+
"operations": [
128+
{
129+
"name": "runCommand",
130+
"object": "db",
131+
"arguments": {
132+
"command": {
133+
"cleanupStructuredEncryptionData": "coll"
134+
},
135+
"commandName": "cleanupStructuredEncryptionData"
136+
},
137+
"expectResult": {
138+
"ok": 1
139+
}
140+
}
141+
],
142+
"expectEvents": [
143+
{
144+
"client": "client",
145+
"events": [
146+
{
147+
"commandStartedEvent": {
148+
"command": {
149+
"listCollections": 1,
150+
"filter": {
151+
"name": "coll"
152+
}
153+
},
154+
"commandName": "listCollections"
155+
}
156+
},
157+
{
158+
"commandStartedEvent": {
159+
"command": {
160+
"find": "datakeys",
161+
"filter": {
162+
"$or": [
163+
{
164+
"_id": {
165+
"$in": [
166+
{
167+
"$binary": {
168+
"base64": "q83vqxI0mHYSNBI0VniQEg==",
169+
"subType": "04"
170+
}
171+
}
172+
]
173+
}
174+
},
175+
{
176+
"keyAltNames": {
177+
"$in": []
178+
}
179+
}
180+
]
181+
},
182+
"$db": "keyvault",
183+
"readConcern": {
184+
"level": "majority"
185+
}
186+
},
187+
"commandName": "find"
188+
}
189+
},
190+
{
191+
"commandStartedEvent": {
192+
"command": {
193+
"cleanupStructuredEncryptionData": "coll",
194+
"cleanupTokens": {
195+
"encryptedText": {
196+
"ecoc": {
197+
"$binary": {
198+
"base64": "SWO8WEoZ2r2Kx/muQKb7+COizy85nIIUFiHh4K9kcvA=",
199+
"subType": "00"
200+
}
201+
},
202+
"anchorPaddingToken": {
203+
"$binary": {
204+
"base64": "YAiF7Iwhqq1UyfxPvm70xfQJtrIRPrjfD2yRLG1+saQ=",
205+
"subType": "00"
206+
}
207+
}
208+
}
209+
}
210+
},
211+
"commandName": "cleanupStructuredEncryptionData"
212+
}
213+
}
214+
]
215+
}
216+
]
217+
}
218+
]
219+
}

0 commit comments

Comments
 (0)