File: download.yml

package info (click to toggle)
ruby-mongo 2.21.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 14,764 kB
  • sloc: ruby: 108,806; makefile: 5; sh: 2
file content (241 lines) | stat: -rw-r--r-- 8,679 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
description: "gridfs-download"

schemaVersion: "1.0"

createEntities:
  - client:
      id: &client0 client0
  - database:
      id: &database0 database0
      client: *client0
      databaseName: &database0Name gridfs-tests
  - bucket:
      id: &bucket0 bucket0
      database: *database0
  - collection:
      id: &bucket0_files_collection bucket0_files_collection
      database: *database0
      collectionName: &bucket0_files_collectionName fs.files
  - collection:
      id: &bucket0_chunks_collection bucket0_chunks_collection
      database: *database0
      collectionName: &bucket0_chunks_collectionName fs.chunks

initialData:
  - collectionName: *bucket0_files_collectionName
    databaseName: *database0Name
    documents:
      - _id: { "$oid": "000000000000000000000001" }
        length: 0
        chunkSize: 4
        uploadDate: { "$date": "1970-01-01T00:00:00.000Z" }
        md5: "d41d8cd98f00b204e9800998ecf8427e"
        filename: "length-0"
        contentType: "application/octet-stream"
        aliases: []
        metadata: {}
      - _id: { "$oid": "000000000000000000000002" }
        length: 0
        chunkSize: 4
        uploadDate: { "$date": "1970-01-01T00:00:00.000Z" }
        md5: "d41d8cd98f00b204e9800998ecf8427e"
        filename: "length-0-with-empty-chunk"
        contentType: "application/octet-stream"
        aliases: []
        metadata: {}
      - _id: { "$oid": "000000000000000000000003" }
        length: 2
        chunkSize: 4
        uploadDate: { "$date": "1970-01-01T00:00:00.000Z" }
        md5: "c700ed4fdb1d27055aa3faa2c2432283"
        filename: "length-2"
        contentType: "application/octet-stream"
        aliases: []
        metadata: {}
      - _id: { "$oid": "000000000000000000000004" }
        length: 8
        chunkSize: 4
        uploadDate: { "$date": "1970-01-01T00:00:00.000Z" }
        md5: "dd254cdc958e53abaa67da9f797125f5"
        filename: "length-8"
        contentType: "application/octet-stream"
        aliases: []
        metadata: {}
      - _id: { "$oid": "000000000000000000000005" }
        length: 10
        chunkSize: 4
        uploadDate: { "$date": "1970-01-01T00:00:00.000Z" }
        md5: "57d83cd477bfb1ccd975ab33d827a92b"
        filename: "length-10"
        contentType: "application/octet-stream"
        aliases: []
        metadata: {}
      - _id: { "$oid": "000000000000000000000006" }
        length: 2
        chunkSize: 4
        uploadDate: { "$date": "1970-01-01T00:00:00.000Z" }
        md5: "c700ed4fdb1d27055aa3faa2c2432283"
        # filename is intentionally omitted
        contentType: "application/octet-stream"
        aliases: []
        metadata: {}
  - collectionName: *bucket0_chunks_collectionName
    databaseName: *database0Name
    documents:
      - _id: { "$oid": "000000000000000000000001" }
        files_id: { "$oid": "000000000000000000000002" }
        n: 0
        data: { "$binary": { "base64": "", "subType": "00" } }
      - _id: { "$oid": "000000000000000000000002" }
        files_id: { "$oid": "000000000000000000000003" }
        n: 0
        data: { "$binary": { "base64": "ESI=", "subType": "00" } } # hex: 1122
      - _id: { "$oid": "000000000000000000000003" }
        files_id: { "$oid": "000000000000000000000004" }
        n: 0
        data: { "$binary": { "base64": "ESIzRA==", "subType": "00" } }  # hex: 11223344
      - _id: { "$oid": "000000000000000000000004" }
        files_id: { "$oid": "000000000000000000000004" }
        n: 1
        data: { "$binary": { "base64": "VWZ3iA==", "subType": "00" } } # hex: 55667788
      - _id: { "$oid": "000000000000000000000005" }
        files_id: { "$oid": "000000000000000000000005" }
        n: 0
        data: { "$binary": { "base64": "ESIzRA==", "subType": "00" } }  # hex: 11223344
      - _id: { "$oid": "000000000000000000000006" }
        files_id: { "$oid": "000000000000000000000005" }
        n: 1
        data: { "$binary": { "base64": "VWZ3iA==", "subType": "00" } } # hex: 55667788
      - _id: { "$oid": "000000000000000000000007" }
        files_id: { "$oid": "000000000000000000000005" }
        n: 2
        data: { "$binary" : { "base64": "mao=", "subType" : "00" } } # hex: 99aa
      - _id: { "$oid": "000000000000000000000008" }
        files_id: { "$oid": "000000000000000000000006" }
        n: 0
        data: { "$binary": { "base64": "ESI=", "subType": "00" } } # hex: 1122

tests:
  - description: "download when length is zero"
    operations:
      - name: download
        object: *bucket0
        arguments:
          id: { $oid: "000000000000000000000001" }
        expectResult: { $$matchesHexBytes: "" }
  - description: "download when length is zero and there is one empty chunk"
    operations:
      - name: download
        object: *bucket0
        arguments:
          id: { $oid: "000000000000000000000002" }
        expectResult: { $$matchesHexBytes: "" }
  - description: "download when there is one chunk"
    operations:
      - name: download
        object: *bucket0
        arguments:
          id: { $oid: "000000000000000000000003" }
        expectResult: { $$matchesHexBytes: "1122" }
  - description: "download when there are two chunks"
    operations:
      - name: download
        object: *bucket0
        arguments:
          id: { $oid: "000000000000000000000004" }
        expectResult: { $$matchesHexBytes: "1122334455667788" }
  - description: "download when there are three chunks"
    operations:
      - name: download
        object: *bucket0
        arguments:
          id: { $oid: "000000000000000000000005" }
        expectResult: { $$matchesHexBytes: "112233445566778899aa" }
  - description: "download when files entry does not exist"
    operations:
      - name: download
        object: *bucket0
        arguments:
          id: { $oid: "000000000000000000000000" }
        expectError: { isError: true } # FileNotFound
  - description: "download when an intermediate chunk is missing"
    operations:
      - name: deleteOne
        object: *bucket0_chunks_collection
        arguments:
          filter:
            files_id: { $oid: "000000000000000000000005" }
            n: 1
        expectResult:
          deletedCount: 1
      - name: download
        object: *bucket0
        arguments:
          id: { $oid: "000000000000000000000005" }
        expectError: { isError: true } # ChunkIsMissing
  - description: "download when final chunk is missing"
    operations:
      - name: deleteOne
        object: *bucket0_chunks_collection
        arguments:
          filter:
            files_id: { $oid: "000000000000000000000005" }
            n: 2
        expectResult:
          deletedCount: 1
      - name: download
        object: *bucket0
        arguments:
          id: { $oid: "000000000000000000000005" }
        expectError: { isError: true } # ChunkIsMissing
  - description: "download when an intermediate chunk is the wrong size"
    operations:
      - name: bulkWrite
        object: *bucket0_chunks_collection
        arguments:
          requests:
            - updateOne:
                filter:
                  files_id: { $oid: "000000000000000000000005" }
                  n: 1
                update:
                  $set: { data: { "$binary": { "base64": "VWZ3", "subType": "00" } } } # hex: 556677
            - updateOne:
                filter:
                  files_id: { $oid: "000000000000000000000005" }
                  n: 2
                update:
                  $set: { data: { "$binary": { "base64": "iJmq", "subType": "00" } } } # hex: 8899aa
        expectResult:
          matchedCount: 2
          modifiedCount: 2
      - name: download
        object: *bucket0
        arguments:
          id: { $oid: "000000000000000000000005" }
        expectError: { isError: true } # ChunkIsWrongSize
  - description: "download when final chunk is the wrong size"
    operations:
      - name: updateOne
        object: *bucket0_chunks_collection
        arguments:
          filter:
            files_id: { $oid: "000000000000000000000005" }
            n: 2
          update:
            $set: { data: { "$binary": { "base64": "mQ==", "subType": "00" } } } # hex: 99
        expectResult:
          matchedCount: 1
          modifiedCount: 1
      - name: download
        object: *bucket0
        arguments:
          id: { $oid: "000000000000000000000005" }
        expectError: { isError: true } # ChunkIsWrongSize
  - description: "download legacy file with no name"
    operations:
      - name: download
        object: *bucket0
        arguments:
          id: { $oid: "000000000000000000000006" }
        expectResult: { $$matchesHexBytes: "1122" }