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,241 @@
1
+ description: "gridfs-download"
2
+
3
+ schemaVersion: "1.0"
4
+
5
+ createEntities:
6
+ - client:
7
+ id: &client0 client0
8
+ - database:
9
+ id: &database0 database0
10
+ client: *client0
11
+ databaseName: &database0Name gridfs-tests
12
+ - bucket:
13
+ id: &bucket0 bucket0
14
+ database: *database0
15
+ - collection:
16
+ id: &bucket0_files_collection bucket0_files_collection
17
+ database: *database0
18
+ collectionName: &bucket0_files_collectionName fs.files
19
+ - collection:
20
+ id: &bucket0_chunks_collection bucket0_chunks_collection
21
+ database: *database0
22
+ collectionName: &bucket0_chunks_collectionName fs.chunks
23
+
24
+ initialData:
25
+ - collectionName: *bucket0_files_collectionName
26
+ databaseName: *database0Name
27
+ documents:
28
+ - _id: { "$oid": "000000000000000000000001" }
29
+ length: 0
30
+ chunkSize: 4
31
+ uploadDate: { "$date": "1970-01-01T00:00:00.000Z" }
32
+ md5: "d41d8cd98f00b204e9800998ecf8427e"
33
+ filename: "length-0"
34
+ contentType: "application/octet-stream"
35
+ aliases: []
36
+ metadata: {}
37
+ - _id: { "$oid": "000000000000000000000002" }
38
+ length: 0
39
+ chunkSize: 4
40
+ uploadDate: { "$date": "1970-01-01T00:00:00.000Z" }
41
+ md5: "d41d8cd98f00b204e9800998ecf8427e"
42
+ filename: "length-0-with-empty-chunk"
43
+ contentType: "application/octet-stream"
44
+ aliases: []
45
+ metadata: {}
46
+ - _id: { "$oid": "000000000000000000000003" }
47
+ length: 2
48
+ chunkSize: 4
49
+ uploadDate: { "$date": "1970-01-01T00:00:00.000Z" }
50
+ md5: "c700ed4fdb1d27055aa3faa2c2432283"
51
+ filename: "length-2"
52
+ contentType: "application/octet-stream"
53
+ aliases: []
54
+ metadata: {}
55
+ - _id: { "$oid": "000000000000000000000004" }
56
+ length: 8
57
+ chunkSize: 4
58
+ uploadDate: { "$date": "1970-01-01T00:00:00.000Z" }
59
+ md5: "dd254cdc958e53abaa67da9f797125f5"
60
+ filename: "length-8"
61
+ contentType: "application/octet-stream"
62
+ aliases: []
63
+ metadata: {}
64
+ - _id: { "$oid": "000000000000000000000005" }
65
+ length: 10
66
+ chunkSize: 4
67
+ uploadDate: { "$date": "1970-01-01T00:00:00.000Z" }
68
+ md5: "57d83cd477bfb1ccd975ab33d827a92b"
69
+ filename: "length-10"
70
+ contentType: "application/octet-stream"
71
+ aliases: []
72
+ metadata: {}
73
+ - _id: { "$oid": "000000000000000000000006" }
74
+ length: 2
75
+ chunkSize: 4
76
+ uploadDate: { "$date": "1970-01-01T00:00:00.000Z" }
77
+ md5: "c700ed4fdb1d27055aa3faa2c2432283"
78
+ # filename is intentionally omitted
79
+ contentType: "application/octet-stream"
80
+ aliases: []
81
+ metadata: {}
82
+ - collectionName: *bucket0_chunks_collectionName
83
+ databaseName: *database0Name
84
+ documents:
85
+ - _id: { "$oid": "000000000000000000000001" }
86
+ files_id: { "$oid": "000000000000000000000002" }
87
+ n: 0
88
+ data: { "$binary": { "base64": "", "subType": "00" } }
89
+ - _id: { "$oid": "000000000000000000000002" }
90
+ files_id: { "$oid": "000000000000000000000003" }
91
+ n: 0
92
+ data: { "$binary": { "base64": "ESI=", "subType": "00" } } # hex: 1122
93
+ - _id: { "$oid": "000000000000000000000003" }
94
+ files_id: { "$oid": "000000000000000000000004" }
95
+ n: 0
96
+ data: { "$binary": { "base64": "ESIzRA==", "subType": "00" } } # hex: 11223344
97
+ - _id: { "$oid": "000000000000000000000004" }
98
+ files_id: { "$oid": "000000000000000000000004" }
99
+ n: 1
100
+ data: { "$binary": { "base64": "VWZ3iA==", "subType": "00" } } # hex: 55667788
101
+ - _id: { "$oid": "000000000000000000000005" }
102
+ files_id: { "$oid": "000000000000000000000005" }
103
+ n: 0
104
+ data: { "$binary": { "base64": "ESIzRA==", "subType": "00" } } # hex: 11223344
105
+ - _id: { "$oid": "000000000000000000000006" }
106
+ files_id: { "$oid": "000000000000000000000005" }
107
+ n: 1
108
+ data: { "$binary": { "base64": "VWZ3iA==", "subType": "00" } } # hex: 55667788
109
+ - _id: { "$oid": "000000000000000000000007" }
110
+ files_id: { "$oid": "000000000000000000000005" }
111
+ n: 2
112
+ data: { "$binary" : { "base64": "mao=", "subType" : "00" } } # hex: 99aa
113
+ - _id: { "$oid": "000000000000000000000008" }
114
+ files_id: { "$oid": "000000000000000000000006" }
115
+ n: 0
116
+ data: { "$binary": { "base64": "ESI=", "subType": "00" } } # hex: 1122
117
+
118
+ tests:
119
+ - description: "download when length is zero"
120
+ operations:
121
+ - name: download
122
+ object: *bucket0
123
+ arguments:
124
+ id: { $oid: "000000000000000000000001" }
125
+ expectResult: { $$matchesHexBytes: "" }
126
+ - description: "download when length is zero and there is one empty chunk"
127
+ operations:
128
+ - name: download
129
+ object: *bucket0
130
+ arguments:
131
+ id: { $oid: "000000000000000000000002" }
132
+ expectResult: { $$matchesHexBytes: "" }
133
+ - description: "download when there is one chunk"
134
+ operations:
135
+ - name: download
136
+ object: *bucket0
137
+ arguments:
138
+ id: { $oid: "000000000000000000000003" }
139
+ expectResult: { $$matchesHexBytes: "1122" }
140
+ - description: "download when there are two chunks"
141
+ operations:
142
+ - name: download
143
+ object: *bucket0
144
+ arguments:
145
+ id: { $oid: "000000000000000000000004" }
146
+ expectResult: { $$matchesHexBytes: "1122334455667788" }
147
+ - description: "download when there are three chunks"
148
+ operations:
149
+ - name: download
150
+ object: *bucket0
151
+ arguments:
152
+ id: { $oid: "000000000000000000000005" }
153
+ expectResult: { $$matchesHexBytes: "112233445566778899aa" }
154
+ - description: "download when files entry does not exist"
155
+ operations:
156
+ - name: download
157
+ object: *bucket0
158
+ arguments:
159
+ id: { $oid: "000000000000000000000000" }
160
+ expectError: { isError: true } # FileNotFound
161
+ - description: "download when an intermediate chunk is missing"
162
+ operations:
163
+ - name: deleteOne
164
+ object: *bucket0_chunks_collection
165
+ arguments:
166
+ filter:
167
+ files_id: { $oid: "000000000000000000000005" }
168
+ n: 1
169
+ expectResult:
170
+ deletedCount: 1
171
+ - name: download
172
+ object: *bucket0
173
+ arguments:
174
+ id: { $oid: "000000000000000000000005" }
175
+ expectError: { isError: true } # ChunkIsMissing
176
+ - description: "download when final chunk is missing"
177
+ operations:
178
+ - name: deleteOne
179
+ object: *bucket0_chunks_collection
180
+ arguments:
181
+ filter:
182
+ files_id: { $oid: "000000000000000000000005" }
183
+ n: 2
184
+ expectResult:
185
+ deletedCount: 1
186
+ - name: download
187
+ object: *bucket0
188
+ arguments:
189
+ id: { $oid: "000000000000000000000005" }
190
+ expectError: { isError: true } # ChunkIsMissing
191
+ - description: "download when an intermediate chunk is the wrong size"
192
+ operations:
193
+ - name: bulkWrite
194
+ object: *bucket0_chunks_collection
195
+ arguments:
196
+ requests:
197
+ - updateOne:
198
+ filter:
199
+ files_id: { $oid: "000000000000000000000005" }
200
+ n: 1
201
+ update:
202
+ $set: { data: { "$binary": { "base64": "VWZ3", "subType": "00" } } } # hex: 556677
203
+ - updateOne:
204
+ filter:
205
+ files_id: { $oid: "000000000000000000000005" }
206
+ n: 2
207
+ update:
208
+ $set: { data: { "$binary": { "base64": "iJmq", "subType": "00" } } } # hex: 8899aa
209
+ expectResult:
210
+ matchedCount: 2
211
+ modifiedCount: 2
212
+ - name: download
213
+ object: *bucket0
214
+ arguments:
215
+ id: { $oid: "000000000000000000000005" }
216
+ expectError: { isError: true } # ChunkIsWrongSize
217
+ - description: "download when final chunk is the wrong size"
218
+ operations:
219
+ - name: updateOne
220
+ object: *bucket0_chunks_collection
221
+ arguments:
222
+ filter:
223
+ files_id: { $oid: "000000000000000000000005" }
224
+ n: 2
225
+ update:
226
+ $set: { data: { "$binary": { "base64": "mQ==", "subType": "00" } } } # hex: 99
227
+ expectResult:
228
+ matchedCount: 1
229
+ modifiedCount: 1
230
+ - name: download
231
+ object: *bucket0
232
+ arguments:
233
+ id: { $oid: "000000000000000000000005" }
234
+ expectError: { isError: true } # ChunkIsWrongSize
235
+ - description: "download legacy file with no name"
236
+ operations:
237
+ - name: download
238
+ object: *bucket0
239
+ arguments:
240
+ id: { $oid: "000000000000000000000006" }
241
+ expectResult: { $$matchesHexBytes: "1122" }
@@ -0,0 +1,159 @@
1
+ description: "gridfs-downloadByName"
2
+
3
+ schemaVersion: "1.0"
4
+
5
+ createEntities:
6
+ - client:
7
+ id: &client0 client0
8
+ - database:
9
+ id: &database0 database0
10
+ client: *client0
11
+ databaseName: &database0Name gridfs-tests
12
+ - bucket:
13
+ id: &bucket0 bucket0
14
+ database: *database0
15
+ - collection:
16
+ id: &bucket0_files_collection bucket0_files_collection
17
+ database: *database0
18
+ collectionName: &bucket0_files_collectionName fs.files
19
+ - collection:
20
+ id: &bucket0_chunks_collection bucket0_chunks_collection
21
+ database: *database0
22
+ collectionName: &bucket0_chunks_collectionName fs.chunks
23
+
24
+ initialData:
25
+ - collectionName: *bucket0_files_collectionName
26
+ databaseName: *database0Name
27
+ documents:
28
+ - _id: { $oid: "000000000000000000000001" }
29
+ length: 1
30
+ chunkSize: 4
31
+ uploadDate: { $date: "1970-01-01T00:00:00.000Z" }
32
+ md5: "47ed733b8d10be225eceba344d533586"
33
+ filename: "abc"
34
+ contentType: "application/octet-stream"
35
+ aliases: []
36
+ metadata: {}
37
+ - _id: { $oid: "000000000000000000000002" }
38
+ length: 1
39
+ chunkSize: 4
40
+ uploadDate: { $date: "1970-01-02T00:00:00.000Z" }
41
+ md5: "b15835f133ff2e27c7cb28117bfae8f4"
42
+ filename: "abc"
43
+ contentType: "application/octet-stream"
44
+ aliases: []
45
+ metadata: {}
46
+ - _id: { $oid: "000000000000000000000003" }
47
+ length: 1
48
+ chunkSize: 4
49
+ uploadDate: { $date: "1970-01-03T00:00:00.000Z" }
50
+ md5: "eccbc87e4b5ce2fe28308fd9f2a7baf3"
51
+ filename: "abc"
52
+ contentType: "application/octet-stream"
53
+ aliases: []
54
+ metadata: {}
55
+ - _id: { $oid: "000000000000000000000004" }
56
+ length: 1
57
+ chunkSize: 4
58
+ uploadDate: { $date: "1970-01-04T00:00:00.000Z" }
59
+ md5: "f623e75af30e62bbd73d6df5b50bb7b5"
60
+ filename: "abc"
61
+ contentType: "application/octet-stream"
62
+ aliases: []
63
+ metadata: {}
64
+ - _id: { $oid: "000000000000000000000005" }
65
+ length: 1
66
+ chunkSize: 4
67
+ uploadDate: { $date: "1970-01-05T00:00:00.000Z" }
68
+ md5: "4c614360da93c0a041b22e537de151eb"
69
+ filename: "abc"
70
+ contentType: "application/octet-stream"
71
+ aliases: []
72
+ metadata: {}
73
+ - collectionName: *bucket0_chunks_collectionName
74
+ databaseName: *database0Name
75
+ documents:
76
+ - _id: { $oid: "000000000000000000000001" }
77
+ files_id: { $oid: "000000000000000000000001" }
78
+ n: 0
79
+ data: { "$binary": { "base64": "EQ==", "subType": "00" } } # hex: 11
80
+ - _id: { $oid: "000000000000000000000002" }
81
+ files_id: { $oid: "000000000000000000000002" }
82
+ n: 0
83
+ data: { "$binary": { "base64": "Ig==", "subType": "00" } } # hex: 22
84
+ - _id: { $oid: "000000000000000000000003" }
85
+ files_id: { $oid: "000000000000000000000003" }
86
+ n: 0
87
+ data: { "$binary": { "base64": "Mw==", "subType": "00" } } # hex: 33
88
+ - _id: { $oid: "000000000000000000000004" }
89
+ files_id: { $oid: "000000000000000000000004" }
90
+ n: 0
91
+ data: { "$binary": { "base64": "RA==", "subType": "00" } } # hex: 44
92
+ - _id: { $oid: "000000000000000000000005" }
93
+ files_id: { $oid: "000000000000000000000005" }
94
+ n: 0
95
+ data: { "$binary": { "base64": "VQ==", "subType": "00" } } # hex: 55
96
+
97
+ tests:
98
+ - description: "downloadByName defaults to latest revision (-1)"
99
+ operations:
100
+ - name: downloadByName
101
+ object: *bucket0
102
+ arguments:
103
+ filename: "abc"
104
+ expectResult: { $$matchesHexBytes: "55" }
105
+ - description: "downloadByName when revision is 0"
106
+ operations:
107
+ - name: downloadByName
108
+ object: *bucket0
109
+ arguments:
110
+ filename: "abc"
111
+ revision: 0
112
+ expectResult: { $$matchesHexBytes: "11" }
113
+ - description: "downloadByName when revision is 1"
114
+ operations:
115
+ - name: downloadByName
116
+ object: *bucket0
117
+ arguments:
118
+ filename: "abc"
119
+ revision: 1
120
+ expectResult: { $$matchesHexBytes: "22" }
121
+ - description: "downloadByName when revision is 2"
122
+ operations:
123
+ - name: downloadByName
124
+ object: *bucket0
125
+ arguments:
126
+ filename: "abc"
127
+ revision: 2
128
+ expectResult: { $$matchesHexBytes: "33" }
129
+ - description: "downloadByName when revision is -2"
130
+ operations:
131
+ - name: downloadByName
132
+ object: *bucket0
133
+ arguments:
134
+ filename: "abc"
135
+ revision: -2
136
+ expectResult: { $$matchesHexBytes: "44" }
137
+ - description: "downloadByName when revision is -1"
138
+ operations:
139
+ - name: downloadByName
140
+ object: *bucket0
141
+ arguments:
142
+ filename: "abc"
143
+ revision: -1
144
+ expectResult: { $$matchesHexBytes: "55" }
145
+ - description: "downloadByName when files entry does not exist"
146
+ operations:
147
+ - name: downloadByName
148
+ object: *bucket0
149
+ arguments:
150
+ filename: "xyz"
151
+ expectError: { isError: true } # FileNotFound
152
+ - description: "downloadByName when revision does not exist"
153
+ operations:
154
+ - name: downloadByName
155
+ object: *bucket0
156
+ arguments:
157
+ filename: "abc"
158
+ revision: 999
159
+ expectError: { isError: true } # RevisionNotFound
@@ -0,0 +1,92 @@
1
+ description: "gridfs-upload-disableMD5"
2
+
3
+ schemaVersion: "1.0"
4
+
5
+ createEntities:
6
+ - client:
7
+ id: &client0 client0
8
+ - database:
9
+ id: &database0 database0
10
+ client: *client0
11
+ databaseName: &database0Name gridfs-tests
12
+ - bucket:
13
+ id: &bucket0 bucket0
14
+ database: *database0
15
+ - collection:
16
+ id: &bucket0_files_collection bucket0_files_collection
17
+ database: *database0
18
+ collectionName: &bucket0_files_collectionName fs.files
19
+ - collection:
20
+ id: &bucket0_chunks_collection bucket0_chunks_collection
21
+ database: *database0
22
+ collectionName: &bucket0_chunks_collectionName fs.chunks
23
+
24
+ initialData:
25
+ - collectionName: *bucket0_files_collectionName
26
+ databaseName: *database0Name
27
+ documents: []
28
+ - collectionName: *bucket0_chunks_collectionName
29
+ databaseName: *database0Name
30
+ documents: []
31
+
32
+ # Note: these tests utilize the transitional "disableMD5" option. Drivers that
33
+ # do not support the option should skip this file.
34
+ tests:
35
+ - description: "upload when length is 0 sans MD5"
36
+ operations:
37
+ - name: upload
38
+ object: *bucket0
39
+ arguments:
40
+ filename: "filename"
41
+ source: { $$hexBytes: "" }
42
+ chunkSizeBytes: 4
43
+ disableMD5: true
44
+ expectResult: { $$type: objectId }
45
+ saveResultAsEntity: &uploadedObjectId uploadedObjectId
46
+ - name: find
47
+ object: *bucket0_files_collection
48
+ arguments:
49
+ filter: {}
50
+ expectResult:
51
+ - _id: { $$matchesEntity: *uploadedObjectId }
52
+ length: 0
53
+ chunkSize: 4
54
+ uploadDate: { $$type: date }
55
+ md5: { $$exists: false }
56
+ filename: filename
57
+ - name: find
58
+ object: *bucket0_chunks_collection
59
+ arguments:
60
+ filter: {}
61
+ expectResult: []
62
+ - description: "upload when length is 1 sans MD5"
63
+ operations:
64
+ - name: upload
65
+ object: *bucket0
66
+ arguments:
67
+ filename: "filename"
68
+ source: { $$hexBytes: "11" }
69
+ chunkSizeBytes: 4
70
+ disableMD5: true
71
+ expectResult: { $$type: objectId }
72
+ saveResultAsEntity: *uploadedObjectId
73
+ - name: find
74
+ object: *bucket0_files_collection
75
+ arguments:
76
+ filter: {}
77
+ expectResult:
78
+ - _id: { $$matchesEntity: *uploadedObjectId }
79
+ length: 1
80
+ chunkSize: 4
81
+ uploadDate: { $$type: date }
82
+ md5: { $$exists: false }
83
+ filename: filename
84
+ - name: find
85
+ object: *bucket0_chunks_collection
86
+ arguments:
87
+ filter: {}
88
+ expectResult:
89
+ - _id: { $$type: objectId }
90
+ files_id: { $$matchesEntity: *uploadedObjectId }
91
+ n: 0
92
+ data: { $binary: { base64: "EQ==", subType: "00" } } # hex 11