...

Source file src/github.com/letsencrypt/boulder/linter/lints/rfc/lint_crl_has_valid_timestamps_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 TestCrlHasValidTimestamps(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: "good_utctime_1950",
    27  			want: lint.Pass,
    28  		},
    29  		{
    30  			name: "good_gentime_2050",
    31  			want: lint.Pass,
    32  		},
    33  		{
    34  			name:       "gentime_2049",
    35  			want:       lint.Error,
    36  			wantSubStr: "timestamps prior to 2050 MUST be encoded using UTCTime",
    37  		},
    38  		{
    39  			name:       "utctime_no_seconds",
    40  			want:       lint.Error,
    41  			wantSubStr: "timestamps encoded using UTCTime MUST be specified in the format \"YYMMDDHHMMSSZ\"",
    42  		},
    43  		{
    44  			name:       "gentime_revoked_2049",
    45  			want:       lint.Error,
    46  			wantSubStr: "timestamps prior to 2050 MUST be encoded using UTCTime",
    47  		},
    48  	}
    49  
    50  	for _, tc := range testCases {
    51  		t.Run(tc.name, func(t *testing.T) {
    52  			l := NewCrlHasValidTimestamps()
    53  			c := test.LoadPEMCRL(t, fmt.Sprintf("testdata/crl_%s.pem", tc.name))
    54  			r := l.Execute(c)
    55  
    56  			if r.Status != tc.want {
    57  				t.Errorf("expected %q, got %q", tc.want, r.Status)
    58  			}
    59  			if !strings.Contains(r.Details, tc.wantSubStr) {
    60  				t.Errorf("expected %q, got %q", tc.wantSubStr, r.Details)
    61  			}
    62  		})
    63  	}
    64  }
    65  

View as plain text