/* Vuls - Vulnerability Scanner Copyright (C) 2016 Future Architect, Inc. Japan. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ package oval import "testing" func TestParseCvss2(t *testing.T) { type out struct { score float64 vector string } var tests = []struct { in string out out }{ { in: "5/AV:N/AC:L/Au:N/C:N/I:N/A:P", out: out{ score: 5.0, vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P", }, }, { in: "", out: out{ score: 0, vector: "", }, }, } for _, tt := range tests { s, v := RedHatBase{}.parseCvss2(tt.in) if s != tt.out.score || v != tt.out.vector { t.Errorf("\nexpected: %f, %s\n actual: %f, %s", tt.out.score, tt.out.vector, s, v) } } } func TestParseCvss3(t *testing.T) { type out struct { score float64 vector string } var tests = []struct { in string out out }{ { in: "5.6/CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L", out: out{ score: 5.6, vector: "AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L", }, }, { in: "", out: out{ score: 0, vector: "", }, }, } for _, tt := range tests { s, v := RedHatBase{}.parseCvss3(tt.in) if s != tt.out.score || v != tt.out.vector { t.Errorf("\nexpected: %f, %s\n actual: %f, %s", tt.out.score, tt.out.vector, s, v) } } }