@selfauth/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.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +16 -2
  3. package/cases/admin.json +326 -0
  4. package/cases/audit-and-errors.json +233 -0
  5. package/cases/csrf.json +413 -0
  6. package/cases/email-verification.json +567 -0
  7. package/cases/identity.json +546 -0
  8. package/cases/login.json +446 -0
  9. package/cases/logout.json +213 -0
  10. package/cases/password-change.json +270 -0
  11. package/cases/password-reset.json +698 -0
  12. package/cases/rate-limits.json +667 -0
  13. package/cases/rbac.json +575 -0
  14. package/cases/registration.json +782 -0
  15. package/cases/resources.json +373 -0
  16. package/cases/sessions.json +308 -0
  17. package/dist/coverage.d.ts +26 -0
  18. package/dist/coverage.d.ts.map +1 -0
  19. package/dist/coverage.js +105 -0
  20. package/dist/coverage.js.map +1 -0
  21. package/dist/index.d.ts +7 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +7 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/load.d.ts +12 -0
  26. package/dist/load.d.ts.map +1 -0
  27. package/dist/load.js +26 -0
  28. package/dist/load.js.map +1 -0
  29. package/dist/report.d.ts +3 -0
  30. package/dist/report.d.ts.map +1 -0
  31. package/dist/report.js +31 -0
  32. package/dist/report.js.map +1 -0
  33. package/dist/runner/assertions.d.ts +11 -0
  34. package/dist/runner/assertions.d.ts.map +1 -0
  35. package/dist/runner/assertions.js +253 -0
  36. package/dist/runner/assertions.js.map +1 -0
  37. package/dist/runner/driver.d.ts +58 -0
  38. package/dist/runner/driver.d.ts.map +1 -0
  39. package/dist/runner/driver.js +2 -0
  40. package/dist/runner/driver.js.map +1 -0
  41. package/dist/runner/run.d.ts +17 -0
  42. package/dist/runner/run.d.ts.map +1 -0
  43. package/dist/runner/run.js +390 -0
  44. package/dist/runner/run.js.map +1 -0
  45. package/dist/schema.d.ts +168 -0
  46. package/dist/schema.d.ts.map +1 -0
  47. package/dist/schema.js +121 -0
  48. package/dist/schema.js.map +1 -0
  49. package/package.json +53 -3
  50. package/verification.json +165 -0
@@ -0,0 +1,698 @@
1
+ {
2
+ "cases": [
3
+ {
4
+ "id": "CT-RESET-001",
5
+ "title": "Reset requests are indistinguishable for known and unknown emails",
6
+ "category": "password-reset",
7
+ "level": "core",
8
+ "requirements": ["AUTHN-RESET-001", "SEC-ENUM-001"],
9
+ "given": [
10
+ {
11
+ "user": "alice",
12
+ "email": "alice@example.test",
13
+ "password": "correct horse battery staple",
14
+ "state": "active"
15
+ }
16
+ ],
17
+ "steps": [
18
+ {
19
+ "op": "requestPasswordReset",
20
+ "input": {
21
+ "email": "alice@example.test"
22
+ },
23
+ "expect": {
24
+ "outcome": "success"
25
+ },
26
+ "save": "known"
27
+ },
28
+ {
29
+ "op": "requestPasswordReset",
30
+ "input": {
31
+ "email": "nobody@example.test"
32
+ },
33
+ "expect": {
34
+ "outcome": "success",
35
+ "indistinguishableFrom": "known"
36
+ }
37
+ },
38
+ {
39
+ "op": "readLastEmail",
40
+ "input": {
41
+ "to": "alice@example.test"
42
+ },
43
+ "expect": {
44
+ "outcome": "success",
45
+ "assert": {
46
+ "kind": "passwordReset"
47
+ }
48
+ }
49
+ },
50
+ {
51
+ "op": "readLastEmail",
52
+ "input": {
53
+ "to": "nobody@example.test"
54
+ },
55
+ "expect": {
56
+ "outcome": "success",
57
+ "assert": {
58
+ "none": true
59
+ }
60
+ }
61
+ }
62
+ ]
63
+ },
64
+ {
65
+ "id": "CT-RESET-002",
66
+ "title": "No reset token is issued for suspended, disabled or deleted accounts",
67
+ "category": "password-reset",
68
+ "level": "core",
69
+ "requirements": ["AUTHN-RESET-002"],
70
+ "given": [
71
+ {
72
+ "user": "susp",
73
+ "email": "susp@example.test",
74
+ "password": "correct horse battery staple",
75
+ "state": "suspended"
76
+ },
77
+ {
78
+ "user": "dis",
79
+ "email": "dis@example.test",
80
+ "password": "correct horse battery staple",
81
+ "state": "disabled"
82
+ },
83
+ {
84
+ "user": "gone",
85
+ "email": "gone@example.test",
86
+ "password": "correct horse battery staple",
87
+ "state": "deleted"
88
+ }
89
+ ],
90
+ "steps": [
91
+ {
92
+ "op": "requestPasswordReset",
93
+ "input": {
94
+ "email": "susp@example.test"
95
+ },
96
+ "expect": {
97
+ "outcome": "success"
98
+ }
99
+ },
100
+ {
101
+ "op": "requestPasswordReset",
102
+ "input": {
103
+ "email": "dis@example.test"
104
+ },
105
+ "expect": {
106
+ "outcome": "success"
107
+ }
108
+ },
109
+ {
110
+ "op": "requestPasswordReset",
111
+ "input": {
112
+ "email": "gone@example.test"
113
+ },
114
+ "expect": {
115
+ "outcome": "success"
116
+ }
117
+ },
118
+ {
119
+ "op": "inspectStorage",
120
+ "input": {
121
+ "entity": "passwordResetToken"
122
+ },
123
+ "expect": {
124
+ "outcome": "success",
125
+ "assert": {
126
+ "count": 0
127
+ }
128
+ }
129
+ }
130
+ ]
131
+ },
132
+ {
133
+ "id": "CT-RESET-003",
134
+ "title": "A successful reset changes the password and revokes every session",
135
+ "category": "password-reset",
136
+ "level": "core",
137
+ "requirements": [
138
+ "AUTHN-RESET-003",
139
+ "AUTHN-RESET-010",
140
+ "AUTHN-RESET-013",
141
+ "SEC-TOKEN-002",
142
+ "AUTHN-SESS-006"
143
+ ],
144
+ "given": [
145
+ {
146
+ "user": "alice",
147
+ "email": "alice@example.test",
148
+ "password": "correct horse battery staple",
149
+ "state": "active"
150
+ }
151
+ ],
152
+ "steps": [
153
+ {
154
+ "op": "login",
155
+ "as": "laptop",
156
+ "input": {
157
+ "email": "alice@example.test",
158
+ "password": "correct horse battery staple"
159
+ }
160
+ },
161
+ {
162
+ "op": "requestPasswordReset",
163
+ "input": {
164
+ "email": "alice@example.test"
165
+ }
166
+ },
167
+ {
168
+ "op": "readLastEmail",
169
+ "input": {
170
+ "to": "alice@example.test"
171
+ },
172
+ "save": "mail"
173
+ },
174
+ {
175
+ "op": "inspectStorage",
176
+ "input": {
177
+ "entity": "passwordResetToken"
178
+ },
179
+ "expect": {
180
+ "outcome": "success",
181
+ "assert": {
182
+ "noFieldContaining": ["$mail.token"],
183
+ "first.tokenHash": {
184
+ "sha256Of": "$mail.token"
185
+ }
186
+ }
187
+ }
188
+ },
189
+ {
190
+ "op": "resetPassword",
191
+ "input": {
192
+ "token": "$mail.token",
193
+ "newPassword": "a brand new passphrase 42"
194
+ },
195
+ "expect": {
196
+ "outcome": "success",
197
+ "sessionCreated": false
198
+ }
199
+ },
200
+ {
201
+ "op": "getCurrentUser",
202
+ "as": "laptop",
203
+ "expect": {
204
+ "outcome": "error",
205
+ "code": "UNAUTHENTICATED"
206
+ }
207
+ },
208
+ {
209
+ "op": "login",
210
+ "input": {
211
+ "email": "alice@example.test",
212
+ "password": "correct horse battery staple"
213
+ },
214
+ "expect": {
215
+ "outcome": "error",
216
+ "code": "INVALID_CREDENTIALS"
217
+ }
218
+ },
219
+ {
220
+ "op": "login",
221
+ "input": {
222
+ "email": "alice@example.test",
223
+ "password": "a brand new passphrase 42"
224
+ },
225
+ "expect": {
226
+ "outcome": "success"
227
+ }
228
+ },
229
+ {
230
+ "op": "inspectEvents",
231
+ "input": {
232
+ "type": "password.reset.requested"
233
+ },
234
+ "expect": {
235
+ "outcome": "success",
236
+ "assert": {
237
+ "count": 1
238
+ }
239
+ }
240
+ },
241
+ {
242
+ "op": "inspectEvents",
243
+ "input": {
244
+ "type": "password.reset.completed"
245
+ },
246
+ "expect": {
247
+ "outcome": "success",
248
+ "assert": {
249
+ "count": 1
250
+ }
251
+ }
252
+ }
253
+ ]
254
+ },
255
+ {
256
+ "id": "CT-RESET-004",
257
+ "title": "Reset tokens expire after the configured TTL",
258
+ "category": "password-reset",
259
+ "level": "core",
260
+ "requirements": ["AUTHN-RESET-003", "AUTHN-RESET-007"],
261
+ "given": [
262
+ {
263
+ "user": "alice",
264
+ "email": "alice@example.test",
265
+ "password": "correct horse battery staple",
266
+ "state": "active"
267
+ }
268
+ ],
269
+ "steps": [
270
+ {
271
+ "op": "requestPasswordReset",
272
+ "input": {
273
+ "email": "alice@example.test"
274
+ }
275
+ },
276
+ {
277
+ "op": "readLastEmail",
278
+ "input": {
279
+ "to": "alice@example.test"
280
+ },
281
+ "save": "mail"
282
+ },
283
+ {
284
+ "op": "advanceClock",
285
+ "input": {
286
+ "minutes": 31
287
+ }
288
+ },
289
+ {
290
+ "op": "resetPassword",
291
+ "input": {
292
+ "token": "$mail.token",
293
+ "newPassword": "a brand new passphrase 42"
294
+ },
295
+ "expect": {
296
+ "outcome": "error",
297
+ "code": "TOKEN_INVALID"
298
+ }
299
+ }
300
+ ]
301
+ },
302
+ {
303
+ "id": "CT-RESET-005",
304
+ "title": "Requesting a new reset invalidates earlier tokens",
305
+ "category": "password-reset",
306
+ "level": "core",
307
+ "requirements": ["AUTHN-RESET-004"],
308
+ "given": [
309
+ {
310
+ "user": "alice",
311
+ "email": "alice@example.test",
312
+ "password": "correct horse battery staple",
313
+ "state": "active"
314
+ }
315
+ ],
316
+ "steps": [
317
+ {
318
+ "op": "requestPasswordReset",
319
+ "input": {
320
+ "email": "alice@example.test"
321
+ }
322
+ },
323
+ {
324
+ "op": "readLastEmail",
325
+ "input": {
326
+ "to": "alice@example.test"
327
+ },
328
+ "save": "first"
329
+ },
330
+ {
331
+ "op": "requestPasswordReset",
332
+ "input": {
333
+ "email": "alice@example.test"
334
+ }
335
+ },
336
+ {
337
+ "op": "readLastEmail",
338
+ "input": {
339
+ "to": "alice@example.test"
340
+ },
341
+ "save": "second"
342
+ },
343
+ {
344
+ "op": "resetPassword",
345
+ "input": {
346
+ "token": "$first.token",
347
+ "newPassword": "a brand new passphrase 42"
348
+ },
349
+ "expect": {
350
+ "outcome": "error",
351
+ "code": "TOKEN_INVALID"
352
+ }
353
+ },
354
+ {
355
+ "op": "resetPassword",
356
+ "input": {
357
+ "token": "$second.token",
358
+ "newPassword": "a brand new passphrase 42"
359
+ },
360
+ "expect": {
361
+ "outcome": "success"
362
+ }
363
+ }
364
+ ]
365
+ },
366
+ {
367
+ "id": "CT-RESET-006",
368
+ "title": "A password-policy violation does not consume the token",
369
+ "category": "password-reset",
370
+ "level": "core",
371
+ "requirements": ["AUTHN-RESET-008"],
372
+ "given": [
373
+ {
374
+ "user": "alice",
375
+ "email": "alice@example.test",
376
+ "password": "correct horse battery staple",
377
+ "state": "active"
378
+ }
379
+ ],
380
+ "steps": [
381
+ {
382
+ "op": "requestPasswordReset",
383
+ "input": {
384
+ "email": "alice@example.test"
385
+ }
386
+ },
387
+ {
388
+ "op": "readLastEmail",
389
+ "input": {
390
+ "to": "alice@example.test"
391
+ },
392
+ "save": "mail"
393
+ },
394
+ {
395
+ "op": "resetPassword",
396
+ "input": {
397
+ "token": "$mail.token",
398
+ "newPassword": "short"
399
+ },
400
+ "expect": {
401
+ "outcome": "error",
402
+ "code": "PASSWORD_POLICY_VIOLATION"
403
+ }
404
+ },
405
+ {
406
+ "op": "resetPassword",
407
+ "input": {
408
+ "token": "$mail.token",
409
+ "newPassword": "a brand new passphrase 42"
410
+ },
411
+ "expect": {
412
+ "outcome": "success"
413
+ }
414
+ }
415
+ ]
416
+ },
417
+ {
418
+ "id": "CT-RESET-007",
419
+ "title": "Reset tokens are single-use, including under concurrency",
420
+ "category": "password-reset",
421
+ "level": "core",
422
+ "requirements": ["AUTHN-RESET-009", "DATA-MODEL-002", "SEC-TOKEN-003"],
423
+ "given": [
424
+ {
425
+ "user": "alice",
426
+ "email": "alice@example.test",
427
+ "password": "correct horse battery staple",
428
+ "state": "active"
429
+ }
430
+ ],
431
+ "steps": [
432
+ {
433
+ "op": "requestPasswordReset",
434
+ "input": {
435
+ "email": "alice@example.test"
436
+ }
437
+ },
438
+ {
439
+ "op": "readLastEmail",
440
+ "input": {
441
+ "to": "alice@example.test"
442
+ },
443
+ "save": "mail"
444
+ },
445
+ {
446
+ "op": "concurrent",
447
+ "input": {
448
+ "steps": [
449
+ {
450
+ "op": "resetPassword",
451
+ "as": "c0",
452
+ "input": {
453
+ "token": "$mail.token",
454
+ "newPassword": "concurrent passphrase 0"
455
+ }
456
+ },
457
+ {
458
+ "op": "resetPassword",
459
+ "as": "c1",
460
+ "input": {
461
+ "token": "$mail.token",
462
+ "newPassword": "concurrent passphrase 1"
463
+ }
464
+ },
465
+ {
466
+ "op": "resetPassword",
467
+ "as": "c2",
468
+ "input": {
469
+ "token": "$mail.token",
470
+ "newPassword": "concurrent passphrase 2"
471
+ }
472
+ },
473
+ {
474
+ "op": "resetPassword",
475
+ "as": "c3",
476
+ "input": {
477
+ "token": "$mail.token",
478
+ "newPassword": "concurrent passphrase 3"
479
+ }
480
+ },
481
+ {
482
+ "op": "resetPassword",
483
+ "as": "c4",
484
+ "input": {
485
+ "token": "$mail.token",
486
+ "newPassword": "concurrent passphrase 4"
487
+ }
488
+ }
489
+ ]
490
+ },
491
+ "expect": {
492
+ "outcome": "success",
493
+ "successCount": 1
494
+ }
495
+ },
496
+ {
497
+ "op": "resetPassword",
498
+ "input": {
499
+ "token": "$mail.token",
500
+ "newPassword": "a brand new passphrase 42"
501
+ },
502
+ "expect": {
503
+ "outcome": "error",
504
+ "code": "TOKEN_INVALID"
505
+ }
506
+ }
507
+ ]
508
+ },
509
+ {
510
+ "id": "CT-RESET-008",
511
+ "title": "A token becomes invalid when its account is suspended",
512
+ "category": "password-reset",
513
+ "level": "authorization",
514
+ "requirements": ["AUTHN-RESET-007", "IDENT-STATE-003"],
515
+ "given": [
516
+ {
517
+ "user": "alice",
518
+ "email": "alice@example.test",
519
+ "password": "correct horse battery staple",
520
+ "state": "active"
521
+ },
522
+ {
523
+ "user": "admin",
524
+ "email": "admin@example.test",
525
+ "password": "correct horse battery staple",
526
+ "state": "active",
527
+ "roles": ["admin"]
528
+ }
529
+ ],
530
+ "steps": [
531
+ {
532
+ "op": "requestPasswordReset",
533
+ "input": {
534
+ "email": "alice@example.test"
535
+ }
536
+ },
537
+ {
538
+ "op": "readLastEmail",
539
+ "input": {
540
+ "to": "alice@example.test"
541
+ },
542
+ "save": "mail"
543
+ },
544
+ {
545
+ "op": "login",
546
+ "as": "admin",
547
+ "input": {
548
+ "email": "admin@example.test",
549
+ "password": "correct horse battery staple"
550
+ }
551
+ },
552
+ {
553
+ "op": "setAccountState",
554
+ "as": "admin",
555
+ "input": {
556
+ "user": "$alice.id",
557
+ "state": "suspended"
558
+ },
559
+ "expect": {
560
+ "outcome": "success"
561
+ }
562
+ },
563
+ {
564
+ "op": "resetPassword",
565
+ "input": {
566
+ "token": "$mail.token",
567
+ "newPassword": "a brand new passphrase 42"
568
+ },
569
+ "expect": {
570
+ "outcome": "error",
571
+ "code": "TOKEN_INVALID"
572
+ }
573
+ }
574
+ ]
575
+ },
576
+ {
577
+ "id": "CT-RESET-009",
578
+ "title": "Reset requests are rate limited, identically for unknown emails",
579
+ "category": "password-reset",
580
+ "level": "core",
581
+ "requirements": ["AUTHN-RESET-005", "SEC-RATE-002", "SEC-RATE-004"],
582
+ "given": [
583
+ {
584
+ "user": "alice",
585
+ "email": "alice@example.test",
586
+ "password": "correct horse battery staple",
587
+ "state": "active"
588
+ }
589
+ ],
590
+ "steps": [
591
+ {
592
+ "op": "requestPasswordReset",
593
+ "input": {
594
+ "email": "alice@example.test"
595
+ },
596
+ "expect": {
597
+ "outcome": "success"
598
+ }
599
+ },
600
+ {
601
+ "op": "requestPasswordReset",
602
+ "input": {
603
+ "email": "alice@example.test"
604
+ },
605
+ "expect": {
606
+ "outcome": "success"
607
+ }
608
+ },
609
+ {
610
+ "op": "requestPasswordReset",
611
+ "input": {
612
+ "email": "alice@example.test"
613
+ },
614
+ "expect": {
615
+ "outcome": "success"
616
+ }
617
+ },
618
+ {
619
+ "op": "requestPasswordReset",
620
+ "input": {
621
+ "email": "alice@example.test"
622
+ },
623
+ "expect": {
624
+ "outcome": "error",
625
+ "code": "RATE_LIMITED"
626
+ },
627
+ "save": "limited"
628
+ },
629
+ {
630
+ "op": "requestPasswordReset",
631
+ "input": {
632
+ "email": "nobody@example.test"
633
+ },
634
+ "expect": {
635
+ "outcome": "success"
636
+ }
637
+ },
638
+ {
639
+ "op": "requestPasswordReset",
640
+ "input": {
641
+ "email": "nobody@example.test"
642
+ },
643
+ "expect": {
644
+ "outcome": "success"
645
+ }
646
+ },
647
+ {
648
+ "op": "requestPasswordReset",
649
+ "input": {
650
+ "email": "nobody@example.test"
651
+ },
652
+ "expect": {
653
+ "outcome": "success"
654
+ }
655
+ },
656
+ {
657
+ "op": "requestPasswordReset",
658
+ "input": {
659
+ "email": "nobody@example.test"
660
+ },
661
+ "expect": {
662
+ "outcome": "error",
663
+ "code": "RATE_LIMITED",
664
+ "indistinguishableFrom": "limited"
665
+ }
666
+ }
667
+ ]
668
+ },
669
+ {
670
+ "id": "CT-RESET-010",
671
+ "title": "The 'requested' event is recorded only when a token is issued",
672
+ "category": "password-reset",
673
+ "level": "core",
674
+ "requirements": ["AUTHN-RESET-013"],
675
+ "given": [],
676
+ "steps": [
677
+ {
678
+ "op": "requestPasswordReset",
679
+ "input": {
680
+ "email": "nobody@example.test"
681
+ }
682
+ },
683
+ {
684
+ "op": "inspectEvents",
685
+ "input": {
686
+ "type": "password.reset.requested"
687
+ },
688
+ "expect": {
689
+ "outcome": "success",
690
+ "assert": {
691
+ "count": 0
692
+ }
693
+ }
694
+ }
695
+ ]
696
+ }
697
+ ]
698
+ }