aboutsummaryrefslogtreecommitdiff
path: root/internal/cvss/v30vector_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 /internal/cvss/v30vector_test.go
parent92400d731546557d110c9c3cc3906d700f83dda8 (diff)
downloadcvez-9c17b97cd0f83be3fff9fa4e87fd1d29052ea616.tar.bz2
cvez-9c17b97cd0f83be3fff9fa4e87fd1d29052ea616.zip
rename to github.com/pablotron/cvez, remove internal libs
Diffstat (limited to 'internal/cvss/v30vector_test.go')
-rw-r--r--internal/cvss/v30vector_test.go69
1 files changed, 0 insertions, 69 deletions
diff --git a/internal/cvss/v30vector_test.go b/internal/cvss/v30vector_test.go
deleted file mode 100644
index 1d44d35..0000000
--- a/internal/cvss/v30vector_test.go
+++ /dev/null
@@ -1,69 +0,0 @@
-package cvss
-
-import (
- "testing"
-)
-
-func TestNewV30Vector(t *testing.T) {
- passTests := []struct {
- val string
- exp []string
- } {
- {
- val: "CVSS:3.0/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:N/A:N",
- exp: []string { "AV:L", "AC:H", "PR:L", "UI:N", "S:U", "C:H", "I:N", "A:N" },
- },
- }
-
- for _, test := range(passTests) {
- t.Run(test.val, func(t *testing.T) {
- // parse vector
- vec, err := newV30Vector(test.val)
- if err != nil {
- t.Error(err)
- return
- }
-
- // check version
- if vec.Version() != V30 {
- t.Errorf("got %s, exp %s", vec.Version(), V30)
- return
- }
-
- // check metric length
- if len(vec.Metrics()) != len(test.exp) {
- t.Errorf("got %d, exp %d", len(vec.Metrics()), len(test.exp))
- return
- }
-
- // check metrics
- for i, m := range(vec.Metrics()) {
- got := m.String()
- if got != test.exp[i] {
- t.Errorf("got %s, exp %s", got, test.exp[i])
- }
- }
- })
- }
-
- failTests := []struct {
- val string
- exp string
- } {
- {
- val: "CVSS:3.0/AV:L/junk/PR:L/UI:N/S:U/C:H/I:N/A:N",
- exp: "invalid CVSS 3.0 metric: junk",
- },
- }
-
- for _, test := range(failTests) {
- t.Run(test.val, func(t *testing.T) {
- got, err := newV30Vector(test.val)
- if err != nil && err.Error() != test.exp {
- t.Errorf("got \"%s\", exp \"%s\"", err.Error(), test.exp)
- } else if err == nil {
- t.Errorf("got \"%s\", exp badMetric", got)
- }
- })
- }
-}