| 1 | package cabf_smime_br |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/zmap/zlint/v3/lint" |
| 7 | "github.com/zmap/zlint/v3/test" |
| 8 | ) |
| 9 | |
| 10 | func TestSMIMESubjectDirAttributes(t *testing.T) { |
| 11 | testCases := []struct { |
| 12 | Name string |
| 13 | InputFilename string |
| 14 | ExpectedResult lint.LintStatus |
| 15 | }{ |
| 16 | { |
| 17 | Name: "pass - no subject dir attributes extension", |
| 18 | InputFilename: "smime/mailboxValidatedStrictWithCommonName.pem", |
| 19 | ExpectedResult: lint.Pass, |
| 20 | }, |
| 21 | { |
| 22 | Name: "error - multipurpose with subject dir attributes extension", |
| 23 | InputFilename: "smime/multipurposeWithSubjectDirectoryAttributes.pem", |
| 24 | ExpectedResult: lint.Error, |
| 25 | }, |
| 26 | { |
| 27 | Name: "NA - legacy no subject dir attributes extension", |
| 28 | InputFilename: "smime/ec_legacy_digital_signature_ku.pem", |
| 29 | ExpectedResult: lint.NA, |
| 30 | }, |
| 31 | } |
| 32 | for _, tc := range testCases { |
| 33 | t.Run(tc.Name, func(t *testing.T) { |
| 34 | result := test.TestLint("e_strict_multipurpose_smime_ext_subject_directory_attr", tc.InputFilename) |
| 35 | if result.Status != tc.ExpectedResult { |
| 36 | t.Errorf("expected result %v was %v - details: %v", tc.ExpectedResult, result.Status, result.Details) |
| 37 | } |
| 38 | }) |
| 39 | } |
| 40 | } |