Skip to content

Commit f72c457

Browse files
committed
add QE text spec tests
1 parent c13d23b commit f72c457

File tree

5 files changed

+1263
-0
lines changed

5 files changed

+1263
-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+
csfle: true
8+
createEntities:
9+
- client:
10+
id: &client "client"
11+
autoEncryptOpts:
12+
keyVaultNamespace: keyvault.datakeys
13+
kmsProviders:
14+
local:
15+
key: Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk
16+
observeEvents:
17+
- commandStartedEvent
18+
- database:
19+
id: &db "db"
20+
client: *client
21+
databaseName: db
22+
- collection:
23+
id: "coll"
24+
database: *db
25+
collectionName: &coll coll
26+
initialData:
27+
- databaseName: *db
28+
collectionName: *coll
29+
documents: []
30+
createOptions:
31+
encryptedFields:
32+
{
33+
"fields":
34+
[
35+
{
36+
"keyId":
37+
{
38+
"$binary":
39+
{ "base64": "q83vqxI0mHYSNBI0VniQEg==", "subType": "04" },
40+
},
41+
"path": "encryptedText",
42+
"bsonType": "string",
43+
"queries": [
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+
csfle: true
8+
createEntities:
9+
- client:
10+
id: &client "client"
11+
autoEncryptOpts:
12+
keyVaultNamespace: keyvault.datakeys
13+
kmsProviders:
14+
local:
15+
key: Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk
16+
observeEvents:
17+
- commandStartedEvent
18+
- database:
19+
id: &db "db"
20+
client: *client
21+
databaseName: db
22+
- collection:
23+
id: "coll"
24+
database: *db
25+
collectionName: &coll coll
26+
initialData:
27+
- databaseName: *db
28+
collectionName: *coll
29+
documents: []
30+
createOptions:
31+
encryptedFields:
32+
&encryptedFields {
33+
"fields":
34+
[
35+
{
36+
"keyId":
37+
{
38+
"$binary":
39+
{ "base64": "q83vqxI0mHYSNBI0VniQEg==", "subType": "04" },
40+
},
41+
"path": "encryptedText",
42+
"bsonType": "string",
43+
"queries": [
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)