@quantcdn/edge-conformance 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,659 @@
1
+ {
2
+ "cases": [
3
+ {
4
+ "id": "rules-function-rule-before-static",
5
+ "description": "A matching function rule answers the request, although a static file exists at the path.",
6
+ "tags": [
7
+ "rules"
8
+ ],
9
+ "op": "serveSite",
10
+ "input": {
11
+ "files": {
12
+ "api/status/index.html": "<p>static status</p>"
13
+ },
14
+ "functions": [
15
+ {
16
+ "uuid": "a1b2c3d4-0001-4000-8000-000000000001",
17
+ "id": "api",
18
+ "type": "function",
19
+ "body": "return new Response(\"from function\", { status: 200, headers: { 'content-type': 'text/plain' } });"
20
+ }
21
+ ],
22
+ "rules": {
23
+ "version": 1,
24
+ "namespace": "conformance",
25
+ "rules": [
26
+ {
27
+ "id": "api",
28
+ "type": "function",
29
+ "urls": [
30
+ "/api/*"
31
+ ],
32
+ "weight": 0,
33
+ "function_uuid": "a1b2c3d4-0001-4000-8000-000000000001"
34
+ }
35
+ ]
36
+ },
37
+ "request": {
38
+ "method": "GET",
39
+ "url": "https://www.example.com/api/status"
40
+ }
41
+ },
42
+ "expect": {
43
+ "status": 200,
44
+ "bodyText": "from function"
45
+ }
46
+ },
47
+ {
48
+ "id": "rules-no-match-serves-static",
49
+ "description": "When no rule matches, the static file is served.",
50
+ "tags": [
51
+ "rules"
52
+ ],
53
+ "op": "serveSite",
54
+ "input": {
55
+ "files": {
56
+ "about/index.html": "<h1>About</h1>"
57
+ },
58
+ "functions": [
59
+ {
60
+ "uuid": "a1b2c3d4-0001-4000-8000-000000000001",
61
+ "id": "api",
62
+ "type": "function",
63
+ "body": "return new Response(\"from function\", { status: 200, headers: { 'content-type': 'text/plain' } });"
64
+ }
65
+ ],
66
+ "rules": {
67
+ "version": 1,
68
+ "namespace": "conformance",
69
+ "rules": [
70
+ {
71
+ "id": "api",
72
+ "type": "function",
73
+ "urls": [
74
+ "/api/*"
75
+ ],
76
+ "weight": 0,
77
+ "function_uuid": "a1b2c3d4-0001-4000-8000-000000000001"
78
+ }
79
+ ]
80
+ },
81
+ "request": {
82
+ "method": "GET",
83
+ "url": "https://www.example.com/about/"
84
+ }
85
+ },
86
+ "expect": {
87
+ "status": 200,
88
+ "bodyText": "<h1>About</h1>"
89
+ }
90
+ },
91
+ {
92
+ "id": "rules-auth-201-continues",
93
+ "description": "An auth function that returns 201 lets the request continue to the static file.",
94
+ "tags": [
95
+ "rules"
96
+ ],
97
+ "op": "serveSite",
98
+ "input": {
99
+ "files": {
100
+ "members/report/index.html": "<h1>Members report</h1>",
101
+ "index.html": "<h1>Home</h1>"
102
+ },
103
+ "functions": [
104
+ {
105
+ "uuid": "a1b2c3d4-0003-4000-8000-000000000003",
106
+ "id": "gate",
107
+ "type": "auth",
108
+ "body": "return new Response('ok', { status: 201 });"
109
+ }
110
+ ],
111
+ "rules": {
112
+ "version": 1,
113
+ "namespace": "conformance",
114
+ "rules": [
115
+ {
116
+ "id": "members",
117
+ "type": "auth",
118
+ "urls": [
119
+ "/members/*"
120
+ ],
121
+ "weight": 0,
122
+ "function_uuid": "a1b2c3d4-0003-4000-8000-000000000003"
123
+ }
124
+ ]
125
+ },
126
+ "request": {
127
+ "method": "GET",
128
+ "url": "https://www.example.com/members/report/"
129
+ }
130
+ },
131
+ "expect": {
132
+ "status": 200,
133
+ "bodyText": "<h1>Members report</h1>"
134
+ }
135
+ },
136
+ {
137
+ "id": "rules-auth-201-adds-its-headers-but-not-content-type",
138
+ "description": "The headers of a 201 auth response are added to the final response, except content-type.",
139
+ "tags": [
140
+ "rules"
141
+ ],
142
+ "op": "serveSite",
143
+ "input": {
144
+ "files": {
145
+ "members/report/index.html": "<h1>Members report</h1>",
146
+ "index.html": "<h1>Home</h1>"
147
+ },
148
+ "functions": [
149
+ {
150
+ "uuid": "a1b2c3d4-0003-4000-8000-000000000003",
151
+ "id": "gate",
152
+ "type": "auth",
153
+ "body": "return new Response('ok', { status: 201, headers: { 'x-member': 'ada', 'content-type': 'text/plain' } });"
154
+ }
155
+ ],
156
+ "rules": {
157
+ "version": 1,
158
+ "namespace": "conformance",
159
+ "rules": [
160
+ {
161
+ "id": "members",
162
+ "type": "auth",
163
+ "urls": [
164
+ "/members/*"
165
+ ],
166
+ "weight": 0,
167
+ "function_uuid": "a1b2c3d4-0003-4000-8000-000000000003"
168
+ }
169
+ ]
170
+ },
171
+ "request": {
172
+ "method": "GET",
173
+ "url": "https://www.example.com/members/report/"
174
+ }
175
+ },
176
+ "expect": {
177
+ "status": 200,
178
+ "headers": {
179
+ "x-member": "ada",
180
+ "content-type": {
181
+ "startsWith": "text/html"
182
+ }
183
+ },
184
+ "bodyText": "<h1>Members report</h1>"
185
+ }
186
+ },
187
+ {
188
+ "id": "rules-auth-201-default-cache-control",
189
+ "description": "When a 201 auth response sets no cache-control, the final response gets private, max-age=0.",
190
+ "tags": [
191
+ "rules"
192
+ ],
193
+ "op": "serveSite",
194
+ "input": {
195
+ "files": {
196
+ "members/report/index.html": "<h1>Members report</h1>",
197
+ "index.html": "<h1>Home</h1>"
198
+ },
199
+ "functions": [
200
+ {
201
+ "uuid": "a1b2c3d4-0003-4000-8000-000000000003",
202
+ "id": "gate",
203
+ "type": "auth",
204
+ "body": "return new Response('ok', { status: 201 });"
205
+ }
206
+ ],
207
+ "rules": {
208
+ "version": 1,
209
+ "namespace": "conformance",
210
+ "rules": [
211
+ {
212
+ "id": "members",
213
+ "type": "auth",
214
+ "urls": [
215
+ "/members/*"
216
+ ],
217
+ "weight": 0,
218
+ "function_uuid": "a1b2c3d4-0003-4000-8000-000000000003"
219
+ }
220
+ ]
221
+ },
222
+ "request": {
223
+ "method": "GET",
224
+ "url": "https://www.example.com/members/report/"
225
+ }
226
+ },
227
+ "expect": {
228
+ "status": 200,
229
+ "headers": {
230
+ "cache-control": "private, max-age=0"
231
+ }
232
+ }
233
+ },
234
+ {
235
+ "id": "rules-auth-201-keeps-its-cache-control",
236
+ "description": "A cache-control on a 201 auth response is kept on the final response.",
237
+ "tags": [
238
+ "rules"
239
+ ],
240
+ "op": "serveSite",
241
+ "input": {
242
+ "files": {
243
+ "members/report/index.html": "<h1>Members report</h1>",
244
+ "index.html": "<h1>Home</h1>"
245
+ },
246
+ "functions": [
247
+ {
248
+ "uuid": "a1b2c3d4-0003-4000-8000-000000000003",
249
+ "id": "gate",
250
+ "type": "auth",
251
+ "body": "return new Response('ok', { status: 201, headers: { 'cache-control': 'private, max-age=30' } });"
252
+ }
253
+ ],
254
+ "rules": {
255
+ "version": 1,
256
+ "namespace": "conformance",
257
+ "rules": [
258
+ {
259
+ "id": "members",
260
+ "type": "auth",
261
+ "urls": [
262
+ "/members/*"
263
+ ],
264
+ "weight": 0,
265
+ "function_uuid": "a1b2c3d4-0003-4000-8000-000000000003"
266
+ }
267
+ ]
268
+ },
269
+ "request": {
270
+ "method": "GET",
271
+ "url": "https://www.example.com/members/report/"
272
+ }
273
+ },
274
+ "expect": {
275
+ "status": 200,
276
+ "headers": {
277
+ "cache-control": "private, max-age=30"
278
+ }
279
+ }
280
+ },
281
+ {
282
+ "id": "rules-auth-denies",
283
+ "description": "An auth function that returns another status ends the request with its response.",
284
+ "tags": [
285
+ "rules"
286
+ ],
287
+ "op": "serveSite",
288
+ "input": {
289
+ "files": {
290
+ "members/report/index.html": "<h1>Members report</h1>",
291
+ "index.html": "<h1>Home</h1>"
292
+ },
293
+ "functions": [
294
+ {
295
+ "uuid": "a1b2c3d4-0003-4000-8000-000000000003",
296
+ "id": "gate",
297
+ "type": "auth",
298
+ "body": "return new Response('Sign in to continue', { status: 401, headers: { 'www-authenticate': 'Basic realm=Members' } });"
299
+ }
300
+ ],
301
+ "rules": {
302
+ "version": 1,
303
+ "namespace": "conformance",
304
+ "rules": [
305
+ {
306
+ "id": "members",
307
+ "type": "auth",
308
+ "urls": [
309
+ "/members/*"
310
+ ],
311
+ "weight": 0,
312
+ "function_uuid": "a1b2c3d4-0003-4000-8000-000000000003"
313
+ }
314
+ ]
315
+ },
316
+ "request": {
317
+ "method": "GET",
318
+ "url": "https://www.example.com/members/report/"
319
+ }
320
+ },
321
+ "expect": {
322
+ "status": 401,
323
+ "headers": {
324
+ "www-authenticate": "Basic realm=Members"
325
+ },
326
+ "bodyText": "Sign in to continue"
327
+ }
328
+ },
329
+ {
330
+ "id": "rules-auth-redirects",
331
+ "description": "An auth function can end the request with a redirect.",
332
+ "tags": [
333
+ "rules"
334
+ ],
335
+ "op": "serveSite",
336
+ "input": {
337
+ "files": {
338
+ "members/report/index.html": "<h1>Members report</h1>",
339
+ "index.html": "<h1>Home</h1>"
340
+ },
341
+ "functions": [
342
+ {
343
+ "uuid": "a1b2c3d4-0003-4000-8000-000000000003",
344
+ "id": "gate",
345
+ "type": "auth",
346
+ "body": "return new Response('', { status: 302, headers: { location: '/login' } });"
347
+ }
348
+ ],
349
+ "rules": {
350
+ "version": 1,
351
+ "namespace": "conformance",
352
+ "rules": [
353
+ {
354
+ "id": "members",
355
+ "type": "auth",
356
+ "urls": [
357
+ "/members/*"
358
+ ],
359
+ "weight": 0,
360
+ "function_uuid": "a1b2c3d4-0003-4000-8000-000000000003"
361
+ }
362
+ ]
363
+ },
364
+ "request": {
365
+ "method": "GET",
366
+ "url": "https://www.example.com/members/report/"
367
+ }
368
+ },
369
+ "expect": {
370
+ "status": 302,
371
+ "headers": {
372
+ "location": "/login"
373
+ }
374
+ }
375
+ },
376
+ {
377
+ "id": "rules-auth-only-on-matching-paths",
378
+ "description": "An auth rule does not run for a path that it does not match.",
379
+ "tags": [
380
+ "rules"
381
+ ],
382
+ "op": "serveSite",
383
+ "input": {
384
+ "files": {
385
+ "members/report/index.html": "<h1>Members report</h1>",
386
+ "index.html": "<h1>Home</h1>"
387
+ },
388
+ "functions": [
389
+ {
390
+ "uuid": "a1b2c3d4-0003-4000-8000-000000000003",
391
+ "id": "gate",
392
+ "type": "auth",
393
+ "body": "return new Response('Sign in to continue', { status: 401 });"
394
+ }
395
+ ],
396
+ "rules": {
397
+ "version": 1,
398
+ "namespace": "conformance",
399
+ "rules": [
400
+ {
401
+ "id": "members",
402
+ "type": "auth",
403
+ "urls": [
404
+ "/members/*"
405
+ ],
406
+ "weight": 0,
407
+ "function_uuid": "a1b2c3d4-0003-4000-8000-000000000003"
408
+ }
409
+ ]
410
+ },
411
+ "request": {
412
+ "method": "GET",
413
+ "url": "https://www.example.com/"
414
+ }
415
+ },
416
+ "expect": {
417
+ "status": 200,
418
+ "bodyText": "<h1>Home</h1>"
419
+ }
420
+ },
421
+ {
422
+ "id": "rules-auth-missing-function-503",
423
+ "description": "An auth rule whose function does not exist answers 503.",
424
+ "tags": [
425
+ "rules"
426
+ ],
427
+ "op": "serveSite",
428
+ "input": {
429
+ "files": {
430
+ "members/report/index.html": "<h1>Members report</h1>",
431
+ "index.html": "<h1>Home</h1>"
432
+ },
433
+ "functions": [],
434
+ "rules": {
435
+ "version": 1,
436
+ "namespace": "conformance",
437
+ "rules": [
438
+ {
439
+ "id": "members",
440
+ "type": "auth",
441
+ "urls": [
442
+ "/members/*"
443
+ ],
444
+ "weight": 0,
445
+ "function_uuid": "a1b2c3d4-0099-4000-8000-000000000099"
446
+ }
447
+ ]
448
+ },
449
+ "request": {
450
+ "method": "GET",
451
+ "url": "https://www.example.com/members/report/"
452
+ }
453
+ },
454
+ "expect": {
455
+ "status": 503,
456
+ "headers": {
457
+ "cache-control": "no-store"
458
+ }
459
+ }
460
+ },
461
+ {
462
+ "id": "rules-auth-missing-function-503-message",
463
+ "description": "The 503 for an auth rule whose function does not exist has a fixed message.",
464
+ "tags": [
465
+ "rules",
466
+ "unverified"
467
+ ],
468
+ "op": "serveSite",
469
+ "input": {
470
+ "files": {
471
+ "members/report/index.html": "<h1>Members report</h1>",
472
+ "index.html": "<h1>Home</h1>"
473
+ },
474
+ "functions": [],
475
+ "rules": {
476
+ "version": 1,
477
+ "namespace": "conformance",
478
+ "rules": [
479
+ {
480
+ "id": "members",
481
+ "type": "auth",
482
+ "urls": [
483
+ "/members/*"
484
+ ],
485
+ "weight": 0,
486
+ "function_uuid": "a1b2c3d4-0099-4000-8000-000000000099"
487
+ }
488
+ ]
489
+ },
490
+ "request": {
491
+ "method": "GET",
492
+ "url": "https://www.example.com/members/report/"
493
+ }
494
+ },
495
+ "expect": {
496
+ "status": 503,
497
+ "bodyText": "Authentication for this page is not available."
498
+ }
499
+ },
500
+ {
501
+ "id": "rules-auth-201-then-function-rule",
502
+ "description": "After a 201 auth response, the next matching rule runs.",
503
+ "tags": [
504
+ "rules"
505
+ ],
506
+ "op": "serveSite",
507
+ "input": {
508
+ "files": {
509
+ "members/report/index.html": "<h1>Members report</h1>",
510
+ "index.html": "<h1>Home</h1>"
511
+ },
512
+ "functions": [
513
+ {
514
+ "uuid": "a1b2c3d4-0003-4000-8000-000000000003",
515
+ "id": "gate",
516
+ "type": "auth",
517
+ "body": "return new Response('ok', { status: 201 });"
518
+ },
519
+ {
520
+ "uuid": "a1b2c3d4-0001-4000-8000-000000000001",
521
+ "id": "api",
522
+ "type": "function",
523
+ "body": "return new Response(\"members api\", { status: 200, headers: { 'content-type': 'text/plain' } });"
524
+ }
525
+ ],
526
+ "rules": {
527
+ "version": 1,
528
+ "namespace": "conformance",
529
+ "rules": [
530
+ {
531
+ "id": "members",
532
+ "type": "auth",
533
+ "urls": [
534
+ "/members/*"
535
+ ],
536
+ "weight": 0,
537
+ "function_uuid": "a1b2c3d4-0003-4000-8000-000000000003"
538
+ },
539
+ {
540
+ "id": "members-api",
541
+ "type": "function",
542
+ "urls": [
543
+ "/members/*"
544
+ ],
545
+ "weight": 1,
546
+ "function_uuid": "a1b2c3d4-0001-4000-8000-000000000001"
547
+ }
548
+ ]
549
+ },
550
+ "request": {
551
+ "method": "GET",
552
+ "url": "https://www.example.com/members/report/"
553
+ }
554
+ },
555
+ "expect": {
556
+ "status": 200,
557
+ "bodyText": "members api"
558
+ }
559
+ },
560
+ {
561
+ "id": "rules-auth-chain",
562
+ "description": "Auth rules chain: each must return 201 for the next one to run.",
563
+ "tags": [
564
+ "rules"
565
+ ],
566
+ "op": "serveSite",
567
+ "input": {
568
+ "files": {
569
+ "members/report/index.html": "<h1>Members report</h1>",
570
+ "index.html": "<h1>Home</h1>"
571
+ },
572
+ "functions": [
573
+ {
574
+ "uuid": "a1b2c3d4-0003-4000-8000-000000000003",
575
+ "id": "gate",
576
+ "type": "auth",
577
+ "body": "return new Response('ok', { status: 201 });"
578
+ },
579
+ {
580
+ "uuid": "a1b2c3d4-0005-4000-8000-000000000005",
581
+ "id": "second-gate",
582
+ "type": "auth",
583
+ "body": "return new Response('Second check failed', { status: 403 });"
584
+ }
585
+ ],
586
+ "rules": {
587
+ "version": 1,
588
+ "namespace": "conformance",
589
+ "rules": [
590
+ {
591
+ "id": "first",
592
+ "type": "auth",
593
+ "urls": [
594
+ "/members/*"
595
+ ],
596
+ "weight": 0,
597
+ "function_uuid": "a1b2c3d4-0003-4000-8000-000000000003"
598
+ },
599
+ {
600
+ "id": "second",
601
+ "type": "auth",
602
+ "urls": [
603
+ "/members/*"
604
+ ],
605
+ "weight": 1,
606
+ "function_uuid": "a1b2c3d4-0005-4000-8000-000000000005"
607
+ }
608
+ ]
609
+ },
610
+ "request": {
611
+ "method": "GET",
612
+ "url": "https://www.example.com/members/report/"
613
+ }
614
+ },
615
+ "expect": {
616
+ "status": 403,
617
+ "bodyText": "Second check failed"
618
+ }
619
+ },
620
+ {
621
+ "id": "rules-missing-function-500",
622
+ "description": "A function rule whose function does not exist answers 500.",
623
+ "tags": [
624
+ "rules",
625
+ "unverified"
626
+ ],
627
+ "op": "serveSite",
628
+ "input": {
629
+ "files": {
630
+ "members/report/index.html": "<h1>Members report</h1>",
631
+ "index.html": "<h1>Home</h1>"
632
+ },
633
+ "functions": [],
634
+ "rules": {
635
+ "version": 1,
636
+ "namespace": "conformance",
637
+ "rules": [
638
+ {
639
+ "id": "api",
640
+ "type": "function",
641
+ "urls": [
642
+ "/api/*"
643
+ ],
644
+ "weight": 0,
645
+ "function_uuid": "a1b2c3d4-0099-4000-8000-000000000099"
646
+ }
647
+ ]
648
+ },
649
+ "request": {
650
+ "method": "GET",
651
+ "url": "https://www.example.com/api/status"
652
+ }
653
+ },
654
+ "expect": {
655
+ "status": 500
656
+ }
657
+ }
658
+ ]
659
+ }