File: signature_gen_test.go

package info (click to toggle)
golang-github-lestrrat-go-jwx 2.1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,872 kB
  • sloc: sh: 222; makefile: 86; perl: 62
file content (816 lines) | stat: -rw-r--r-- 26,489 bytes parent folder | download
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
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
// Code generated by tools/cmd/genjwa/main.go. DO NOT EDIT

package jwa_test

import (
	"testing"

	"github.com/lestrrat-go/jwx/v2/jwa"
	"github.com/stretchr/testify/assert"
)

func TestSignatureAlgorithm(t *testing.T) {
	t.Parallel()
	t.Run(`accept jwa constant ES256`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(jwa.ES256), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.ES256, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept the string ES256`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept("ES256"), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.ES256, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept fmt.Stringer for ES256`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(stringer{src: "ES256"}), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.ES256, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`stringification for ES256`, func(t *testing.T) {
		t.Parallel()
		if !assert.Equal(t, "ES256", jwa.ES256.String(), `stringified value matches`) {
			return
		}
	})
	t.Run(`accept jwa constant ES256K`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(jwa.ES256K), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.ES256K, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept the string ES256K`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept("ES256K"), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.ES256K, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept fmt.Stringer for ES256K`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(stringer{src: "ES256K"}), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.ES256K, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`stringification for ES256K`, func(t *testing.T) {
		t.Parallel()
		if !assert.Equal(t, "ES256K", jwa.ES256K.String(), `stringified value matches`) {
			return
		}
	})
	t.Run(`accept jwa constant ES384`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(jwa.ES384), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.ES384, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept the string ES384`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept("ES384"), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.ES384, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept fmt.Stringer for ES384`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(stringer{src: "ES384"}), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.ES384, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`stringification for ES384`, func(t *testing.T) {
		t.Parallel()
		if !assert.Equal(t, "ES384", jwa.ES384.String(), `stringified value matches`) {
			return
		}
	})
	t.Run(`accept jwa constant ES512`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(jwa.ES512), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.ES512, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept the string ES512`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept("ES512"), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.ES512, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept fmt.Stringer for ES512`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(stringer{src: "ES512"}), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.ES512, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`stringification for ES512`, func(t *testing.T) {
		t.Parallel()
		if !assert.Equal(t, "ES512", jwa.ES512.String(), `stringified value matches`) {
			return
		}
	})
	t.Run(`accept jwa constant EdDSA`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(jwa.EdDSA), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.EdDSA, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept the string EdDSA`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept("EdDSA"), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.EdDSA, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept fmt.Stringer for EdDSA`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(stringer{src: "EdDSA"}), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.EdDSA, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`stringification for EdDSA`, func(t *testing.T) {
		t.Parallel()
		if !assert.Equal(t, "EdDSA", jwa.EdDSA.String(), `stringified value matches`) {
			return
		}
	})
	t.Run(`accept jwa constant HS256`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(jwa.HS256), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.HS256, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept the string HS256`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept("HS256"), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.HS256, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept fmt.Stringer for HS256`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(stringer{src: "HS256"}), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.HS256, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`stringification for HS256`, func(t *testing.T) {
		t.Parallel()
		if !assert.Equal(t, "HS256", jwa.HS256.String(), `stringified value matches`) {
			return
		}
	})
	t.Run(`accept jwa constant HS384`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(jwa.HS384), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.HS384, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept the string HS384`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept("HS384"), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.HS384, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept fmt.Stringer for HS384`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(stringer{src: "HS384"}), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.HS384, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`stringification for HS384`, func(t *testing.T) {
		t.Parallel()
		if !assert.Equal(t, "HS384", jwa.HS384.String(), `stringified value matches`) {
			return
		}
	})
	t.Run(`accept jwa constant HS512`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(jwa.HS512), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.HS512, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept the string HS512`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept("HS512"), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.HS512, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept fmt.Stringer for HS512`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(stringer{src: "HS512"}), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.HS512, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`stringification for HS512`, func(t *testing.T) {
		t.Parallel()
		if !assert.Equal(t, "HS512", jwa.HS512.String(), `stringified value matches`) {
			return
		}
	})
	t.Run(`accept jwa constant NoSignature`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(jwa.NoSignature), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.NoSignature, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept the string none`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept("none"), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.NoSignature, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept fmt.Stringer for none`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(stringer{src: "none"}), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.NoSignature, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`stringification for none`, func(t *testing.T) {
		t.Parallel()
		if !assert.Equal(t, "none", jwa.NoSignature.String(), `stringified value matches`) {
			return
		}
	})
	t.Run(`accept jwa constant PS256`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(jwa.PS256), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.PS256, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept the string PS256`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept("PS256"), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.PS256, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept fmt.Stringer for PS256`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(stringer{src: "PS256"}), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.PS256, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`stringification for PS256`, func(t *testing.T) {
		t.Parallel()
		if !assert.Equal(t, "PS256", jwa.PS256.String(), `stringified value matches`) {
			return
		}
	})
	t.Run(`accept jwa constant PS384`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(jwa.PS384), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.PS384, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept the string PS384`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept("PS384"), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.PS384, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept fmt.Stringer for PS384`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(stringer{src: "PS384"}), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.PS384, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`stringification for PS384`, func(t *testing.T) {
		t.Parallel()
		if !assert.Equal(t, "PS384", jwa.PS384.String(), `stringified value matches`) {
			return
		}
	})
	t.Run(`accept jwa constant PS512`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(jwa.PS512), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.PS512, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept the string PS512`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept("PS512"), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.PS512, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept fmt.Stringer for PS512`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(stringer{src: "PS512"}), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.PS512, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`stringification for PS512`, func(t *testing.T) {
		t.Parallel()
		if !assert.Equal(t, "PS512", jwa.PS512.String(), `stringified value matches`) {
			return
		}
	})
	t.Run(`accept jwa constant RS256`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(jwa.RS256), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.RS256, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept the string RS256`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept("RS256"), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.RS256, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept fmt.Stringer for RS256`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(stringer{src: "RS256"}), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.RS256, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`stringification for RS256`, func(t *testing.T) {
		t.Parallel()
		if !assert.Equal(t, "RS256", jwa.RS256.String(), `stringified value matches`) {
			return
		}
	})
	t.Run(`accept jwa constant RS384`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(jwa.RS384), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.RS384, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept the string RS384`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept("RS384"), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.RS384, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept fmt.Stringer for RS384`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(stringer{src: "RS384"}), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.RS384, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`stringification for RS384`, func(t *testing.T) {
		t.Parallel()
		if !assert.Equal(t, "RS384", jwa.RS384.String(), `stringified value matches`) {
			return
		}
	})
	t.Run(`accept jwa constant RS512`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(jwa.RS512), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.RS512, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept the string RS512`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept("RS512"), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.RS512, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`accept fmt.Stringer for RS512`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.NoError(t, dst.Accept(stringer{src: "RS512"}), `accept is successful`) {
			return
		}
		if !assert.Equal(t, jwa.RS512, dst, `accepted value should be equal to constant`) {
			return
		}
	})
	t.Run(`stringification for RS512`, func(t *testing.T) {
		t.Parallel()
		if !assert.Equal(t, "RS512", jwa.RS512.String(), `stringified value matches`) {
			return
		}
	})
	t.Run(`bail out on random integer value`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.Error(t, dst.Accept(1), `accept should fail`) {
			return
		}
	})
	t.Run(`do not accept invalid (totally made up) string value`, func(t *testing.T) {
		t.Parallel()
		var dst jwa.SignatureAlgorithm
		if !assert.Error(t, dst.Accept(`totallyInvalidValue`), `accept should fail`) {
			return
		}
	})
	t.Run(`check symmetric values`, func(t *testing.T) {
		t.Parallel()
		t.Run(`ES256`, func(t *testing.T) {
			assert.False(t, jwa.ES256.IsSymmetric(), `jwa.ES256 should NOT be symmetric`)
		})
		t.Run(`ES256K`, func(t *testing.T) {
			assert.False(t, jwa.ES256K.IsSymmetric(), `jwa.ES256K should NOT be symmetric`)
		})
		t.Run(`ES384`, func(t *testing.T) {
			assert.False(t, jwa.ES384.IsSymmetric(), `jwa.ES384 should NOT be symmetric`)
		})
		t.Run(`ES512`, func(t *testing.T) {
			assert.False(t, jwa.ES512.IsSymmetric(), `jwa.ES512 should NOT be symmetric`)
		})
		t.Run(`EdDSA`, func(t *testing.T) {
			assert.False(t, jwa.EdDSA.IsSymmetric(), `jwa.EdDSA should NOT be symmetric`)
		})
		t.Run(`HS256`, func(t *testing.T) {
			assert.True(t, jwa.HS256.IsSymmetric(), `jwa.HS256 should be symmetric`)
		})
		t.Run(`HS384`, func(t *testing.T) {
			assert.True(t, jwa.HS384.IsSymmetric(), `jwa.HS384 should be symmetric`)
		})
		t.Run(`HS512`, func(t *testing.T) {
			assert.True(t, jwa.HS512.IsSymmetric(), `jwa.HS512 should be symmetric`)
		})
		t.Run(`NoSignature`, func(t *testing.T) {
			assert.False(t, jwa.NoSignature.IsSymmetric(), `jwa.NoSignature should NOT be symmetric`)
		})
		t.Run(`PS256`, func(t *testing.T) {
			assert.False(t, jwa.PS256.IsSymmetric(), `jwa.PS256 should NOT be symmetric`)
		})
		t.Run(`PS384`, func(t *testing.T) {
			assert.False(t, jwa.PS384.IsSymmetric(), `jwa.PS384 should NOT be symmetric`)
		})
		t.Run(`PS512`, func(t *testing.T) {
			assert.False(t, jwa.PS512.IsSymmetric(), `jwa.PS512 should NOT be symmetric`)
		})
		t.Run(`RS256`, func(t *testing.T) {
			assert.False(t, jwa.RS256.IsSymmetric(), `jwa.RS256 should NOT be symmetric`)
		})
		t.Run(`RS384`, func(t *testing.T) {
			assert.False(t, jwa.RS384.IsSymmetric(), `jwa.RS384 should NOT be symmetric`)
		})
		t.Run(`RS512`, func(t *testing.T) {
			assert.False(t, jwa.RS512.IsSymmetric(), `jwa.RS512 should NOT be symmetric`)
		})
	})
	t.Run(`check list of elements`, func(t *testing.T) {
		t.Parallel()
		var expected = map[jwa.SignatureAlgorithm]struct{}{
			jwa.ES256:       {},
			jwa.ES256K:      {},
			jwa.ES384:       {},
			jwa.ES512:       {},
			jwa.EdDSA:       {},
			jwa.HS256:       {},
			jwa.HS384:       {},
			jwa.HS512:       {},
			jwa.NoSignature: {},
			jwa.PS256:       {},
			jwa.PS384:       {},
			jwa.PS512:       {},
			jwa.RS256:       {},
			jwa.RS384:       {},
			jwa.RS512:       {},
		}
		for _, v := range jwa.SignatureAlgorithms() {
			if _, ok := expected[v]; !assert.True(t, ok, `%s should be in the expected list`, v) {
				return
			}
			delete(expected, v)
		}
		if !assert.Len(t, expected, 0) {
			return
		}
	})
}

// Note: this test can NOT be run in parallel as it uses options with global effect.
func TestSignatureAlgorithmCustomAlgorithm(t *testing.T) {
	// These subtests can NOT be run in parallel as options with global effect change.
	customAlgorithm := jwa.SignatureAlgorithm("custom-algorithm")
	// Unregister the custom algorithm, in case tests fail.
	t.Cleanup(func() {
		jwa.UnregisterSignatureAlgorithm(customAlgorithm)
	})
	t.Run(`with custom algorithm registered`, func(t *testing.T) {
		jwa.RegisterSignatureAlgorithm(customAlgorithm)
		t.Run(`accept variable used to register custom algorithm`, func(t *testing.T) {
			t.Parallel()
			var dst jwa.SignatureAlgorithm
			if !assert.NoError(t, dst.Accept(customAlgorithm), `accept is successful`) {
				return
			}
			assert.Equal(t, customAlgorithm, dst, `accepted value should be equal to variable`)
		})
		t.Run(`accept the string custom-algorithm`, func(t *testing.T) {
			t.Parallel()
			var dst jwa.SignatureAlgorithm
			if !assert.NoError(t, dst.Accept(`custom-algorithm`), `accept is successful`) {
				return
			}
			assert.Equal(t, customAlgorithm, dst, `accepted value should be equal to variable`)
		})
		t.Run(`accept fmt.Stringer for custom-algorithm`, func(t *testing.T) {
			t.Parallel()
			var dst jwa.SignatureAlgorithm
			if !assert.NoError(t, dst.Accept(stringer{src: `custom-algorithm`}), `accept is successful`) {
				return
			}
			assert.Equal(t, customAlgorithm, dst, `accepted value should be equal to variable`)
		})
		t.Run(`check symmetric`, func(t *testing.T) {
			t.Parallel()
			assert.False(t, customAlgorithm.IsSymmetric(), `custom algorithm should NOT be symmetric`)
		})
	})
	t.Run(`with custom algorithm deregistered`, func(t *testing.T) {
		jwa.UnregisterSignatureAlgorithm(customAlgorithm)
		t.Run(`reject variable used to register custom algorithm`, func(t *testing.T) {
			t.Parallel()
			var dst jwa.SignatureAlgorithm
			assert.Error(t, dst.Accept(customAlgorithm), `accept failed`)
		})
		t.Run(`reject the string custom-algorithm`, func(t *testing.T) {
			t.Parallel()
			var dst jwa.SignatureAlgorithm
			assert.Error(t, dst.Accept(`custom-algorithm`), `accept failed`)
		})
		t.Run(`reject fmt.Stringer for custom-algorithm`, func(t *testing.T) {
			t.Parallel()
			var dst jwa.SignatureAlgorithm
			assert.Error(t, dst.Accept(stringer{src: `custom-algorithm`}), `accept failed`)
		})
		t.Run(`check symmetric`, func(t *testing.T) {
			t.Parallel()
			assert.False(t, customAlgorithm.IsSymmetric(), `custom algorithm should NOT be symmetric`)
		})
	})

	t.Run(`with custom algorithm registered with WithSymmetricAlgorithm(false)`, func(t *testing.T) {
		jwa.RegisterSignatureAlgorithmWithOptions(customAlgorithm, jwa.WithSymmetricAlgorithm(false))
		t.Run(`accept variable used to register custom algorithm`, func(t *testing.T) {
			t.Parallel()
			var dst jwa.SignatureAlgorithm
			if !assert.NoError(t, dst.Accept(customAlgorithm), `accept is successful`) {
				return
			}
			assert.Equal(t, customAlgorithm, dst, `accepted value should be equal to variable`)
		})
		t.Run(`accept the string custom-algorithm`, func(t *testing.T) {
			t.Parallel()
			var dst jwa.SignatureAlgorithm
			if !assert.NoError(t, dst.Accept(`custom-algorithm`), `accept is successful`) {
				return
			}
			assert.Equal(t, customAlgorithm, dst, `accepted value should be equal to variable`)
		})
		t.Run(`accept fmt.Stringer for custom-algorithm`, func(t *testing.T) {
			t.Parallel()
			var dst jwa.SignatureAlgorithm
			if !assert.NoError(t, dst.Accept(stringer{src: `custom-algorithm`}), `accept is successful`) {
				return
			}
			assert.Equal(t, customAlgorithm, dst, `accepted value should be equal to variable`)
		})
		t.Run(`check symmetric`, func(t *testing.T) {
			t.Parallel()
			assert.False(t, customAlgorithm.IsSymmetric(), `custom algorithm should NOT be symmetric`)
		})
	})
	t.Run(`with custom algorithm deregistered (was WithSymmetricAlgorithm(false))`, func(t *testing.T) {
		jwa.UnregisterSignatureAlgorithm(customAlgorithm)
		t.Run(`reject variable used to register custom algorithm`, func(t *testing.T) {
			t.Parallel()
			var dst jwa.SignatureAlgorithm
			assert.Error(t, dst.Accept(customAlgorithm), `accept failed`)
		})
		t.Run(`reject the string custom-algorithm`, func(t *testing.T) {
			t.Parallel()
			var dst jwa.SignatureAlgorithm
			assert.Error(t, dst.Accept(`custom-algorithm`), `accept failed`)
		})
		t.Run(`reject fmt.Stringer for custom-algorithm`, func(t *testing.T) {
			t.Parallel()
			var dst jwa.SignatureAlgorithm
			assert.Error(t, dst.Accept(stringer{src: `custom-algorithm`}), `accept failed`)
		})
		t.Run(`check symmetric`, func(t *testing.T) {
			t.Parallel()
			assert.False(t, customAlgorithm.IsSymmetric(), `custom algorithm should NOT be symmetric`)
		})
	})

	t.Run(`with custom algorithm registered with WithSymmetricAlgorithm(true)`, func(t *testing.T) {
		jwa.RegisterSignatureAlgorithmWithOptions(customAlgorithm, jwa.WithSymmetricAlgorithm(true))
		t.Run(`accept variable used to register custom algorithm`, func(t *testing.T) {
			t.Parallel()
			var dst jwa.SignatureAlgorithm
			if !assert.NoError(t, dst.Accept(customAlgorithm), `accept is successful`) {
				return
			}
			assert.Equal(t, customAlgorithm, dst, `accepted value should be equal to variable`)
		})
		t.Run(`accept the string custom-algorithm`, func(t *testing.T) {
			t.Parallel()
			var dst jwa.SignatureAlgorithm
			if !assert.NoError(t, dst.Accept(`custom-algorithm`), `accept is successful`) {
				return
			}
			assert.Equal(t, customAlgorithm, dst, `accepted value should be equal to variable`)
		})
		t.Run(`accept fmt.Stringer for custom-algorithm`, func(t *testing.T) {
			t.Parallel()
			var dst jwa.SignatureAlgorithm
			if !assert.NoError(t, dst.Accept(stringer{src: `custom-algorithm`}), `accept is successful`) {
				return
			}
			assert.Equal(t, customAlgorithm, dst, `accepted value should be equal to variable`)
		})
		t.Run(`check symmetric`, func(t *testing.T) {
			t.Parallel()
			assert.True(t, customAlgorithm.IsSymmetric(), `custom algorithm should be symmetric`)
		})
	})
	t.Run(`with custom algorithm deregistered (was WithSymmetricAlgorithm(true))`, func(t *testing.T) {
		jwa.UnregisterSignatureAlgorithm(customAlgorithm)
		t.Run(`reject variable used to register custom algorithm`, func(t *testing.T) {
			t.Parallel()
			var dst jwa.SignatureAlgorithm
			assert.Error(t, dst.Accept(customAlgorithm), `accept failed`)
		})
		t.Run(`reject the string custom-algorithm`, func(t *testing.T) {
			t.Parallel()
			var dst jwa.SignatureAlgorithm
			assert.Error(t, dst.Accept(`custom-algorithm`), `accept failed`)
		})
		t.Run(`reject fmt.Stringer for custom-algorithm`, func(t *testing.T) {
			t.Parallel()
			var dst jwa.SignatureAlgorithm
			assert.Error(t, dst.Accept(stringer{src: `custom-algorithm`}), `accept failed`)
		})
		t.Run(`check symmetric`, func(t *testing.T) {
			t.Parallel()
			assert.False(t, customAlgorithm.IsSymmetric(), `custom algorithm should NOT be symmetric`)
		})
	})
}