mirror of
https://github.com/kubescape/kubescape.git
synced 2026-02-14 09:59:54 +00:00
62 lines
1.1 KiB
Go
62 lines
1.1 KiB
Go
package shared
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/kubescape/kubescape/v3/core/cautils"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// Validate a scanInfo struct with a valid fail threshold severity
|
|
func TestValidateImageScanInfo(t *testing.T) {
|
|
testCases := []struct {
|
|
Description string
|
|
ScanInfo *cautils.ScanInfo
|
|
Want error
|
|
}{
|
|
{
|
|
"Empty scanInfo is valid",
|
|
&cautils.ScanInfo{},
|
|
nil,
|
|
},
|
|
{
|
|
"Empty severity is valid",
|
|
&cautils.ScanInfo{FailThresholdSeverity: ""},
|
|
nil,
|
|
},
|
|
{
|
|
"High severity is valid",
|
|
&cautils.ScanInfo{FailThresholdSeverity: "High"},
|
|
nil,
|
|
},
|
|
{
|
|
"HIGH severity is valid",
|
|
&cautils.ScanInfo{FailThresholdSeverity: "HIGH"},
|
|
nil,
|
|
},
|
|
{
|
|
"high severity is valid",
|
|
&cautils.ScanInfo{FailThresholdSeverity: "high"},
|
|
nil,
|
|
},
|
|
{
|
|
"Unknown severity is invalid",
|
|
&cautils.ScanInfo{FailThresholdSeverity: "unknown"},
|
|
ErrUnknownSeverity,
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
t.Run(
|
|
tc.Description,
|
|
func(t *testing.T) {
|
|
var want = tc.Want
|
|
|
|
got := ValidateImageScanInfo(tc.ScanInfo)
|
|
|
|
assert.Equal(t, want, got)
|
|
},
|
|
)
|
|
}
|
|
}
|