mongo 2.18.0.beta1 → 2.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/mongo/bulk_write.rb +8 -2
  4. data/lib/mongo/client.rb +19 -5
  5. data/lib/mongo/client_encryption.rb +86 -4
  6. data/lib/mongo/cluster.rb +6 -4
  7. data/lib/mongo/collection/view/aggregation.rb +3 -0
  8. data/lib/mongo/collection/view/change_stream.rb +9 -0
  9. data/lib/mongo/collection/view/iterable.rb +1 -0
  10. data/lib/mongo/collection/view/readable.rb +11 -3
  11. data/lib/mongo/collection.rb +9 -1
  12. data/lib/mongo/config.rb +11 -0
  13. data/lib/mongo/crypt/auto_encrypter.rb +49 -21
  14. data/lib/mongo/crypt/binding.rb +73 -48
  15. data/lib/mongo/crypt/data_key_context.rb +6 -1
  16. data/lib/mongo/crypt/encryption_io.rb +66 -0
  17. data/lib/mongo/crypt/explicit_encrypter.rb +116 -5
  18. data/lib/mongo/crypt/explicit_encryption_context.rb +3 -8
  19. data/lib/mongo/crypt/handle.rb +26 -8
  20. data/lib/mongo/crypt/kms/aws.rb +11 -3
  21. data/lib/mongo/crypt/kms/azure.rb +14 -6
  22. data/lib/mongo/crypt/kms/gcp.rb +12 -5
  23. data/lib/mongo/crypt/kms/kmip.rb +15 -9
  24. data/lib/mongo/crypt/kms/local.rb +9 -1
  25. data/lib/mongo/crypt/kms/master_key_document.rb +1 -1
  26. data/lib/mongo/crypt/rewrap_many_data_key_context.rb +46 -0
  27. data/lib/mongo/crypt/rewrap_many_data_key_result.rb +37 -0
  28. data/lib/mongo/crypt/status.rb +8 -2
  29. data/lib/mongo/crypt.rb +2 -0
  30. data/lib/mongo/database.rb +10 -27
  31. data/lib/mongo/error/missing_file_chunk.rb +8 -2
  32. data/lib/mongo/grid/stream/read.rb +6 -0
  33. data/lib/mongo/index/view.rb +1 -0
  34. data/lib/mongo/operation/create/op_msg.rb +1 -13
  35. data/lib/mongo/operation/distinct/op_msg.rb +4 -1
  36. data/lib/mongo/protocol/msg.rb +0 -16
  37. data/lib/mongo/server/connection_pool.rb +5 -4
  38. data/lib/mongo/server/monitor/connection.rb +10 -4
  39. data/lib/mongo/server/monitor.rb +4 -0
  40. data/lib/mongo/server/push_monitor.rb +4 -0
  41. data/lib/mongo/version.rb +1 -1
  42. data/lib/mongo.rb +2 -0
  43. data/spec/README.md +14 -0
  44. data/spec/integration/change_stream_spec.rb +1 -1
  45. data/spec/integration/client_construction_spec.rb +73 -7
  46. data/spec/integration/client_side_encryption/auto_encryption_command_monitoring_spec.rb +165 -164
  47. data/spec/integration/client_side_encryption/decryption_events_prose_spec.rb +158 -0
  48. data/spec/integration/client_side_encryption/explicit_queryable_encryption_spec.rb +5 -5
  49. data/spec/integration/client_side_encryption/kms_tls_options_spec.rb +50 -8
  50. data/spec/integration/client_side_encryption/unique_index_on_key_alt_names_prose_spec.rb +85 -0
  51. data/spec/integration/ocsp_verifier_spec.rb +1 -1
  52. data/spec/integration/reconnect_spec.rb +2 -0
  53. data/spec/integration/sdam_events_spec.rb +40 -0
  54. data/spec/integration/srv_monitoring_spec.rb +1 -0
  55. data/spec/integration/srv_spec.rb +1 -0
  56. data/spec/lite_spec_helper.rb +5 -4
  57. data/spec/mongo/bulk_write_spec.rb +13 -0
  58. data/spec/mongo/client_construction_spec.rb +45 -2
  59. data/spec/mongo/client_encryption_spec.rb +0 -12
  60. data/spec/mongo/client_spec.rb +1 -1
  61. data/spec/mongo/collection/view/aggregation_spec.rb +119 -0
  62. data/spec/mongo/collection/view/readable_spec.rb +630 -5
  63. data/spec/mongo/collection_spec.rb +32 -0
  64. data/spec/mongo/crypt/auto_encrypter_spec.rb +110 -0
  65. data/spec/mongo/crypt/binding/context_spec.rb +3 -35
  66. data/spec/mongo/crypt/data_key_context_spec.rb +1 -1
  67. data/spec/mongo/crypt/explicit_encryption_context_spec.rb +8 -3
  68. data/spec/mongo/crypt/handle_spec.rb +39 -3
  69. data/spec/mongo/crypt/kms/credentials_spec.rb +0 -47
  70. data/spec/mongo/index/view_spec.rb +56 -0
  71. data/spec/mongo/operation/create/op_msg_spec.rb +0 -42
  72. data/spec/mongo/server/connection_pool_spec.rb +26 -4
  73. data/spec/mongo/socket/ssl_spec.rb +3 -3
  74. data/spec/runners/crud/requirement.rb +6 -1
  75. data/spec/runners/crud/test.rb +1 -1
  76. data/spec/runners/transactions/spec.rb +2 -2
  77. data/spec/runners/transactions/test.rb +4 -20
  78. data/spec/runners/transactions.rb +2 -2
  79. data/spec/runners/unified/assertions.rb +32 -2
  80. data/spec/runners/unified/change_stream_operations.rb +3 -0
  81. data/spec/runners/unified/client_side_encryption_operations.rb +83 -0
  82. data/spec/runners/unified/crud_operations.rb +17 -2
  83. data/spec/runners/unified/ddl_operations.rb +27 -2
  84. data/spec/runners/unified/grid_fs_operations.rb +21 -0
  85. data/spec/runners/unified/test.rb +59 -1
  86. data/spec/shared/lib/mrss/docker_runner.rb +2 -0
  87. data/spec/shared/lib/mrss/eg_config_utils.rb +51 -0
  88. data/spec/shared/lib/mrss/lite_constraints.rb +10 -2
  89. data/spec/shared/shlib/set_env.sh +3 -0
  90. data/spec/solo/clean_exit_spec.rb +5 -0
  91. data/spec/spec_tests/client_side_encryption_spec.rb +1 -1
  92. data/spec/spec_tests/client_side_encryption_unified_spec.rb +16 -0
  93. data/spec/spec_tests/data/change_streams_unified/change-streams-showExpandedEvents.yml +298 -0
  94. data/spec/spec_tests/data/client_side_encryption/create-and-createIndexes.yml +58 -0
  95. data/spec/spec_tests/data/client_side_encryption/fle2-Delete.yml +1 -1
  96. data/spec/spec_tests/data/client_side_encryption/fle2-EncryptedFields-vs-jsonSchema.yml +1 -1
  97. data/spec/spec_tests/data/client_side_encryption/fle2-FindOneAndUpdate.yml +2 -2
  98. data/spec/spec_tests/data/client_side_encryption/fle2-InsertFind-Indexed.yml +1 -1
  99. data/spec/spec_tests/data/client_side_encryption/fle2-Update.yml +2 -2
  100. data/spec/spec_tests/data/client_side_encryption/unified/addKeyAltName.yml +194 -0
  101. data/spec/spec_tests/data/client_side_encryption/unified/createDataKey-kms_providers-invalid.yml +67 -0
  102. data/spec/spec_tests/data/client_side_encryption/unified/createDataKey.yml +309 -0
  103. data/spec/spec_tests/data/client_side_encryption/unified/deleteKey.yml +159 -0
  104. data/spec/spec_tests/data/client_side_encryption/unified/getKey.yml +105 -0
  105. data/spec/spec_tests/data/client_side_encryption/unified/getKeyByAltName.yml +104 -0
  106. data/spec/spec_tests/data/client_side_encryption/unified/getKeys.yml +122 -0
  107. data/spec/spec_tests/data/client_side_encryption/unified/removeKeyAltName.yml +157 -0
  108. data/spec/spec_tests/data/client_side_encryption/unified/rewrapManyDataKey-decrypt_failure.yml +69 -0
  109. data/spec/spec_tests/data/client_side_encryption/unified/rewrapManyDataKey-encrypt_failure.yml +122 -0
  110. data/spec/spec_tests/data/client_side_encryption/unified/rewrapManyDataKey.yml +432 -0
  111. data/spec/spec_tests/data/client_side_encryption/validatorAndPartialFieldExpression.yml +166 -0
  112. data/spec/spec_tests/data/command_monitoring_unified/bulkWrite.yml +68 -0
  113. data/spec/spec_tests/data/command_monitoring_unified/command.yml +50 -0
  114. data/spec/spec_tests/data/command_monitoring_unified/deleteMany.yml +79 -0
  115. data/spec/spec_tests/data/command_monitoring_unified/deleteOne.yml +79 -0
  116. data/spec/spec_tests/data/command_monitoring_unified/find.yml +254 -0
  117. data/spec/spec_tests/data/command_monitoring_unified/insertMany.yml +79 -0
  118. data/spec/spec_tests/data/command_monitoring_unified/insertOne.yml +77 -0
  119. data/spec/spec_tests/data/command_monitoring_unified/unacknowledgedBulkWrite.yml +55 -0
  120. data/spec/spec_tests/data/command_monitoring_unified/updateMany.yml +87 -0
  121. data/spec/spec_tests/data/command_monitoring_unified/updateOne.yml +118 -0
  122. data/spec/spec_tests/data/crud_unified/distinct-comment.yml +98 -0
  123. data/spec/spec_tests/data/gridfs_unified/delete.yml +198 -0
  124. data/spec/spec_tests/data/gridfs_unified/download.yml +241 -0
  125. data/spec/spec_tests/data/gridfs_unified/downloadByName.yml +159 -0
  126. data/spec/spec_tests/data/gridfs_unified/upload-disableMD5.yml +92 -0
  127. data/spec/spec_tests/data/gridfs_unified/upload.yml +288 -0
  128. data/spec/spec_tests/gridfs_unified_spec.rb +13 -0
  129. data/spec/stress/connection_pool_timing_spec.rb +2 -2
  130. data/spec/support/background_thread_registry.rb +3 -13
  131. data/spec/support/certificates/atlas-ocsp-ca.crt +40 -47
  132. data/spec/support/certificates/atlas-ocsp.crt +101 -106
  133. data/spec/support/crypt.rb +57 -13
  134. data/spec/support/macros.rb +10 -0
  135. data/spec/support/spec_config.rb +4 -0
  136. data.tar.gz.sig +0 -0
  137. metadata +1271 -1219
  138. metadata.gz.sig +0 -0
  139. data/spec/spec_tests/command_monitoring_spec.rb +0 -71
  140. data/spec/spec_tests/data/command_monitoring/bulkWrite.yml +0 -49
  141. data/spec/spec_tests/data/command_monitoring/command.yml +0 -61
  142. data/spec/spec_tests/data/command_monitoring/deleteMany.yml +0 -55
  143. data/spec/spec_tests/data/command_monitoring/deleteOne.yml +0 -55
  144. data/spec/spec_tests/data/command_monitoring/find.yml +0 -266
  145. data/spec/spec_tests/data/command_monitoring/insertMany.yml +0 -75
  146. data/spec/spec_tests/data/command_monitoring/insertOne.yml +0 -51
  147. data/spec/spec_tests/data/command_monitoring/unacknowledgedBulkWrite.yml +0 -34
  148. data/spec/spec_tests/data/command_monitoring/updateMany.yml +0 -65
  149. data/spec/spec_tests/data/command_monitoring/updateOne.yml +0 -90
@@ -0,0 +1,298 @@
1
+ description: "change-streams-showExpandedEvents"
2
+ schemaVersion: "1.7"
3
+ runOnRequirements:
4
+ - minServerVersion: "6.0.0"
5
+ topologies: [ replicaset, sharded-replicaset, sharded ]
6
+ createEntities:
7
+ - client:
8
+ id: &client0 client0
9
+ observeEvents: [ commandStartedEvent ]
10
+ ignoreCommandMonitoringEvents: [ killCursors ]
11
+ useMultipleMongoses: false
12
+ - database:
13
+ id: &database0 database0
14
+ client: *client0
15
+ databaseName: *database0
16
+ - collection:
17
+ id: &collection0 collection0
18
+ database: *database0
19
+ collectionName: *collection0
20
+ - database:
21
+ id: &database1 database1
22
+ client: *client0
23
+ databaseName: *database1
24
+ - collection:
25
+ id: &collection1 collection1
26
+ database: *database1
27
+ collectionName: *collection1
28
+ - database:
29
+ id: &shardedDb shardedDb
30
+ client: *client0
31
+ databaseName: *shardedDb
32
+ - database:
33
+ id: &adminDb adminDb
34
+ client: *client0
35
+ databaseName: admin
36
+ - collection:
37
+ id: &shardedCollection shardedCollection
38
+ database: *shardedDb
39
+ collectionName: *shardedCollection
40
+
41
+ initialData:
42
+ - collectionName: *collection0
43
+ databaseName: *database0
44
+ documents: []
45
+
46
+ tests:
47
+ - description: "when provided, showExpandedEvents is sent as a part of the aggregate command"
48
+ operations:
49
+ - name: createChangeStream
50
+ object: *collection0
51
+ arguments:
52
+ pipeline: []
53
+ showExpandedEvents: true
54
+ saveResultAsEntity: &changeStream0 changeStream0
55
+ expectEvents:
56
+ - client: *client0
57
+ ignoreExtraEvents: true
58
+ events:
59
+ - commandStartedEvent:
60
+ command:
61
+ aggregate: *collection0
62
+ cursor: {}
63
+ pipeline:
64
+ - $changeStream:
65
+ showExpandedEvents: true
66
+ commandName: aggregate
67
+ databaseName: *database0
68
+
69
+ - description: "when omitted, showExpandedEvents is not sent as a part of the aggregate command"
70
+ operations:
71
+ - name: createChangeStream
72
+ object: *collection0
73
+ arguments:
74
+ pipeline: []
75
+ saveResultAsEntity: &changeStream0 changeStream0
76
+ expectEvents:
77
+ - client: *client0
78
+ ignoreExtraEvents: true
79
+ events:
80
+ - commandStartedEvent:
81
+ command:
82
+ aggregate: *collection0
83
+ cursor: {}
84
+ pipeline:
85
+ - $changeStream:
86
+ showExpandedEvents:
87
+ $$exists: false
88
+ commandName: aggregate
89
+ databaseName: *database0
90
+
91
+ - description: "when showExpandedEvents is true, new fields on change stream events are handled appropriately"
92
+ operations:
93
+ - name: dropCollection
94
+ object: *database0
95
+ arguments:
96
+ collection: &existing-collection foo
97
+ - name: createCollection
98
+ object: *database0
99
+ arguments:
100
+ collection: *existing-collection
101
+ - name: createChangeStream
102
+ object: *collection0
103
+ arguments:
104
+ pipeline: []
105
+ showExpandedEvents: true
106
+ saveResultAsEntity: &changeStream0 changeStream0
107
+ - name: insertOne
108
+ object: *collection0
109
+ arguments:
110
+ document:
111
+ a: 1
112
+ - name: createIndex
113
+ object: *collection0
114
+ arguments:
115
+ keys:
116
+ x: 1
117
+ name: x_1
118
+ - name: rename
119
+ object: *collection0
120
+ arguments:
121
+ to: *existing-collection
122
+ dropTarget: true
123
+ - name: iterateUntilDocumentOrError
124
+ object: *changeStream0
125
+ expectResult:
126
+ operationType: insert
127
+ ns:
128
+ db: *database0
129
+ coll: *collection0
130
+ collectionUUID:
131
+ $$exists: true
132
+ - name: iterateUntilDocumentOrError
133
+ object: *changeStream0
134
+ expectResult:
135
+ operationType: createIndexes
136
+ ns:
137
+ db: *database0
138
+ coll: *collection0
139
+ operationDescription:
140
+ $$exists: true
141
+ - name: iterateUntilDocumentOrError
142
+ object: *changeStream0
143
+ expectResult:
144
+ operationType: rename
145
+ ns:
146
+ db: *database0
147
+ coll: *collection0
148
+ to:
149
+ db: *database0
150
+ coll: *existing-collection
151
+ operationDescription:
152
+ dropTarget:
153
+ $$exists: true
154
+ to:
155
+ db: *database0
156
+ coll: *existing-collection
157
+
158
+ - description: "when showExpandedEvents is true, createIndex events are reported"
159
+ operations:
160
+ - name: createChangeStream
161
+ object: *collection0
162
+ arguments:
163
+ pipeline: []
164
+ showExpandedEvents: true
165
+ saveResultAsEntity: &changeStream0 changeStream0
166
+ - name: createIndex
167
+ object: *collection0
168
+ arguments:
169
+ keys:
170
+ x: 1
171
+ name: x_1
172
+ - name: iterateUntilDocumentOrError
173
+ object: *changeStream0
174
+ expectResult:
175
+ operationType: createIndexes
176
+
177
+ - description: "when showExpandedEvents is true, dropIndexes events are reported"
178
+ operations:
179
+ - name: createIndex
180
+ object: *collection0
181
+ arguments:
182
+ keys:
183
+ x: 1
184
+ name: &index1 x_1
185
+ - name: createChangeStream
186
+ object: *collection0
187
+ arguments:
188
+ pipeline: []
189
+ showExpandedEvents: true
190
+ saveResultAsEntity: &changeStream0 changeStream0
191
+ - name: dropIndex
192
+ object: *collection0
193
+ arguments:
194
+ name: *index1
195
+ - name: iterateUntilDocumentOrError
196
+ object: *changeStream0
197
+ expectResult:
198
+ operationType: dropIndexes
199
+
200
+ - description: "when showExpandedEvents is true, create events are reported"
201
+ operations:
202
+ - name: dropCollection
203
+ object: *database0
204
+ arguments:
205
+ collection: &collection1 foo
206
+ - name: createChangeStream
207
+ object: *database0
208
+ arguments:
209
+ pipeline: []
210
+ showExpandedEvents: true
211
+ saveResultAsEntity: &changeStream0 changeStream0
212
+ - name: createCollection
213
+ object: *database0
214
+ arguments:
215
+ collection: *collection1
216
+ - name: iterateUntilDocumentOrError
217
+ object: *changeStream0
218
+ expectResult:
219
+ operationType: create
220
+
221
+ - description: "when showExpandedEvents is true, create events on views are reported"
222
+ operations:
223
+ - name: dropCollection
224
+ object: *database0
225
+ arguments:
226
+ collection: &collection1 foo
227
+ - name: createChangeStream
228
+ object: *database0
229
+ arguments:
230
+ pipeline: []
231
+ showExpandedEvents: true
232
+ saveResultAsEntity: &changeStream0 changeStream0
233
+ - name: createCollection
234
+ object: *database0
235
+ arguments:
236
+ collection: *collection1
237
+ viewOn: testName
238
+ - name: iterateUntilDocumentOrError
239
+ object: *changeStream0
240
+ expectResult:
241
+ operationType: create
242
+
243
+ - description: "when showExpandedEvents is true, modify events are reported"
244
+ operations:
245
+ - name: createIndex
246
+ object: *collection0
247
+ arguments:
248
+ keys:
249
+ x: 1
250
+ name: &index2 x_2
251
+ - name: createChangeStream
252
+ object: *collection0
253
+ arguments:
254
+ pipeline: []
255
+ showExpandedEvents: true
256
+ saveResultAsEntity: &changeStream0 changeStream0
257
+ - name: runCommand
258
+ object: *database0
259
+ arguments:
260
+ command:
261
+ collMod: *collection0
262
+ # Added here to fix our tests as we require a commandName but don't
263
+ # do anything with it.
264
+ commandName: modify_collection
265
+ - name: iterateUntilDocumentOrError
266
+ object: *changeStream0
267
+ expectResult:
268
+ operationType: modify
269
+
270
+ - description: "when showExpandedEvents is true, shardCollection events are reported"
271
+ runOnRequirements:
272
+ - topologies: [ sharded-replicaset, sharded ]
273
+ operations:
274
+ - name: dropCollection
275
+ object: *shardedDb
276
+ arguments:
277
+ collection: *shardedCollection
278
+ - name: createCollection
279
+ object: *shardedDb
280
+ arguments:
281
+ collection: *shardedCollection
282
+ - name: createChangeStream
283
+ object: *shardedCollection
284
+ arguments:
285
+ pipeline: []
286
+ showExpandedEvents: true
287
+ saveResultAsEntity: &changeStream0 changeStream0
288
+ - name: runCommand
289
+ object: *adminDb
290
+ arguments:
291
+ command:
292
+ shardCollection: shardedDb.shardedCollection
293
+ key:
294
+ _id: 1
295
+ - name: iterateUntilDocumentOrError
296
+ object: *changeStream0
297
+ expectResult:
298
+ operationType: shardCollection
@@ -0,0 +1,58 @@
1
+ runOn:
2
+ - minServerVersion: "4.1.10"
3
+ database_name: &database_name "default"
4
+ collection_name: &collection_name "default"
5
+
6
+ data: []
7
+ tests:
8
+ - description: "create is OK"
9
+ clientOptions:
10
+ autoEncryptOpts:
11
+ kmsProviders:
12
+ local: {'key': {'$binary': {'base64': 'Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk', 'subType': '00'}}}
13
+ operations:
14
+ # Drop to remove a collection that may exist from previous test runs.
15
+ - name: dropCollection
16
+ object: database
17
+ arguments:
18
+ collection: "unencryptedCollection"
19
+ - name: createCollection
20
+ object: database
21
+ arguments:
22
+ collection: "unencryptedCollection"
23
+ validator:
24
+ unencrypted_string: "foo"
25
+ - name: assertCollectionExists
26
+ object: testRunner
27
+ arguments:
28
+ database: *database_name
29
+ collection: "unencryptedCollection"
30
+ - description: "createIndexes is OK"
31
+ clientOptions:
32
+ autoEncryptOpts:
33
+ kmsProviders:
34
+ local: {'key': {'$binary': {'base64': 'Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk', 'subType': '00'}}}
35
+ operations:
36
+ # Drop to remove a collection that may exist from previous test runs.
37
+ - name: dropCollection
38
+ object: database
39
+ arguments:
40
+ collection: "unencryptedCollection"
41
+ - name: createCollection
42
+ object: database
43
+ arguments:
44
+ collection: "unencryptedCollection"
45
+ - name: runCommand
46
+ object: database
47
+ arguments:
48
+ command:
49
+ createIndexes: "unencryptedCollection"
50
+ indexes:
51
+ - name: "name"
52
+ key: { name: 1 }
53
+ - name: assertIndexExists
54
+ object: testRunner
55
+ arguments:
56
+ database: *database_name
57
+ collection: "unencryptedCollection"
58
+ index: name
@@ -71,7 +71,7 @@ tests:
71
71
  "encryptedIndexed": {
72
72
  "$eq": {
73
73
  "$binary": {
74
- "base64": "BYkAAAAFZAAgAAAAAPtVteJQAlgb2YMa/+7YWH00sbQPyt7L6Rb8OwBdMmL2BXMAIAAAAAAd44hgVKnEnTFlwNVC14oyc9OZOTspeymusqkRQj57nAVjACAAAAAA19X9v9NlWidu/wR5/C/7WUV54DfL5CkNmT5WYrhxdDcSY20AAAAAAAAAAAAA",
74
+ "base64": "BbEAAAAFZAAgAAAAAPtVteJQAlgb2YMa/+7YWH00sbQPyt7L6Rb8OwBdMmL2BXMAIAAAAAAd44hgVKnEnTFlwNVC14oyc9OZOTspeymusqkRQj57nAVjACAAAAAA19X9v9NlWidu/wR5/C/7WUV54DfL5CkNmT5WYrhxdDcFZQAgAAAAAOuac/eRLYakKX6B0vZ1r3QodOQFfjqJD+xlGiPu4/PsEmNtAAAAAAAAAAAAAA==",
75
75
  "subType": "06"
76
76
  }
77
77
  }
@@ -72,7 +72,7 @@ tests:
72
72
  "encryptedIndexed": {
73
73
  "$eq": {
74
74
  "$binary": {
75
- "base64": "BYkAAAAFZAAgAAAAAPGmZcUzdE/FPILvRSyAScGvZparGI2y9rJ/vSBxgCujBXMAIAAAAACi1RjmndKqgnXy7xb22RzUbnZl1sOZRXPOC0KcJkAxmQVjACAAAAAAWuidNu47c9A4Clic3DvFhn1AQJVC+FJtoE5bGZuz6PsSY20AAAAAAAAAAAAA",
75
+ "base64": "BbEAAAAFZAAgAAAAAPGmZcUzdE/FPILvRSyAScGvZparGI2y9rJ/vSBxgCujBXMAIAAAAACi1RjmndKqgnXy7xb22RzUbnZl1sOZRXPOC0KcJkAxmQVjACAAAAAAWuidNu47c9A4Clic3DvFhn1AQJVC+FJtoE5bGZuz6PsFZQAgAAAAAOuac/eRLYakKX6B0vZ1r3QodOQFfjqJD+xlGiPu4/PsEmNtAAAAAAAAAAAAAA==",
76
76
  "subType": "06"
77
77
  }
78
78
  }
@@ -70,7 +70,7 @@ tests:
70
70
  "encryptedIndexed": {
71
71
  "$eq": {
72
72
  "$binary": {
73
- "base64": "BYkAAAAFZAAgAAAAAPtVteJQAlgb2YMa/+7YWH00sbQPyt7L6Rb8OwBdMmL2BXMAIAAAAAAd44hgVKnEnTFlwNVC14oyc9OZOTspeymusqkRQj57nAVjACAAAAAA19X9v9NlWidu/wR5/C/7WUV54DfL5CkNmT5WYrhxdDcSY20AAAAAAAAAAAAA",
73
+ "base64": "BbEAAAAFZAAgAAAAAPtVteJQAlgb2YMa/+7YWH00sbQPyt7L6Rb8OwBdMmL2BXMAIAAAAAAd44hgVKnEnTFlwNVC14oyc9OZOTspeymusqkRQj57nAVjACAAAAAA19X9v9NlWidu/wR5/C/7WUV54DfL5CkNmT5WYrhxdDcFZQAgAAAAAOuac/eRLYakKX6B0vZ1r3QodOQFfjqJD+xlGiPu4/PsEmNtAAAAAAAAAAAAAA==",
74
74
  "subType": "06"
75
75
  }
76
76
  }
@@ -172,7 +172,7 @@ tests:
172
172
  "encryptedIndexed": {
173
173
  "$eq": {
174
174
  "$binary": {
175
- "base64": "BYkAAAAFZAAgAAAAAPtVteJQAlgb2YMa/+7YWH00sbQPyt7L6Rb8OwBdMmL2BXMAIAAAAAAd44hgVKnEnTFlwNVC14oyc9OZOTspeymusqkRQj57nAVjACAAAAAA19X9v9NlWidu/wR5/C/7WUV54DfL5CkNmT5WYrhxdDcSY20AAAAAAAAAAAAA",
175
+ "base64": "BbEAAAAFZAAgAAAAAPtVteJQAlgb2YMa/+7YWH00sbQPyt7L6Rb8OwBdMmL2BXMAIAAAAAAd44hgVKnEnTFlwNVC14oyc9OZOTspeymusqkRQj57nAVjACAAAAAA19X9v9NlWidu/wR5/C/7WUV54DfL5CkNmT5WYrhxdDcFZQAgAAAAAOuac/eRLYakKX6B0vZ1r3QodOQFfjqJD+xlGiPu4/PsEmNtAAAAAAAAAAAAAA==",
176
176
  "subType": "06"
177
177
  }
178
178
  }
@@ -68,7 +68,7 @@ tests:
68
68
  "encryptedIndexed": {
69
69
  "$eq": {
70
70
  "$binary": {
71
- "base64": "BYkAAAAFZAAgAAAAAPGmZcUzdE/FPILvRSyAScGvZparGI2y9rJ/vSBxgCujBXMAIAAAAACi1RjmndKqgnXy7xb22RzUbnZl1sOZRXPOC0KcJkAxmQVjACAAAAAAWuidNu47c9A4Clic3DvFhn1AQJVC+FJtoE5bGZuz6PsSY20AAAAAAAAAAAAA",
71
+ "base64": "BbEAAAAFZAAgAAAAAPGmZcUzdE/FPILvRSyAScGvZparGI2y9rJ/vSBxgCujBXMAIAAAAACi1RjmndKqgnXy7xb22RzUbnZl1sOZRXPOC0KcJkAxmQVjACAAAAAAWuidNu47c9A4Clic3DvFhn1AQJVC+FJtoE5bGZuz6PsFZQAgAAAAAOuac/eRLYakKX6B0vZ1r3QodOQFfjqJD+xlGiPu4/PsEmNtAAAAAAAAAAAAAA==",
72
72
  "subType": "06"
73
73
  }
74
74
  }
@@ -74,7 +74,7 @@ tests:
74
74
  "encryptedIndexed": {
75
75
  "$eq": {
76
76
  "$binary": {
77
- "base64": "BYkAAAAFZAAgAAAAAPtVteJQAlgb2YMa/+7YWH00sbQPyt7L6Rb8OwBdMmL2BXMAIAAAAAAd44hgVKnEnTFlwNVC14oyc9OZOTspeymusqkRQj57nAVjACAAAAAA19X9v9NlWidu/wR5/C/7WUV54DfL5CkNmT5WYrhxdDcSY20AAAAAAAAAAAAA",
77
+ "base64": "BbEAAAAFZAAgAAAAAPtVteJQAlgb2YMa/+7YWH00sbQPyt7L6Rb8OwBdMmL2BXMAIAAAAAAd44hgVKnEnTFlwNVC14oyc9OZOTspeymusqkRQj57nAVjACAAAAAA19X9v9NlWidu/wR5/C/7WUV54DfL5CkNmT5WYrhxdDcFZQAgAAAAAOuac/eRLYakKX6B0vZ1r3QodOQFfjqJD+xlGiPu4/PsEmNtAAAAAAAAAAAAAA==",
78
78
  "subType": "06"
79
79
  }
80
80
  }
@@ -179,7 +179,7 @@ tests:
179
179
  "encryptedIndexed": {
180
180
  "$eq": {
181
181
  "$binary": {
182
- "base64": "BYkAAAAFZAAgAAAAAPtVteJQAlgb2YMa/+7YWH00sbQPyt7L6Rb8OwBdMmL2BXMAIAAAAAAd44hgVKnEnTFlwNVC14oyc9OZOTspeymusqkRQj57nAVjACAAAAAA19X9v9NlWidu/wR5/C/7WUV54DfL5CkNmT5WYrhxdDcSY20AAAAAAAAAAAAA",
182
+ "base64": "BbEAAAAFZAAgAAAAAPtVteJQAlgb2YMa/+7YWH00sbQPyt7L6Rb8OwBdMmL2BXMAIAAAAAAd44hgVKnEnTFlwNVC14oyc9OZOTspeymusqkRQj57nAVjACAAAAAA19X9v9NlWidu/wR5/C/7WUV54DfL5CkNmT5WYrhxdDcFZQAgAAAAAOuac/eRLYakKX6B0vZ1r3QodOQFfjqJD+xlGiPu4/PsEmNtAAAAAAAAAAAAAA==",
183
183
  "subType": "06"
184
184
  }
185
185
  }
@@ -0,0 +1,194 @@
1
+ description: addKeyAltName
2
+
3
+ schemaVersion: "1.8"
4
+
5
+ runOnRequirements:
6
+ - csfle: true
7
+
8
+ createEntities:
9
+ - client:
10
+ id: &client0 client0
11
+ observeEvents:
12
+ - commandStartedEvent
13
+ - clientEncryption:
14
+ id: &clientEncryption0 clientEncryption0
15
+ clientEncryptionOpts:
16
+ keyVaultClient: *client0
17
+ keyVaultNamespace: keyvault.datakeys
18
+ kmsProviders:
19
+ local: { key: { $$placeholder: 1 } }
20
+ - database:
21
+ id: &database0 database0
22
+ client: *client0
23
+ databaseName: &database0Name keyvault
24
+ - collection:
25
+ id: &collection0 collection0
26
+ database: *database0
27
+ collectionName: &collection0Name datakeys
28
+
29
+ initialData:
30
+ - databaseName: *database0Name
31
+ collectionName: *collection0Name
32
+ documents:
33
+ - &local_key_doc
34
+ _id: &local_key_id { $binary: { base64: bG9jYWxrZXlsb2NhbGtleQ==, subType: "04" } }
35
+ keyMaterial: { $binary: { base64: ABKBldDEoDW323yejOnIRk6YQmlD9d3eQthd16scKL75nz2LjNL9fgPDZWrFFOlqlhMCFaSrNJfGrFUjYk5JFDO7soG5Syb50k1niJoKg4ilsj0L4mpimFUtTpOr2nzZOeQtvAksEXc7gsFgq8gV7t/U3lsaXPY7I0t42DfSE8EGlPdxRjFdHnxh+OR8h7U9b8Qs5K5UuhgyeyxaBZ1Hgw==, subType: "00" } }
36
+ creationDate: { $date: { $numberLong: "1641024000000" } }
37
+ updateDate: { $date: { $numberLong: "1641024000000" } }
38
+ status: 1
39
+ masterKey:
40
+ provider: local
41
+
42
+ tests:
43
+ - description: add keyAltName to non-existent data key
44
+ operations:
45
+ - name: addKeyAltName
46
+ object: *clientEncryption0
47
+ arguments:
48
+ # First 3 letters of local_key_id replaced with 'A' (value: "#alkeylocalkey").
49
+ id: &non_existent_id { $binary: { base64: AAAjYWxrZXlsb2NhbGtleQ==, subType: "04" } }
50
+ keyAltName: new_key_alt_name
51
+ expectResult: { $$unsetOrMatches: null }
52
+ expectEvents:
53
+ - client: *client0
54
+ events:
55
+ - commandStartedEvent:
56
+ databaseName: *database0Name
57
+ command:
58
+ findAndModify: *collection0Name
59
+ query: { _id: *non_existent_id }
60
+ update: { $addToSet: { keyAltNames: new_key_alt_name } }
61
+ writeConcern: { w: majority }
62
+ outcome:
63
+ - collectionName: *collection0Name
64
+ databaseName: *database0Name
65
+ documents:
66
+ - *local_key_doc
67
+
68
+ - description: add new keyAltName to data key with no keyAltNames
69
+ operations:
70
+ - name: addKeyAltName
71
+ object: *clientEncryption0
72
+ arguments:
73
+ id: *local_key_id
74
+ keyAltName: local_key
75
+ expectResult: *local_key_doc
76
+ - name: find
77
+ object: *collection0
78
+ arguments:
79
+ filter: {}
80
+ projection: { _id: 0, keyAltNames: 1 }
81
+ expectResult:
82
+ - keyAltNames: [local_key]
83
+ expectEvents:
84
+ - client: *client0
85
+ events:
86
+ - commandStartedEvent:
87
+ databaseName: *database0Name
88
+ command:
89
+ findAndModify: *collection0Name
90
+ query: { _id: *local_key_id }
91
+ update: { $addToSet: { keyAltNames: local_key } }
92
+ writeConcern: { w: majority }
93
+ - commandStartedEvent: { commandName: find }
94
+
95
+ - description: add existing keyAltName to existing data key
96
+ operations:
97
+ - name: addKeyAltName
98
+ object: *clientEncryption0
99
+ arguments:
100
+ id: *local_key_id
101
+ keyAltName: local_key
102
+ expectResult: *local_key_doc
103
+ - name: addKeyAltName
104
+ # Attempting to add a duplicate keyAltName to the data key should not be an error.
105
+ object: *clientEncryption0
106
+ arguments:
107
+ id: *local_key_id
108
+ keyAltName: local_key
109
+ expectResult:
110
+ _id: *local_key_id
111
+ keyAltNames: [local_key]
112
+ keyMaterial: { $$type: binData }
113
+ creationDate: { $$type: date }
114
+ updateDate: { $$type: date }
115
+ status: 1
116
+ masterKey:
117
+ provider: local
118
+ - name: find
119
+ object: *collection0
120
+ arguments:
121
+ filter: {}
122
+ projection: { _id: 0, keyAltNames: 1 }
123
+ expectResult:
124
+ - keyAltNames: [local_key]
125
+ expectEvents:
126
+ - client: *client0
127
+ events:
128
+ - commandStartedEvent:
129
+ databaseName: *database0Name
130
+ command:
131
+ findAndModify: *collection0Name
132
+ query: { _id: *local_key_id }
133
+ update: { $addToSet: { keyAltNames: local_key } }
134
+ writeConcern: { w: majority }
135
+ - commandStartedEvent:
136
+ databaseName: *database0Name
137
+ command:
138
+ findAndModify: *collection0Name
139
+ query: { _id: *local_key_id }
140
+ update: { $addToSet: { keyAltNames: local_key } }
141
+ writeConcern: { w: majority }
142
+ - commandStartedEvent: { commandName: find }
143
+
144
+ - description: add new keyAltName to data key with keyAltNames
145
+ operations:
146
+ - name: addKeyAltName
147
+ object: *clientEncryption0
148
+ arguments:
149
+ id: *local_key_id
150
+ keyAltName: local_key
151
+ expectResult: *local_key_doc
152
+ - name: addKeyAltName
153
+ object: *clientEncryption0
154
+ arguments:
155
+ id: *local_key_id
156
+ keyAltName: another_name
157
+ expectResult:
158
+ _id: *local_key_id
159
+ keyAltNames: [local_key]
160
+ keyMaterial: { $$type: binData }
161
+ creationDate: { $$type: date }
162
+ updateDate: { $$type: date }
163
+ status: 1
164
+ masterKey:
165
+ provider: local
166
+ - name: aggregate
167
+ object: *collection0
168
+ arguments:
169
+ pipeline:
170
+ # Ensure keyAltNames are in deterministically sorted order.
171
+ - $project: { _id: 0, keyAltNames: $keyAltNames }
172
+ - $unwind: $keyAltNames
173
+ - $sort: { keyAltNames: 1 }
174
+ expectResult:
175
+ - keyAltNames: another_name
176
+ - keyAltNames: local_key
177
+ expectEvents:
178
+ - client: *client0
179
+ events:
180
+ - commandStartedEvent:
181
+ databaseName: *database0Name
182
+ command:
183
+ findAndModify: *collection0Name
184
+ query: { _id: *local_key_id }
185
+ update: { $addToSet: { keyAltNames: local_key } }
186
+ writeConcern: { w: majority }
187
+ - commandStartedEvent:
188
+ databaseName: *database0Name
189
+ command:
190
+ findAndModify: *collection0Name
191
+ query: { _id: *local_key_id }
192
+ update: { $addToSet: { keyAltNames: another_name } }
193
+ writeConcern: { w: majority }
194
+ - commandStartedEvent: { commandName: aggregate }
@@ -0,0 +1,67 @@
1
+ description: createDataKey-provider-invalid
2
+
3
+ schemaVersion: "1.8"
4
+
5
+ runOnRequirements:
6
+ - csfle: true
7
+
8
+ createEntities:
9
+ - client:
10
+ id: &client0 client0
11
+ observeEvents:
12
+ - commandStartedEvent
13
+ - commandSucceededEvent
14
+ - commandFailedEvent
15
+ - clientEncryption:
16
+ id: &clientEncryption0 clientEncryption0
17
+ clientEncryptionOpts:
18
+ keyVaultClient: *client0
19
+ keyVaultNamespace: keyvault.datakeys
20
+ kmsProviders:
21
+ aws: { accessKeyId: { $$placeholder: 1 }, secretAccessKey: { $$placeholder: 1 } }
22
+
23
+ tests:
24
+ - description: create data key without required master key fields
25
+ operations:
26
+ - name: createDataKey
27
+ object: *clientEncryption0
28
+ arguments:
29
+ kmsProvider: aws
30
+ opts:
31
+ masterKey: {}
32
+ expectError:
33
+ isClientError: true
34
+ expectEvents:
35
+ - client: *client0
36
+ events: []
37
+
38
+ - description: create data key with invalid master key field
39
+ operations:
40
+ - name: createDataKey
41
+ object: *clientEncryption0
42
+ arguments:
43
+ kmsProvider: local
44
+ opts:
45
+ masterKey:
46
+ invalid: 1
47
+ expectError:
48
+ isClientError: true
49
+ expectEvents:
50
+ - client: *client0
51
+ events: []
52
+
53
+ - description: create data key with invalid master key
54
+ operations:
55
+ - name: createDataKey
56
+ object: *clientEncryption0
57
+ arguments:
58
+ kmsProvider: aws
59
+ opts:
60
+ masterKey:
61
+ key: arn:aws:kms:us-east-1:579766882180:key/89fcc2c4-08b0-4bd9-9f25-e30687b580d0
62
+ region: invalid
63
+ expectError:
64
+ isClientError: true
65
+ expectEvents:
66
+ - client: *client0
67
+ events: []