Skip to content

Commit aeea387

Browse files
committed
add QE text spec tests
1 parent 28ffbc4 commit aeea387

File tree

5 files changed

+1260
-0
lines changed

5 files changed

+1260
-0
lines changed
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
description: QE-Text-cleanupStructuredEncryptionData
2+
schemaVersion: "1.23"
3+
runOnRequirements:
4+
# Requires libmongocrypt 1.15.0 for SPM-4158.
5+
- minServerVersion: "8.2.0" # Server 8.2.0 adds preview support for QE text queries.
6+
topologies: ["replicaset", "sharded", "load-balanced"] # QE does not support standalone.
7+
createEntities:
8+
- client:
9+
id: &client "client"
10+
autoEncryptOpts:
11+
keyVaultNamespace: keyvault.datakeys
12+
kmsProviders:
13+
local:
14+
key: Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk
15+
observeEvents:
16+
- commandStartedEvent
17+
- database:
18+
id: &db "db"
19+
client: *client
20+
databaseName: db
21+
- collection:
22+
id: "coll"
23+
database: *db
24+
collectionName: &coll coll
25+
initialData:
26+
- databaseName: *db
27+
collectionName: *coll
28+
documents: []
29+
createOptions:
30+
encryptedFields:
31+
{
32+
"fields":
33+
[
34+
{
35+
"keyId":
36+
{
37+
"$binary":
38+
{ "base64": "q83vqxI0mHYSNBI0VniQEg==", "subType": "04" },
39+
},
40+
"path": "encryptedText",
41+
"bsonType": "string",
42+
"queries": [
43+
# Use zero contention for deterministic __safeContent__:
44+
{
45+
"queryType": "prefixPreview",
46+
"contention": { "$numberLong": "0" },
47+
"strMinQueryLength": { "$numberLong": "3" },
48+
"strMaxQueryLength": { "$numberLong": "30" },
49+
"caseSensitive": true,
50+
"diacriticSensitive": true,
51+
},
52+
],
53+
},
54+
],
55+
}
56+
- databaseName: keyvault
57+
collectionName: datakeys
58+
documents:
59+
[
60+
{
61+
"_id":
62+
{
63+
"$binary":
64+
{ "base64": "q83vqxI0mHYSNBI0VniQEg==", "subType": "04" },
65+
},
66+
"keyMaterial":
67+
{
68+
"$binary":
69+
{
70+
"base64": "HBk9BWihXExNDvTp1lUxOuxuZK2Pe2ZdVdlsxPEBkiO1bS4mG5NNDsQ7zVxJAH8BtdOYp72Ku4Y3nwc0BUpIKsvAKX4eYXtlhv5zUQxWdeNFhg9qK7qb8nqhnnLeT0f25jFSqzWJoT379hfwDeu0bebJHr35QrJ8myZdPMTEDYF08QYQ48ShRBli0S+QzBHHAQiM2iJNr4svg2WR8JSeWQ==",
71+
"subType": "00",
72+
},
73+
},
74+
"creationDate": { "$date": { "$numberLong": "1648914851981" } },
75+
"updateDate": { "$date": { "$numberLong": "1648914851981" } },
76+
"status": { "$numberInt": "0" },
77+
"masterKey": { "provider": "local" },
78+
},
79+
]
80+
tests:
81+
- description: "QE Text cleanupStructuredEncryptionData works"
82+
operations:
83+
- name: runCommand
84+
object: "db"
85+
arguments:
86+
command:
87+
cleanupStructuredEncryptionData: *coll
88+
commandName: cleanupStructuredEncryptionData
89+
expectResult: { ok: 1 }
90+
expectEvents:
91+
- client: *client
92+
events:
93+
- commandStartedEvent:
94+
command:
95+
listCollections: 1
96+
filter:
97+
name: *coll
98+
commandName: listCollections
99+
- commandStartedEvent:
100+
command:
101+
find: datakeys
102+
filter:
103+
{
104+
"$or":
105+
[
106+
"_id":
107+
{
108+
"$in":
109+
[
110+
"$binary":
111+
{
112+
"base64": "q83vqxI0mHYSNBI0VniQEg==",
113+
"subType": "04",
114+
},
115+
],
116+
},
117+
"keyAltNames": { "$in": [] },
118+
],
119+
}
120+
$db: keyvault
121+
readConcern: { level: "majority" }
122+
commandName: find
123+
- commandStartedEvent:
124+
command:
125+
{
126+
"cleanupStructuredEncryptionData": "coll",
127+
"cleanupTokens": {
128+
"encryptedText": {
129+
"ecoc": {
130+
"$binary": {
131+
"base64": "SWO8WEoZ2r2Kx/muQKb7+COizy85nIIUFiHh4K9kcvA=",
132+
"subType": "00"
133+
}
134+
},
135+
"anchorPaddingToken": {
136+
"$binary": {
137+
"base64": "YAiF7Iwhqq1UyfxPvm70xfQJtrIRPrjfD2yRLG1+saQ=",
138+
"subType": "00"
139+
}
140+
}
141+
}
142+
}
143+
}
144+
commandName: cleanupStructuredEncryptionData
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
description: QE-Text-compactStructuredEncryptionData
2+
schemaVersion: "1.23"
3+
runOnRequirements:
4+
# Requires libmongocrypt 1.15.0 for SPM-4158.
5+
- minServerVersion: "8.2.0" # Server 8.2.0 adds preview support for QE text queries.
6+
topologies: ["replicaset", "sharded", "load-balanced"] # QE does not support standalone.
7+
createEntities:
8+
- client:
9+
id: &client "client"
10+
autoEncryptOpts:
11+
keyVaultNamespace: keyvault.datakeys
12+
kmsProviders:
13+
local:
14+
key: Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk
15+
observeEvents:
16+
- commandStartedEvent
17+
- database:
18+
id: &db "db"
19+
client: *client
20+
databaseName: db
21+
- collection:
22+
id: "coll"
23+
database: *db
24+
collectionName: &coll coll
25+
initialData:
26+
- databaseName: *db
27+
collectionName: *coll
28+
documents: []
29+
createOptions:
30+
encryptedFields:
31+
&encryptedFields {
32+
"fields":
33+
[
34+
{
35+
"keyId":
36+
{
37+
"$binary":
38+
{ "base64": "q83vqxI0mHYSNBI0VniQEg==", "subType": "04" },
39+
},
40+
"path": "encryptedText",
41+
"bsonType": "string",
42+
"queries": [
43+
# Use zero contention for deterministic __safeContent__:
44+
{
45+
"queryType": "prefixPreview",
46+
"contention": { "$numberLong": "0" },
47+
"strMinQueryLength": { "$numberLong": "3" },
48+
"strMaxQueryLength": { "$numberLong": "30" },
49+
"caseSensitive": true,
50+
"diacriticSensitive": true,
51+
},
52+
],
53+
},
54+
],
55+
}
56+
- databaseName: keyvault
57+
collectionName: datakeys
58+
documents:
59+
[
60+
{
61+
"_id":
62+
{
63+
"$binary":
64+
{ "base64": "q83vqxI0mHYSNBI0VniQEg==", "subType": "04" },
65+
},
66+
"keyMaterial":
67+
{
68+
"$binary":
69+
{
70+
"base64": "HBk9BWihXExNDvTp1lUxOuxuZK2Pe2ZdVdlsxPEBkiO1bS4mG5NNDsQ7zVxJAH8BtdOYp72Ku4Y3nwc0BUpIKsvAKX4eYXtlhv5zUQxWdeNFhg9qK7qb8nqhnnLeT0f25jFSqzWJoT379hfwDeu0bebJHr35QrJ8myZdPMTEDYF08QYQ48ShRBli0S+QzBHHAQiM2iJNr4svg2WR8JSeWQ==",
71+
"subType": "00",
72+
},
73+
},
74+
"creationDate": { "$date": { "$numberLong": "1648914851981" } },
75+
"updateDate": { "$date": { "$numberLong": "1648914851981" } },
76+
"status": { "$numberInt": "0" },
77+
"masterKey": { "provider": "local" },
78+
},
79+
]
80+
tests:
81+
- description: "QE Text compactStructuredEncryptionData works"
82+
operations:
83+
- name: runCommand
84+
object: "db"
85+
arguments:
86+
command:
87+
compactStructuredEncryptionData: *coll
88+
commandName: compactStructuredEncryptionData
89+
expectResult: { ok: 1 }
90+
expectEvents:
91+
- client: *client
92+
events:
93+
- commandStartedEvent:
94+
command:
95+
listCollections: 1
96+
filter:
97+
name: *coll
98+
commandName: listCollections
99+
- commandStartedEvent:
100+
command:
101+
find: datakeys
102+
filter:
103+
{
104+
"$or":
105+
[
106+
"_id":
107+
{
108+
"$in":
109+
[
110+
"$binary":
111+
{
112+
"base64": "q83vqxI0mHYSNBI0VniQEg==",
113+
"subType": "04",
114+
},
115+
],
116+
},
117+
"keyAltNames": { "$in": [] },
118+
],
119+
}
120+
$db: keyvault
121+
readConcern: { level: "majority" }
122+
commandName: find
123+
- commandStartedEvent:
124+
command:
125+
compactStructuredEncryptionData: "coll"
126+
encryptionInformation:
127+
type: { "$numberInt": "1" }
128+
schema:
129+
db.coll:
130+
<<: *encryptedFields
131+
# libmongocrypt applies strEncodeVersion, escCollection, and ecocCollection:
132+
strEncodeVersion: { "$numberInt": "1" }
133+
escCollection: "enxcol_.coll.esc"
134+
ecocCollection: "enxcol_.coll.ecoc"
135+
compactionTokens:
136+
encryptedText:
137+
ecoc:
138+
{
139+
"$binary":
140+
{
141+
"base64": "SWO8WEoZ2r2Kx/muQKb7+COizy85nIIUFiHh4K9kcvA=",
142+
"subType": "00",
143+
},
144+
}
145+
anchorPaddingToken:
146+
{
147+
"$binary":
148+
{
149+
"base64": "YAiF7Iwhqq1UyfxPvm70xfQJtrIRPrjfD2yRLG1+saQ=",
150+
"subType": "00",
151+
},
152+
}
153+
commandName: compactStructuredEncryptionData

0 commit comments

Comments
 (0)