aboutsummaryrefslogtreecommitdiff
path: root/internal/cvss/v3key_test.go
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2022-01-31 22:07:06 -0500
committerPaul Duncan <pabs@pablotron.org>2022-01-31 22:07:06 -0500
commitabcd9428d9eb6cc8ac0189e6443930a67ebcabda (patch)
treedbd3a1f78fe900514244588d50bab7d98eebe0ba /internal/cvss/v3key_test.go
parenta739c2c0116e3bbe3122ec08b13a38440a3f9b62 (diff)
downloadcvez-abcd9428d9eb6cc8ac0189e6443930a67ebcabda.tar.bz2
cvez-abcd9428d9eb6cc8ac0189e6443930a67ebcabda.zip
internal/cvss: add many tests
Diffstat (limited to 'internal/cvss/v3key_test.go')
-rw-r--r--internal/cvss/v3key_test.go124
1 files changed, 124 insertions, 0 deletions
diff --git a/internal/cvss/v3key_test.go b/internal/cvss/v3key_test.go
new file mode 100644
index 0000000..ccf2b8f
--- /dev/null
+++ b/internal/cvss/v3key_test.go
@@ -0,0 +1,124 @@
+package cvss
+
+import (
+ "testing"
+)
+
+func TestV3KeyString(t *testing.T) {
+ tests := []struct {
+ val v3Key
+ exp string
+ } {
+ { v3AttackVector, "AV" },
+ { v3AttackComplexity, "AC" },
+ { v3PrivilegesRequired, "PR" },
+ { v3UserInteraction, "UI" },
+ { v3Scope, "S" },
+ { v3Confidentiality, "C" },
+ { v3Integrity, "I" },
+ { v3Availability, "A" },
+ { v3ExploitCodeMaturity, "E" },
+ { v3RemediationLevel, "RL" },
+ { v3ReportConfidence, "RC" },
+ { v3ConfidentialityRequirement, "CR" },
+ { v3IntegrityRequirement, "IR" },
+ { v3AvailabilityRequirement, "AR" },
+ { v3ModifiedAttackVector, "MAV" },
+ { v3ModifiedAttackComplexity, "MAC" },
+ { v3ModifiedPrivilegesRequired, "MPR" },
+ { v3ModifiedUserInteraction, "MUI" },
+ { v3ModifiedScope, "MS" },
+ { v3ModifiedConfidentiality, "MC" },
+ { v3ModifiedIntegrity, "MI" },
+ { v3ModifiedAvailability, "MA" },
+
+ { v3Key(255), "v3Key(255)" },
+ }
+
+ for _, test := range(tests) {
+ t.Run(test.exp, func(t *testing.T) {
+ got := test.val.String()
+ if got != test.exp {
+ t.Errorf("got \"%s\", exp \"%s\"", got, test.exp)
+ }
+ })
+ }
+}
+
+func TestV3KeyName(t *testing.T) {
+ tests := []struct {
+ val v3Key
+ exp string
+ } {
+ { v3AttackVector, "Attack Vector" },
+ { v3AttackComplexity, "Attack Complexity" },
+ { v3PrivilegesRequired, "Privileges Required" },
+ { v3UserInteraction, "User Interaction" },
+ { v3Scope, "Scope" },
+ { v3Confidentiality, "Confidentiality" },
+ { v3Integrity, "Integrity" },
+ { v3Availability, "Availability" },
+ { v3ExploitCodeMaturity, "Exploit Code Maturity" },
+ { v3RemediationLevel, "Remediation Level" },
+ { v3ReportConfidence, "Report Confidence" },
+ { v3ConfidentialityRequirement, "Confidentiality Requirement" },
+ { v3IntegrityRequirement, "Integrity Requirement" },
+ { v3AvailabilityRequirement, "Availability Requirement" },
+ { v3ModifiedAttackVector, "Modified Attack Vector" },
+ { v3ModifiedAttackComplexity, "Modified Attack Complexity" },
+ { v3ModifiedPrivilegesRequired, "Modified Privileges Required" },
+ { v3ModifiedUserInteraction, "Modified User Interaction" },
+ { v3ModifiedScope, "Modified Scope" },
+ { v3ModifiedConfidentiality, "Modified Confidentiality" },
+ { v3ModifiedIntegrity, "Modified Integrity" },
+ { v3ModifiedAvailability, "Modified Availability" },
+ }
+
+ for _, test := range(tests) {
+ t.Run(test.exp, func(t *testing.T) {
+ got := test.val.Name()
+ if got != test.exp {
+ t.Errorf("got \"%s\", exp \"%s\"", got, test.exp)
+ }
+ })
+ }
+}
+
+func TestV3KeyCategory(t *testing.T) {
+ tests := []struct {
+ val v3Key
+ exp Category
+ } {
+ { v3AttackVector, Base },
+ { v3AttackComplexity, Base },
+ { v3PrivilegesRequired, Base },
+ { v3UserInteraction, Base },
+ { v3Scope, Base },
+ { v3Confidentiality, Base },
+ { v3Integrity, Base },
+ { v3Availability, Base },
+ { v3ExploitCodeMaturity, Temporal },
+ { v3RemediationLevel, Temporal },
+ { v3ReportConfidence, Temporal },
+ { v3ConfidentialityRequirement, Environmental },
+ { v3IntegrityRequirement, Environmental },
+ { v3AvailabilityRequirement, Environmental },
+ { v3ModifiedAttackVector, Environmental },
+ { v3ModifiedAttackComplexity, Environmental },
+ { v3ModifiedPrivilegesRequired, Environmental },
+ { v3ModifiedUserInteraction, Environmental },
+ { v3ModifiedScope, Environmental },
+ { v3ModifiedConfidentiality, Environmental },
+ { v3ModifiedIntegrity, Environmental },
+ { v3ModifiedAvailability, Environmental },
+ }
+
+ for _, test := range(tests) {
+ t.Run(test.val.String(), func(t *testing.T) {
+ got := test.val.Category()
+ if got != test.exp {
+ t.Errorf("got \"%s\", exp \"%s\"", got, test.exp)
+ }
+ })
+ }
+}