2023-08-30 12:12:24 -05:00
|
|
|
//go:build search
|
|
|
|
// +build search
|
|
|
|
|
2023-10-03 13:15:39 -05:00
|
|
|
package client_test
|
2023-08-30 12:12:24 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
|
|
|
2024-01-31 23:34:07 -05:00
|
|
|
"zotregistry.dev/zot/pkg/api"
|
|
|
|
"zotregistry.dev/zot/pkg/api/config"
|
|
|
|
"zotregistry.dev/zot/pkg/cli/client"
|
|
|
|
extconf "zotregistry.dev/zot/pkg/extensions/config"
|
|
|
|
test "zotregistry.dev/zot/pkg/test/common"
|
2023-08-30 12:12:24 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestGQLQueries(t *testing.T) {
|
|
|
|
port := test.GetFreePort()
|
|
|
|
baseURL := test.GetBaseURL(port)
|
|
|
|
conf := config.New()
|
|
|
|
conf.HTTP.Port = port
|
|
|
|
dir := t.TempDir()
|
|
|
|
conf.Storage.RootDirectory = dir
|
|
|
|
defaultVal := true
|
|
|
|
conf.Extensions = &extconf.ExtensionConfig{
|
|
|
|
Search: &extconf.SearchConfig{
|
|
|
|
BaseConfig: extconf.BaseConfig{Enable: &defaultVal},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
ctlr := api.NewController(conf)
|
|
|
|
|
|
|
|
cm := test.NewControllerManager(ctlr)
|
|
|
|
cm.StartAndWait(conf.HTTP.Port)
|
|
|
|
|
|
|
|
defer cm.StopServer()
|
|
|
|
|
2023-10-03 13:15:39 -05:00
|
|
|
searchConfig := client.SearchConfig{
|
|
|
|
ServURL: baseURL,
|
|
|
|
User: "",
|
|
|
|
VerifyTLS: false,
|
|
|
|
Debug: false,
|
|
|
|
ResultWriter: io.Discard,
|
2023-08-30 12:12:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Convey("Make sure the current CLI used the right queries in case they change", t, func() {
|
|
|
|
Convey("ImageList", func() {
|
2023-10-03 13:15:39 -05:00
|
|
|
err := client.CheckExtEndPointQuery(searchConfig, client.ImageListQuery())
|
2023-08-30 12:12:24 -05:00
|
|
|
So(err, ShouldBeNil)
|
|
|
|
})
|
|
|
|
|
|
|
|
Convey("ImageListForDigest", func() {
|
2023-10-03 13:15:39 -05:00
|
|
|
err := client.CheckExtEndPointQuery(searchConfig, client.ImageListForDigestQuery())
|
2023-08-30 12:12:24 -05:00
|
|
|
So(err, ShouldBeNil)
|
|
|
|
})
|
|
|
|
|
|
|
|
Convey("BaseImageList", func() {
|
2023-10-03 13:15:39 -05:00
|
|
|
err := client.CheckExtEndPointQuery(searchConfig, client.BaseImageListQuery())
|
2023-08-30 12:12:24 -05:00
|
|
|
So(err, ShouldBeNil)
|
|
|
|
})
|
|
|
|
|
|
|
|
Convey("DerivedImageList", func() {
|
2023-10-03 13:15:39 -05:00
|
|
|
err := client.CheckExtEndPointQuery(searchConfig, client.DerivedImageListQuery())
|
2023-08-30 12:12:24 -05:00
|
|
|
So(err, ShouldBeNil)
|
|
|
|
})
|
|
|
|
|
|
|
|
Convey("CVEListForImage", func() {
|
2023-10-03 13:15:39 -05:00
|
|
|
err := client.CheckExtEndPointQuery(searchConfig, client.CVEListForImageQuery())
|
2023-08-30 12:12:24 -05:00
|
|
|
So(err, ShouldBeNil)
|
|
|
|
})
|
|
|
|
|
|
|
|
Convey("ImageListForCVE", func() {
|
2023-10-03 13:15:39 -05:00
|
|
|
err := client.CheckExtEndPointQuery(searchConfig, client.ImageListForCVEQuery())
|
2023-08-30 12:12:24 -05:00
|
|
|
So(err, ShouldBeNil)
|
|
|
|
})
|
|
|
|
|
|
|
|
Convey("ImageListWithCVEFixed", func() {
|
2023-10-03 13:15:39 -05:00
|
|
|
err := client.CheckExtEndPointQuery(searchConfig, client.ImageListWithCVEFixedQuery())
|
2023-08-30 12:12:24 -05:00
|
|
|
So(err, ShouldBeNil)
|
|
|
|
})
|
|
|
|
|
|
|
|
Convey("Referrers", func() {
|
2023-10-03 13:15:39 -05:00
|
|
|
err := client.CheckExtEndPointQuery(searchConfig, client.ReferrersQuery())
|
2023-08-30 12:12:24 -05:00
|
|
|
So(err, ShouldBeNil)
|
|
|
|
})
|
|
|
|
|
|
|
|
Convey("GlobalSearch", func() {
|
2023-10-03 13:15:39 -05:00
|
|
|
err := client.CheckExtEndPointQuery(searchConfig, client.GlobalSearchQuery())
|
2023-08-30 12:12:24 -05:00
|
|
|
So(err, ShouldBeNil)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|