Skip to content

Commit 21cb923

Browse files
authored
PHPLIB-1375: Test KMIP "delegated" protocol (#1358)
* PHPLIB-1375: Test KMIP "delegated" protocol This syncs spec tests with mongodb/specifications@dc6eb4c * PHPLIB-1401: Sync CSFLE CSOT tests This syncs the spec tests to mongodb/specifications@5984422
1 parent 0b16223 commit 21cb923

File tree

6 files changed

+668
-14
lines changed

6 files changed

+668
-14
lines changed

tests/SpecTests/client-side-encryption/tests/azureKMS.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@
7878
"bsonType": "string",
7979
"algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"
8080
}
81+
},
82+
"encrypted_string_kmip_delegated": {
83+
"encrypt": {
84+
"keyId": [
85+
{
86+
"$uuid": "7411e9af-c688-4df7-8143-5e60ae96cba6"
87+
}
88+
],
89+
"bsonType": "string",
90+
"algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"
91+
}
8192
}
8293
},
8394
"bsonType": "object"

tests/SpecTests/client-side-encryption/tests/gcpKMS.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@
7878
"bsonType": "string",
7979
"algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"
8080
}
81+
},
82+
"encrypted_string_kmip_delegated": {
83+
"encrypt": {
84+
"keyId": [
85+
{
86+
"$uuid": "7411e9af-c688-4df7-8143-5e60ae96cba6"
87+
}
88+
],
89+
"bsonType": "string",
90+
"algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"
91+
}
8192
}
8293
},
8394
"bsonType": "object"

tests/SpecTests/client-side-encryption/tests/kmipKMS.json

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@
7878
"bsonType": "string",
7979
"algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"
8080
}
81+
},
82+
"encrypted_string_kmip_delegated": {
83+
"encrypt": {
84+
"keyId": [
85+
{
86+
"$uuid": "7411e9af-c688-4df7-8143-5e60ae96cba6"
87+
}
88+
],
89+
"bsonType": "string",
90+
"algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"
91+
}
8192
}
8293
},
8394
"bsonType": "object"
@@ -117,6 +128,38 @@
117128
"altname",
118129
"kmip_altname"
119130
]
131+
},
132+
{
133+
"_id": {
134+
"$uuid": "7411e9af-c688-4df7-8143-5e60ae96cba6"
135+
},
136+
"keyMaterial": {
137+
"$binary": {
138+
"base64": "5TLMFWlguBWe5GUESTvOVtkdBsCrynhnV72XRyZ66/nk+EP9/1oEp1t1sg0+vwCTqULHjBiUE6DRx2mYD/Eup1+u2Jgz9/+1sV1drXeOPALNPkSgiZiDbIb67zRi+wTABEcKcegJH+FhmSGxwUoQAiHCsCbcvia5P8tN1lt98YQ=",
139+
"subType": "00"
140+
}
141+
},
142+
"creationDate": {
143+
"$date": {
144+
"$numberLong": "1634220190041"
145+
}
146+
},
147+
"updateDate": {
148+
"$date": {
149+
"$numberLong": "1634220190041"
150+
}
151+
},
152+
"status": {
153+
"$numberInt": "0"
154+
},
155+
"masterKey": {
156+
"provider": "kmip",
157+
"delegated": true,
158+
"keyId": "11"
159+
},
160+
"keyAltNames": [
161+
"delegated"
162+
]
120163
}
121164
],
122165
"tests": [
@@ -218,6 +261,102 @@
218261
]
219262
}
220263
}
264+
},
265+
{
266+
"description": "Insert a document with auto encryption using KMIP delegated KMS provider",
267+
"clientOptions": {
268+
"autoEncryptOpts": {
269+
"kmsProviders": {
270+
"kmip": {}
271+
}
272+
}
273+
},
274+
"operations": [
275+
{
276+
"name": "insertOne",
277+
"arguments": {
278+
"document": {
279+
"_id": 1,
280+
"encrypted_string_kmip_delegated": "string0"
281+
}
282+
}
283+
}
284+
],
285+
"expectations": [
286+
{
287+
"command_started_event": {
288+
"command": {
289+
"listCollections": 1,
290+
"filter": {
291+
"name": "default"
292+
}
293+
},
294+
"command_name": "listCollections"
295+
}
296+
},
297+
{
298+
"command_started_event": {
299+
"command": {
300+
"find": "datakeys",
301+
"filter": {
302+
"$or": [
303+
{
304+
"_id": {
305+
"$in": [
306+
{
307+
"$uuid": "7411e9af-c688-4df7-8143-5e60ae96cba6"
308+
}
309+
]
310+
}
311+
},
312+
{
313+
"keyAltNames": {
314+
"$in": []
315+
}
316+
}
317+
]
318+
},
319+
"$db": "keyvault"
320+
},
321+
"command_name": "find"
322+
}
323+
},
324+
{
325+
"command_started_event": {
326+
"command": {
327+
"insert": "default",
328+
"documents": [
329+
{
330+
"_id": 1,
331+
"encrypted_string_kmip_delegated": {
332+
"$binary": {
333+
"base64": "AXQR6a/GiE33gUNeYK6Wy6YCkB+8NVfAAjIbvLqyXIg6g1a8tXrym92DPoqmxpcdQyH0vQM3aFNMz7tZwQBimKs29ztZV/LWjM633HhO5ACl9A==",
334+
"subType": "06"
335+
}
336+
}
337+
}
338+
],
339+
"ordered": true
340+
},
341+
"command_name": "insert"
342+
}
343+
}
344+
],
345+
"outcome": {
346+
"collection": {
347+
"data": [
348+
{
349+
"_id": 1,
350+
"encrypted_string_kmip_delegated": {
351+
"$binary": {
352+
"base64": "AXQR6a/GiE33gUNeYK6Wy6YCkB+8NVfAAjIbvLqyXIg6g1a8tXrym92DPoqmxpcdQyH0vQM3aFNMz7tZwQBimKs29ztZV/LWjM633HhO5ACl9A==",
353+
"subType": "06"
354+
}
355+
}
356+
}
357+
]
358+
}
359+
}
221360
}
222361
]
223362
}

tests/SpecTests/client-side-encryption/tests/timeoutMS.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,15 @@
161161
"failPoint": {
162162
"configureFailPoint": "failCommand",
163163
"mode": {
164-
"times": 3
164+
"times": 2
165165
},
166166
"data": {
167167
"failCommands": [
168168
"listCollections",
169169
"find"
170170
],
171171
"blockConnection": true,
172-
"blockTimeMS": 20
172+
"blockTimeMS": 30
173173
}
174174
},
175175
"clientOptions": {

tests/UnifiedSpecTests/client-side-encryption/createDataKey.json

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,70 @@
337337
}
338338
]
339339
},
340+
{
341+
"description": "create datakey with KMIP delegated KMS provider",
342+
"operations": [
343+
{
344+
"name": "createDataKey",
345+
"object": "clientEncryption0",
346+
"arguments": {
347+
"kmsProvider": "kmip",
348+
"opts": {
349+
"masterKey": {
350+
"delegated": true
351+
}
352+
}
353+
},
354+
"expectResult": {
355+
"$$type": "binData"
356+
}
357+
}
358+
],
359+
"expectEvents": [
360+
{
361+
"client": "client0",
362+
"events": [
363+
{
364+
"commandStartedEvent": {
365+
"databaseName": "keyvault",
366+
"command": {
367+
"insert": "datakeys",
368+
"documents": [
369+
{
370+
"_id": {
371+
"$$type": "binData"
372+
},
373+
"keyMaterial": {
374+
"$$type": "binData"
375+
},
376+
"creationDate": {
377+
"$$type": "date"
378+
},
379+
"updateDate": {
380+
"$$type": "date"
381+
},
382+
"status": {
383+
"$$exists": true
384+
},
385+
"masterKey": {
386+
"provider": "kmip",
387+
"keyId": {
388+
"$$type": "string"
389+
},
390+
"delegated": true
391+
}
392+
}
393+
],
394+
"writeConcern": {
395+
"w": "majority"
396+
}
397+
}
398+
}
399+
}
400+
]
401+
}
402+
]
403+
},
340404
{
341405
"description": "create datakey with local KMS provider",
342406
"operations": [

0 commit comments

Comments
 (0)