aboutsummaryrefslogtreecommitdiff
path: root/cvss/v3key_test.go
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2022-02-04 00:35:31 -0500
committerPaul Duncan <pabs@pablotron.org>2022-02-04 00:35:31 -0500
commit9c17b97cd0f83be3fff9fa4e87fd1d29052ea616 (patch)
tree0d97030a0d0c3ad983be281ce89f80571338887f /cvss/v3key_test.go
parent92400d731546557d110c9c3cc3906d700f83dda8 (diff)
downloadcvez-9c17b97cd0f83be3fff9fa4e87fd1d29052ea616.tar.bz2
cvez-9c17b97cd0f83be3fff9fa4e87fd1d29052ea616.zip
rename to github.com/pablotron/cvez, remove internal libs
Diffstat (limited to 'cvss/v3key_test.go')
-rw-r--r--cvss/v3key_test.go142
1 files changed, 142 insertions, 0 deletions
diff --git a/cvss/v3key_test.go b/cvss/v3key_test.go
new file mode 100644
index 0000000..517eebd
--- /dev/null
+++ b/cvss/v3key_test.go
@@ -0,0 +1,142 @@
+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)
+ }
+ })
+ }
+}
+
+func TestInvalidV3KeyName(t *testing.T) {
+ exp := "invalid"
+ got := v3Key(255).Name()
+
+ if got != exp {
+ t.Errorf("got: \"%s\", exp: \"%s\"", got, exp)
+ }
+}
+
+func TestInvalidV3KeyCategory(t *testing.T) {
+ exp := InvalidCategory
+ got := v3Key(255).Category()
+
+ if got != exp {
+ t.Errorf("got: \"%s\", exp: \"%s\"", got, exp)
+ }
+}