1{
2 "description": "gridfs-download",
3 "schemaVersion": "1.0",
4 "createEntities": [
5 {
6 "client": {
7 "id": "client0"
8 }
9 },
10 {
11 "database": {
12 "id": "database0",
13 "client": "client0",
14 "databaseName": "gridfs-tests"
15 }
16 },
17 {
18 "bucket": {
19 "id": "bucket0",
20 "database": "database0"
21 }
22 },
23 {
24 "collection": {
25 "id": "bucket0_files_collection",
26 "database": "database0",
27 "collectionName": "fs.files"
28 }
29 },
30 {
31 "collection": {
32 "id": "bucket0_chunks_collection",
33 "database": "database0",
34 "collectionName": "fs.chunks"
35 }
36 }
37 ],
38 "initialData": [
39 {
40 "collectionName": "fs.files",
41 "databaseName": "gridfs-tests",
42 "documents": [
43 {
44 "_id": {
45 "$oid": "000000000000000000000001"
46 },
47 "length": 0,
48 "chunkSize": 4,
49 "uploadDate": {
50 "$date": "1970-01-01T00:00:00.000Z"
51 },
52 "md5": "d41d8cd98f00b204e9800998ecf8427e",
53 "filename": "length-0",
54 "contentType": "application/octet-stream",
55 "aliases": [],
56 "metadata": {}
57 },
58 {
59 "_id": {
60 "$oid": "000000000000000000000002"
61 },
62 "length": 0,
63 "chunkSize": 4,
64 "uploadDate": {
65 "$date": "1970-01-01T00:00:00.000Z"
66 },
67 "md5": "d41d8cd98f00b204e9800998ecf8427e",
68 "filename": "length-0-with-empty-chunk",
69 "contentType": "application/octet-stream",
70 "aliases": [],
71 "metadata": {}
72 },
73 {
74 "_id": {
75 "$oid": "000000000000000000000003"
76 },
77 "length": 2,
78 "chunkSize": 4,
79 "uploadDate": {
80 "$date": "1970-01-01T00:00:00.000Z"
81 },
82 "md5": "c700ed4fdb1d27055aa3faa2c2432283",
83 "filename": "length-2",
84 "contentType": "application/octet-stream",
85 "aliases": [],
86 "metadata": {}
87 },
88 {
89 "_id": {
90 "$oid": "000000000000000000000004"
91 },
92 "length": 8,
93 "chunkSize": 4,
94 "uploadDate": {
95 "$date": "1970-01-01T00:00:00.000Z"
96 },
97 "md5": "dd254cdc958e53abaa67da9f797125f5",
98 "filename": "length-8",
99 "contentType": "application/octet-stream",
100 "aliases": [],
101 "metadata": {}
102 },
103 {
104 "_id": {
105 "$oid": "000000000000000000000005"
106 },
107 "length": 10,
108 "chunkSize": 4,
109 "uploadDate": {
110 "$date": "1970-01-01T00:00:00.000Z"
111 },
112 "md5": "57d83cd477bfb1ccd975ab33d827a92b",
113 "filename": "length-10",
114 "contentType": "application/octet-stream",
115 "aliases": [],
116 "metadata": {}
117 },
118 {
119 "_id": {
120 "$oid": "000000000000000000000006"
121 },
122 "length": 2,
123 "chunkSize": 4,
124 "uploadDate": {
125 "$date": "1970-01-01T00:00:00.000Z"
126 },
127 "md5": "c700ed4fdb1d27055aa3faa2c2432283",
128 "contentType": "application/octet-stream",
129 "aliases": [],
130 "metadata": {}
131 }
132 ]
133 },
134 {
135 "collectionName": "fs.chunks",
136 "databaseName": "gridfs-tests",
137 "documents": [
138 {
139 "_id": {
140 "$oid": "000000000000000000000001"
141 },
142 "files_id": {
143 "$oid": "000000000000000000000002"
144 },
145 "n": 0,
146 "data": {
147 "$binary": {
148 "base64": "",
149 "subType": "00"
150 }
151 }
152 },
153 {
154 "_id": {
155 "$oid": "000000000000000000000002"
156 },
157 "files_id": {
158 "$oid": "000000000000000000000003"
159 },
160 "n": 0,
161 "data": {
162 "$binary": {
163 "base64": "ESI=",
164 "subType": "00"
165 }
166 }
167 },
168 {
169 "_id": {
170 "$oid": "000000000000000000000003"
171 },
172 "files_id": {
173 "$oid": "000000000000000000000004"
174 },
175 "n": 0,
176 "data": {
177 "$binary": {
178 "base64": "ESIzRA==",
179 "subType": "00"
180 }
181 }
182 },
183 {
184 "_id": {
185 "$oid": "000000000000000000000004"
186 },
187 "files_id": {
188 "$oid": "000000000000000000000004"
189 },
190 "n": 1,
191 "data": {
192 "$binary": {
193 "base64": "VWZ3iA==",
194 "subType": "00"
195 }
196 }
197 },
198 {
199 "_id": {
200 "$oid": "000000000000000000000005"
201 },
202 "files_id": {
203 "$oid": "000000000000000000000005"
204 },
205 "n": 0,
206 "data": {
207 "$binary": {
208 "base64": "ESIzRA==",
209 "subType": "00"
210 }
211 }
212 },
213 {
214 "_id": {
215 "$oid": "000000000000000000000006"
216 },
217 "files_id": {
218 "$oid": "000000000000000000000005"
219 },
220 "n": 1,
221 "data": {
222 "$binary": {
223 "base64": "VWZ3iA==",
224 "subType": "00"
225 }
226 }
227 },
228 {
229 "_id": {
230 "$oid": "000000000000000000000007"
231 },
232 "files_id": {
233 "$oid": "000000000000000000000005"
234 },
235 "n": 2,
236 "data": {
237 "$binary": {
238 "base64": "mao=",
239 "subType": "00"
240 }
241 }
242 },
243 {
244 "_id": {
245 "$oid": "000000000000000000000008"
246 },
247 "files_id": {
248 "$oid": "000000000000000000000006"
249 },
250 "n": 0,
251 "data": {
252 "$binary": {
253 "base64": "ESI=",
254 "subType": "00"
255 }
256 }
257 }
258 ]
259 }
260 ],
261 "tests": [
262 {
263 "description": "download when length is zero",
264 "operations": [
265 {
266 "name": "download",
267 "object": "bucket0",
268 "arguments": {
269 "id": {
270 "$oid": "000000000000000000000001"
271 }
272 },
273 "expectResult": {
274 "$$matchesHexBytes": ""
275 }
276 }
277 ]
278 },
279 {
280 "description": "download when length is zero and there is one empty chunk",
281 "operations": [
282 {
283 "name": "download",
284 "object": "bucket0",
285 "arguments": {
286 "id": {
287 "$oid": "000000000000000000000002"
288 }
289 },
290 "expectResult": {
291 "$$matchesHexBytes": ""
292 }
293 }
294 ]
295 },
296 {
297 "description": "download when there is one chunk",
298 "operations": [
299 {
300 "name": "download",
301 "object": "bucket0",
302 "arguments": {
303 "id": {
304 "$oid": "000000000000000000000003"
305 }
306 },
307 "expectResult": {
308 "$$matchesHexBytes": "1122"
309 }
310 }
311 ]
312 },
313 {
314 "description": "download when there are two chunks",
315 "operations": [
316 {
317 "name": "download",
318 "object": "bucket0",
319 "arguments": {
320 "id": {
321 "$oid": "000000000000000000000004"
322 }
323 },
324 "expectResult": {
325 "$$matchesHexBytes": "1122334455667788"
326 }
327 }
328 ]
329 },
330 {
331 "description": "download when there are three chunks",
332 "operations": [
333 {
334 "name": "download",
335 "object": "bucket0",
336 "arguments": {
337 "id": {
338 "$oid": "000000000000000000000005"
339 }
340 },
341 "expectResult": {
342 "$$matchesHexBytes": "112233445566778899aa"
343 }
344 }
345 ]
346 },
347 {
348 "description": "download when files entry does not exist",
349 "operations": [
350 {
351 "name": "download",
352 "object": "bucket0",
353 "arguments": {
354 "id": {
355 "$oid": "000000000000000000000000"
356 }
357 },
358 "expectError": {
359 "isError": true
360 }
361 }
362 ]
363 },
364 {
365 "description": "download when an intermediate chunk is missing",
366 "operations": [
367 {
368 "name": "deleteOne",
369 "object": "bucket0_chunks_collection",
370 "arguments": {
371 "filter": {
372 "files_id": {
373 "$oid": "000000000000000000000005"
374 },
375 "n": 1
376 }
377 },
378 "expectResult": {
379 "deletedCount": 1
380 }
381 },
382 {
383 "name": "download",
384 "object": "bucket0",
385 "arguments": {
386 "id": {
387 "$oid": "000000000000000000000005"
388 }
389 },
390 "expectError": {
391 "isError": true
392 }
393 }
394 ]
395 },
396 {
397 "description": "download when final chunk is missing",
398 "operations": [
399 {
400 "name": "deleteOne",
401 "object": "bucket0_chunks_collection",
402 "arguments": {
403 "filter": {
404 "files_id": {
405 "$oid": "000000000000000000000005"
406 },
407 "n": 2
408 }
409 },
410 "expectResult": {
411 "deletedCount": 1
412 }
413 },
414 {
415 "name": "download",
416 "object": "bucket0",
417 "arguments": {
418 "id": {
419 "$oid": "000000000000000000000005"
420 }
421 },
422 "expectError": {
423 "isError": true
424 }
425 }
426 ]
427 },
428 {
429 "description": "download when an intermediate chunk is the wrong size",
430 "operations": [
431 {
432 "name": "bulkWrite",
433 "object": "bucket0_chunks_collection",
434 "arguments": {
435 "requests": [
436 {
437 "updateOne": {
438 "filter": {
439 "files_id": {
440 "$oid": "000000000000000000000005"
441 },
442 "n": 1
443 },
444 "update": {
445 "$set": {
446 "data": {
447 "$binary": {
448 "base64": "VWZ3",
449 "subType": "00"
450 }
451 }
452 }
453 }
454 }
455 },
456 {
457 "updateOne": {
458 "filter": {
459 "files_id": {
460 "$oid": "000000000000000000000005"
461 },
462 "n": 2
463 },
464 "update": {
465 "$set": {
466 "data": {
467 "$binary": {
468 "base64": "iJmq",
469 "subType": "00"
470 }
471 }
472 }
473 }
474 }
475 }
476 ]
477 },
478 "expectResult": {
479 "matchedCount": 2,
480 "modifiedCount": 2
481 }
482 },
483 {
484 "name": "download",
485 "object": "bucket0",
486 "arguments": {
487 "id": {
488 "$oid": "000000000000000000000005"
489 }
490 },
491 "expectError": {
492 "isError": true
493 }
494 }
495 ]
496 },
497 {
498 "description": "download when final chunk is the wrong size",
499 "operations": [
500 {
501 "name": "updateOne",
502 "object": "bucket0_chunks_collection",
503 "arguments": {
504 "filter": {
505 "files_id": {
506 "$oid": "000000000000000000000005"
507 },
508 "n": 2
509 },
510 "update": {
511 "$set": {
512 "data": {
513 "$binary": {
514 "base64": "mQ==",
515 "subType": "00"
516 }
517 }
518 }
519 }
520 },
521 "expectResult": {
522 "matchedCount": 1,
523 "modifiedCount": 1
524 }
525 },
526 {
527 "name": "download",
528 "object": "bucket0",
529 "arguments": {
530 "id": {
531 "$oid": "000000000000000000000005"
532 }
533 },
534 "expectError": {
535 "isError": true
536 }
537 }
538 ]
539 },
540 {
541 "description": "download legacy file with no name",
542 "operations": [
543 {
544 "name": "download",
545 "object": "bucket0",
546 "arguments": {
547 "id": {
548 "$oid": "000000000000000000000006"
549 }
550 },
551 "expectResult": {
552 "$$matchesHexBytes": "1122"
553 }
554 }
555 ]
556 }
557 ]
558}
View as plain text