mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +08:00
Fixes issue #132, if image does not have any fixed tags, empty list with no error should be returned
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user