@@ -297,6 +297,43 @@ func TestScanWithFailOnBadValue(t *testing.T) {
297297 Err : "--fail-on takes only 'all', 'upgradable' or 'patchable' values" })
298298}
299299
300+ func TestScanWithSeverity (t * testing.T ) {
301+ if runtime .GOOS == "windows" || runtime .GOOS == "darwin" {
302+ t .Skip ("Can't run on this ci platform (windows containers or no engine installed)" )
303+ }
304+ _ , cleanFunction := createSnykConfFile (t , os .Getenv ("E2E_TEST_AUTH_TOKEN" ))
305+ defer cleanFunction ()
306+
307+ cmd , configDir , cleanup := dockerCli .createTestCmd ()
308+ defer cleanup ()
309+
310+ createScanConfigFile (t , configDir )
311+
312+ cmd .Command = dockerCli .Command ("scan" , "--accept-license" , "--severity=medium" , ImageWithVulnerabilities )
313+ output := icmd .RunCmd (cmd ).Assert (t , icmd.Expected {ExitCode : 1 }).Combined ()
314+ assert .Assert (t , strings .Contains (output , "alpine:3.10.0" )) // beginning of the dependency tree
315+ assert .Assert (t , cmp .Regexp ("found .* issues" , output ))
316+ assert .Assert (t , ! strings .Contains (output , "Low severity" ))
317+ }
318+
319+ func TestScanWithSeverityBadValue (t * testing.T ) {
320+ if runtime .GOOS == "windows" || runtime .GOOS == "darwin" {
321+ t .Skip ("Can't run on this ci platform (windows containers or no engine installed)" )
322+ }
323+ _ , cleanFunction := createSnykConfFile (t , os .Getenv ("E2E_TEST_AUTH_TOKEN" ))
324+ defer cleanFunction ()
325+
326+ cmd , configDir , cleanup := dockerCli .createTestCmd ()
327+ defer cleanup ()
328+
329+ createScanConfigFile (t , configDir )
330+
331+ cmd .Command = dockerCli .Command ("scan" , "--accept-license" , "--severity=unsupportedValue" , ImageWithVulnerabilities )
332+ icmd .RunCmd (cmd ).Assert (t , icmd.Expected {
333+ ExitCode : 1 ,
334+ Err : "--severity takes only 'low', 'medium' or 'high' values" })
335+ }
336+
300337func createSnykConfFile (t * testing.T , token string ) (* fs.Dir , func ()) {
301338 content := fmt .Sprintf (`{"api" : "%s"}` , token )
302339 homeDir := fs .NewDir (t , t .Name (),
0 commit comments