1 package cabfbr
2
3 import (
4 "fmt"
5 "strings"
6 "testing"
7
8 "github.com/zmap/zlint/v3/lint"
9
10 "github.com/letsencrypt/boulder/linter/lints/test"
11 )
12
13 func TestCrlAcceptableReasonCodes(t *testing.T) {
14 t.Parallel()
15
16 testCases := []struct {
17 name string
18 want lint.LintStatus
19 wantSubStr string
20 }{
21 {
22
23 name: "good",
24 want: lint.Pass,
25 },
26 {
27 name: "reason_0",
28 want: lint.Error,
29 wantSubStr: "MUST NOT include reasonCodes other than",
30 },
31 {
32 name: "reason_1",
33 want: lint.Pass,
34 },
35 {
36 name: "reason_2",
37 want: lint.Error,
38 wantSubStr: "MUST NOT include reasonCodes other than",
39 },
40 {
41 name: "reason_3",
42 want: lint.Pass,
43 },
44 {
45 name: "reason_4",
46 want: lint.Pass,
47 },
48 {
49 name: "reason_5",
50 want: lint.Pass,
51 },
52 {
53 name: "reason_6",
54 want: lint.Error,
55 wantSubStr: "MUST NOT include reasonCodes other than",
56 },
57 {
58 name: "reason_8",
59 want: lint.Error,
60 wantSubStr: "MUST NOT include reasonCodes other than",
61 },
62 {
63 name: "reason_9",
64 want: lint.Pass,
65 },
66 {
67 name: "reason_10",
68 want: lint.Error,
69 wantSubStr: "MUST NOT include reasonCodes other than",
70 },
71 }
72
73 for _, tc := range testCases {
74 t.Run(tc.name, func(t *testing.T) {
75 l := NewCrlAcceptableReasonCodes()
76 c := test.LoadPEMCRL(t, fmt.Sprintf("testdata/crl_%s.pem", tc.name))
77 r := l.Execute(c)
78
79 if r.Status != tc.want {
80 t.Errorf("expected %q, got %q", tc.want, r.Status)
81 }
82 if !strings.Contains(r.Details, tc.wantSubStr) {
83 t.Errorf("expected %q, got %q", tc.wantSubStr, r.Details)
84 }
85 })
86 }
87 }
88
View as plain text