| 1 |
package rfc |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
import ( |
| 18 |
"testing" |
| 19 |
|
| 20 |
"github.com/zmap/zlint/v3/lint" |
| 21 |
"github.com/zmap/zlint/v3/test" |
| 22 |
) |
| 23 |
|
| 24 |
func TestNewRsaAllowedKUEe(t *testing.T) { |
| 25 |
testCases := []struct { |
| 26 |
name string |
| 27 |
filename string |
| 28 |
expectedStatus lint.LintStatus |
| 29 |
expectedDetails string |
| 30 |
}{ |
| 31 |
{ |
| 32 |
name: "Certificate with EC key", |
| 33 |
filename: "ecdsaP384.pem", |
| 34 |
expectedStatus: lint.NA, |
| 35 |
expectedDetails: "", |
| 36 |
}, |
| 37 |
{ |
| 38 |
name: "Subscriber certificate with RSA key and key usages digitalSignature and nonRepudiation", |
| 39 |
filename: "eeWithRSAAllowedKeyUsage.pem", |
| 40 |
expectedStatus: lint.Pass, |
| 41 |
expectedDetails: "", |
| 42 |
}, |
| 43 |
{ |
| 44 |
name: "CA certificate with RSA key and key usages digitalSignature, certificateSign, and crlSign", |
| 45 |
filename: "caBasicConstCrit.pem", |
| 46 |
expectedStatus: lint.NA, |
| 47 |
expectedDetails: "", |
| 48 |
}, |
| 49 |
{ |
| 50 |
name: "Subscriber certificate with RSA key and key usages digitalSignature and nonRepudiation older than", |
| 51 |
filename: "eeWithRSAAllowedKeyUsageOld.pem", |
| 52 |
expectedStatus: lint.NE, |
| 53 |
expectedDetails: "", |
| 54 |
}, |
| 55 |
{ |
| 56 |
name: "Subscriber certificate with RSA key and key usage keyAgreement", |
| 57 |
filename: "eeWithRSADisallowedKeyUsage.pem", |
| 58 |
expectedStatus: lint.Error, |
| 59 |
expectedDetails: "Subscriber certificate with an RSA key contains invalid key usage(s): KeyUsageKeyAgreement", |
| 60 |
}, |
| 61 |
} |
| 62 |
|
| 63 |
for _, tc := range testCases { |
| 64 |
result := test.TestLint("e_rsa_allowed_ku_ee", tc.filename) |
| 65 |
if result.Status != tc.expectedStatus { |
| 66 |
t.Errorf("expected result %v. actual result was %v", |
| 67 |
tc.expectedStatus, result.Status) |
| 68 |
} |
| 69 |
if result.Details != tc.expectedDetails { |
| 70 |
t.Errorf("expected details %q. actual result was %q", |
| 71 |
tc.expectedDetails, result.Details) |
| 72 |
} |
| 73 |
} |
| 74 |
} |