forked from haiwen/seafile-docker
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfileop-cases.json
More file actions
475 lines (475 loc) · 11.9 KB
/
Copy pathfileop-cases.json
File metadata and controls
475 lines (475 loc) · 11.9 KB
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
{
"version": 1,
"comment": "Executable form of docs/fileop-lifecycle.md. Loaded by the C suite (tests/cf-fileop) and the Go suite (fileserver/cf_fileop_test.go); both MUST agree on every case. Keep this file free of anything that needs a database or a running server -- it exists so the vocabulary and the path rules can be checked without one.",
"normalize": {
"comment": "dir + name -> normalized object path. Rule 5 of the spec is load-bearing: no Unicode normalization, no case folding. A name of null means `dir` is itself the object (mkdir, revert-dir, update-dir).",
"cases": [
{
"name": "plain join",
"dir": "/a",
"entry": "b.txt",
"expect": "/a/b.txt"
},
{
"name": "root parent",
"dir": "/",
"entry": "b.txt",
"expect": "/b.txt"
},
{
"name": "empty dir is root",
"dir": "",
"entry": "b.txt",
"expect": "/b.txt"
},
{
"name": "null dir is root",
"dir": null,
"entry": "b.txt",
"expect": "/b.txt"
},
{
"name": "missing leading slash",
"dir": "a/b",
"entry": "c.txt",
"expect": "/a/b/c.txt"
},
{
"name": "trailing slash dropped",
"dir": "/a/b/",
"entry": "c.txt",
"expect": "/a/b/c.txt"
},
{
"name": "doubled separators folded",
"dir": "//a//b",
"entry": "c.txt",
"expect": "/a/b/c.txt"
},
{
"name": "many separators folded",
"dir": "/a////b",
"entry": "c.txt",
"expect": "/a/b/c.txt"
},
{
"name": "dir itself is the object",
"dir": "/a/b",
"entry": null,
"expect": "/a/b"
},
{
"name": "root itself is the object",
"dir": "/",
"entry": null,
"expect": "/"
},
{
"name": "empty is root object",
"dir": "",
"entry": null,
"expect": "/"
},
{
"name": "root stays single slash",
"dir": "///",
"entry": null,
"expect": "/"
},
{
"name": "entry carrying a subpath",
"dir": "/a",
"entry": "b/c.txt",
"expect": "/a/b/c.txt"
},
{
"name": "entry with leading slash",
"dir": "/a",
"entry": "/b.txt",
"expect": "/a/b.txt"
},
{
"name": "spaces are significant",
"dir": "/a b",
"entry": "c d.txt",
"expect": "/a b/c d.txt"
},
{
"name": "dot is a normal name",
"dir": "/a",
"entry": ".hidden",
"expect": "/a/.hidden"
},
{
"name": "no case folding",
"dir": "/A",
"entry": "B.TXT",
"expect": "/A/B.TXT"
},
{
"name": "no unicode normalization",
"dir": "/é",
"entry": "x",
"expect": "/é/x"
},
{
"name": "decomposed stays decomposed",
"dir": "/é",
"entry": "x",
"expect": "/é/x"
}
]
},
"operations": {
"comment": "The stable vocabulary. `source` marks the ops that carry src_repo_id/src_path. `pathless` marks the ops with no object path at all -- a lock provider MUST ignore those (see spec section 3). `subject_is_root` marks the ops whose object is the whole library.",
"cases": [
{
"op": "create-file",
"valid": true,
"source": false,
"pathless": false,
"subject_is_root": false
},
{
"op": "update-file",
"valid": true,
"source": false,
"pathless": false,
"subject_is_root": false
},
{
"op": "delete",
"valid": true,
"source": false,
"pathless": false,
"subject_is_root": false
},
{
"op": "mkdir",
"valid": true,
"source": false,
"pathless": false,
"subject_is_root": false
},
{
"op": "rename",
"valid": true,
"source": true,
"pathless": false,
"subject_is_root": false
},
{
"op": "move",
"valid": true,
"source": true,
"pathless": false,
"subject_is_root": false
},
{
"op": "copy",
"valid": true,
"source": true,
"pathless": false,
"subject_is_root": false
},
{
"op": "revert-file",
"valid": true,
"source": false,
"pathless": false,
"subject_is_root": false
},
{
"op": "revert-dir",
"valid": true,
"source": false,
"pathless": false,
"subject_is_root": false
},
{
"op": "revert-repo",
"valid": true,
"source": false,
"pathless": false,
"subject_is_root": true
},
{
"op": "update-dir",
"valid": true,
"source": false,
"pathless": false,
"subject_is_root": false
},
{
"op": "upload-blocks",
"valid": true,
"source": false,
"pathless": true,
"subject_is_root": false
},
{
"op": "sync-update",
"valid": true,
"source": false,
"pathless": false,
"subject_is_root": true
},
{
"op": "",
"valid": false,
"source": false,
"pathless": false,
"subject_is_root": false
},
{
"op": "Create-File",
"valid": false,
"source": false,
"pathless": false,
"subject_is_root": false
},
{
"op": "create_file",
"valid": false,
"source": false,
"pathless": false,
"subject_is_root": false
},
{
"op": "write",
"valid": false,
"source": false,
"pathless": false,
"subject_is_root": false
},
{
"op": "put-file",
"valid": false,
"source": false,
"pathless": false,
"subject_is_root": false
}
]
},
"dispatch": {
"comment": "PREPARE runs providers in registration order and stops at the first refusal. `verdicts` is what each registered provider returns; `expect_allowed` is the outcome and `expect_ran` is how many providers actually ran -- a provider that runs after a refusal is a bug, because the whole point of stopping is that a refused write must not have side effects.",
"cases": [
{
"name": "no providers allows",
"verdicts": [],
"expect_allowed": true,
"expect_ran": 0
},
{
"name": "single allow",
"verdicts": [
"allow"
],
"expect_allowed": true,
"expect_ran": 1
},
{
"name": "single refuse",
"verdicts": [
"refuse"
],
"expect_allowed": false,
"expect_ran": 1
},
{
"name": "all allow",
"verdicts": [
"allow",
"allow"
],
"expect_allowed": true,
"expect_ran": 2
},
{
"name": "first refuses, second skipped",
"verdicts": [
"refuse",
"allow"
],
"expect_allowed": false,
"expect_ran": 1
},
{
"name": "second refuses",
"verdicts": [
"allow",
"refuse"
],
"expect_allowed": false,
"expect_ran": 2
},
{
"name": "refusal stops the rest",
"verdicts": [
"allow",
"refuse",
"allow"
],
"expect_allowed": false,
"expect_ran": 2
},
{
"name": "provider without a prepare hook is skipped",
"verdicts": [
"none",
"refuse"
],
"expect_allowed": false,
"expect_ran": 1
}
]
},
"facts": {
"comment": "Exactly-once accounting, from spec section 8.2. `prepare` is whether PREPARE was reached and allowed; `commit_attempts` counts how many times the underlying commit was attempted (>1 models the concurrent-upload retry loop); `succeeded` is the operation outcome. This encodes the rule that a retry loop must not multiply the fact.",
"cases": [
{
"name": "simple success",
"prepare": "allow",
"commit_attempts": 1,
"succeeded": true,
"expect_committed": 1,
"expect_aborted": 0
},
{
"name": "retry then success",
"prepare": "allow",
"commit_attempts": 3,
"succeeded": true,
"expect_committed": 1,
"expect_aborted": 0
},
{
"name": "commit fails",
"prepare": "allow",
"commit_attempts": 1,
"succeeded": false,
"expect_committed": 0,
"expect_aborted": 1
},
{
"name": "retries then fails",
"prepare": "allow",
"commit_attempts": 3,
"succeeded": false,
"expect_committed": 0,
"expect_aborted": 1
},
{
"name": "refused before any write",
"prepare": "refuse",
"commit_attempts": 0,
"succeeded": false,
"expect_committed": 0,
"expect_aborted": 0
},
{
"name": "no provider, nothing emitted",
"prepare": "inactive",
"commit_attempts": 1,
"succeeded": true,
"expect_committed": 0,
"expect_aborted": 0
}
]
},
"has_component": {
"comment": "Component-wise path matching (cf_path_has_component). The write lifecycle gate's fake provider refuses on a marked path component, so whether phase 2 of that gate passes for the right reason depends on these rules. A substring match would make a refusal cover paths the test never named; an empty component matching everything would make it cover all of them.",
"cases": [
{
"name": "exact basename",
"path": "/box/cf-refuse",
"component": "cf-refuse",
"expect": true
},
{
"name": "directory component",
"path": "/cf-refuse/inside.dat",
"component": "cf-refuse",
"expect": true
},
{
"name": "middle component",
"path": "/a/cf-refuse/b/c.txt",
"component": "cf-refuse",
"expect": true
},
{
"name": "component is the whole path",
"path": "/cf-refuse",
"component": "cf-refuse",
"expect": true
},
{
"name": "trailing slash",
"path": "/cf-refuse/",
"component": "cf-refuse",
"expect": true
},
{
"name": "doubled separators",
"path": "//a//cf-refuse//b",
"component": "cf-refuse",
"expect": true
},
{
"name": "suffix is not a component",
"path": "/box/cf-refuse-not",
"component": "cf-refuse",
"expect": false
},
{
"name": "prefix is not a component",
"path": "/box/not-cf-refuse",
"component": "cf-refuse",
"expect": false
},
{
"name": "substring inside a name",
"path": "/box/xcf-refusex.txt",
"component": "cf-refuse",
"expect": false
},
{
"name": "unrelated path",
"path": "/box/plain.dat",
"component": "cf-refuse",
"expect": false
},
{
"name": "root never matches",
"path": "/",
"component": "cf-refuse",
"expect": false
},
{
"name": "empty component matches nothing",
"path": "/box/cf-refuse",
"component": "",
"expect": false
},
{
"name": "null component matches nothing",
"path": "/box/cf-refuse",
"component": null,
"expect": false
},
{
"name": "null path matches nothing",
"path": null,
"component": "cf-refuse",
"expect": false
},
{
"name": "case is significant",
"path": "/box/CF-REFUSE",
"component": "cf-refuse",
"expect": false
}
]
}
}