github.com/zmap/zlint@v1.1.0/lints/lint_spki_rsa_encryption_parameter_not_null_test.go (about) 1 package lints 2 3 import ( 4 "fmt" 5 "testing" 6 ) 7 8 func TestRSAAlgIDNullParams(t *testing.T) { 9 10 testCases := []struct { 11 name string 12 filepath string 13 expectedStatus LintStatus 14 details string 15 }{ 16 { 17 name: "pass cert with NULL params", 18 filepath: "rsawithsha1after2016.pem", 19 expectedStatus: Pass, 20 }, 21 { 22 name: "error cert with missing NULL params", 23 filepath: "rsaAlgIDNoNULLParams.pem", 24 expectedStatus: Error, 25 details: "certificate pkixPublicKey RSA algorithm identifier missing required NULL parameter", 26 }, 27 { 28 name: "error cert with non NULL params", 29 filepath: "rsaKeyWithParameters.pem", 30 expectedStatus: Error, 31 details: "certificate pkixPublicKey RSA algorithm identifier with non-NULL parameter", 32 }, 33 } 34 35 for _, tc := range testCases { 36 t.Run(tc.name, func(t *testing.T) { 37 inputPath := fmt.Sprintf("%s%s", testCaseDir, tc.filepath) 38 result := Lints["e_spki_rsa_encryption_parameter_not_null"].Execute(ReadCertificate(inputPath)) 39 if result.Status != tc.expectedStatus { 40 t.Errorf("expected result %v was %v", tc.expectedStatus, result.Status) 41 } 42 43 if result.Details != tc.details { 44 t.Errorf("expected error details %q was %q", tc.details, result.Details) 45 } 46 }) 47 } 48 }