Fixes issue #132, if image does not have any fixed tags, empty list with no error should be returned

This commit is contained in:
Shivam Mishra
2020-09-04 15:02:10 -07:00
parent aa6683854f
commit cd0206fe6c
5 changed files with 44 additions and 11 deletions
+17
View File
@@ -427,6 +427,23 @@ func TestServerCVEResponse(t *testing.T) {
So(err, ShouldBeNil)
So(str, ShouldEqual, "")
})
Convey("invalid image", func() {
args := []string{"cvetest", "--cve-id", "CVE-2019-20807", "--image", "zot-cv-test", "--fixed"}
configPath := makeConfigFile(fmt.Sprintf(`{"configs":[{"_name":"cvetest","url":"%s","showspinner":false}]}`, url))
defer os.Remove(configPath)
cveCmd := NewCveCommand(new(searchService))
buff := bytes.NewBufferString("")
cveCmd.SetOut(buff)
cveCmd.SetErr(ioutil.Discard)
cveCmd.SetArgs(args)
err := cveCmd.Execute()
space := regexp.MustCompile(`\s+`)
str := space.ReplaceAllString(buff.String(), " ")
str = strings.TrimSpace(str)
So(err, ShouldNotBeNil)
So(strings.TrimSpace(str), ShouldNotContainSubstring, "IMAGE NAME TAG DIGEST SIZE")
})
})
Convey("Test CVE by name and CVE ID", t, func() {
-7
View File
@@ -394,12 +394,6 @@ func (service searchService) getFixedTagsForCVE(ctx context.Context, config sear
var errBuilder strings.Builder
for _, err := range result.Errors {
if err.Message == zotErrors.ErrFixedTagNotFound.Error() {
// this if block and goto should be removed when the server API is fixed.
// currently, the API returns an error if the data is empty and we are ignoring that error here
goto Outside
}
fmt.Fprintln(&errBuilder, err.Message)
}
@@ -411,7 +405,6 @@ func (service searchService) getFixedTagsForCVE(ctx context.Context, config sear
return
}
Outside:
var localWg sync.WaitGroup
p := newSmoothRateLimiter(ctx, &localWg, c)