@@ -261,6 +261,42 @@ func TestScanWithDependencies(t *testing.T) {
261261 assert .Assert (t , strings .Contains (output , "vulnerability found" ))
262262}
263263
264+ func TestScanWithFailOn (t * testing.T ) {
265+ if runtime .GOOS == "windows" || runtime .GOOS == "darwin" {
266+ t .Skip ("Can't run on this ci platform (windows containers or no engine installed)" )
267+ }
268+ _ , cleanFunction := createSnykConfFile (t , os .Getenv ("E2E_TEST_AUTH_TOKEN" ))
269+ defer cleanFunction ()
270+
271+ cmd , configDir , cleanup := dockerCli .createTestCmd ()
272+ defer cleanup ()
273+
274+ createScanConfigFile (t , configDir )
275+
276+ cmd .Command = dockerCli .Command ("scan" , "--accept-license" , "--fail-on" , "upgradable" , ImageWithVulnerabilities )
277+ output := icmd .RunCmd (cmd ).Assert (t , icmd.Expected {ExitCode : 0 }).Combined ()
278+ assert .Assert (t , strings .Contains (output , "alpine:3.10.0" )) // beginning of the dependency tree
279+ assert .Assert (t , cmp .Regexp ("found .* issues" , output ))
280+ }
281+
282+ func TestScanWithFailOnBadValue (t * testing.T ) {
283+ if runtime .GOOS == "windows" || runtime .GOOS == "darwin" {
284+ t .Skip ("Can't run on this ci platform (windows containers or no engine installed)" )
285+ }
286+ _ , cleanFunction := createSnykConfFile (t , os .Getenv ("E2E_TEST_AUTH_TOKEN" ))
287+ defer cleanFunction ()
288+
289+ cmd , configDir , cleanup := dockerCli .createTestCmd ()
290+ defer cleanup ()
291+
292+ createScanConfigFile (t , configDir )
293+
294+ cmd .Command = dockerCli .Command ("scan" , "--accept-license" , "--fail-on" , "unsupportedValue" , ImageWithVulnerabilities )
295+ icmd .RunCmd (cmd ).Assert (t , icmd.Expected {
296+ ExitCode : 1 ,
297+ Err : "--fail-on takes only 'all', 'upgradable' or 'patchable' values" })
298+ }
299+
264300func createSnykConfFile (t * testing.T , token string ) (* fs.Dir , func ()) {
265301 content := fmt .Sprintf (`{"api" : "%s"}` , token )
266302 homeDir := fs .NewDir (t , t .Name (),
0 commit comments