...

Source file src/github.com/letsencrypt/boulder/linter/lints/rfc/lint_crl_has_number_test.go

Documentation: github.com/letsencrypt/boulder/linter/lints/rfc

     1  package rfc
     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 TestCrlHasNumber(t *testing.T) {
    14  	t.Parallel()
    15  
    16  	testCases := []struct {
    17  		name       string
    18  		want       lint.LintStatus
    19  		wantSubStr string
    20  	}{
    21  		{
    22  			name: "good",
    23  			want: lint.Pass,
    24  		},
    25  		{
    26  			name:       "no_number",
    27  			want:       lint.Error,
    28  			wantSubStr: "MUST include the CRL number",
    29  		},
    30  		{
    31  			name:       "critical_number",
    32  			want:       lint.Error,
    33  			wantSubStr: "MUST NOT be marked critical",
    34  		},
    35  		{
    36  			name:       "long_number",
    37  			want:       lint.Error,
    38  			wantSubStr: "MUST NOT be longer than 20 octets",
    39  		},
    40  	}
    41  
    42  	for _, tc := range testCases {
    43  		t.Run(tc.name, func(t *testing.T) {
    44  			l := NewCrlHasNumber()
    45  			c := test.LoadPEMCRL(t, fmt.Sprintf("testdata/crl_%s.pem", tc.name))
    46  			r := l.Execute(c)
    47  
    48  			if r.Status != tc.want {
    49  				t.Errorf("expected %q, got %q", tc.want, r.Status)
    50  			}
    51  			if !strings.Contains(r.Details, tc.wantSubStr) {
    52  				t.Errorf("expected %q, got %q", tc.wantSubStr, r.Details)
    53  			}
    54  		})
    55  	}
    56  }
    57  

View as plain text