boulder/linter/lints/rfc/lint_crl_has_aki_test.go

52 lines
991 B
Go

package rfc
import (
"fmt"
"strings"
"testing"
"github.com/zmap/zlint/v3/lint"
"github.com/letsencrypt/boulder/linter/lints/test"
)
func TestCrlHasAKI(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
want lint.LintStatus
wantSubStr string
}{
{
name: "good",
want: lint.Pass,
},
{
name: "no_aki",
want: lint.Error,
wantSubStr: "MUST include the authority key identifier",
},
{
name: "aki_name_and_serial",
want: lint.Error,
wantSubStr: "MUST use the key identifier method",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
l := NewCrlHasAKI()
c := test.LoadPEMCRL(t, fmt.Sprintf("testdata/crl_%s.pem", tc.name))
r := l.Execute(c)
if r.Status != tc.want {
t.Errorf("expected %q, got %q", tc.want, r.Status)
}
if !strings.Contains(r.Details, tc.wantSubStr) {
t.Errorf("expected %q, got %q", tc.wantSubStr, r.Details)
}
})
}
}