2021-12-03 22:50:58 -05:00
|
|
|
//go:build extended
|
2021-10-15 10:05:00 -05:00
|
|
|
// +build extended
|
|
|
|
|
2021-05-26 12:22:31 -05:00
|
|
|
// nolint: gochecknoinits
|
|
|
|
package digestinfo_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"encoding/json"
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
|
|
"gopkg.in/resty.v1"
|
2021-12-03 22:50:58 -05:00
|
|
|
"zotregistry.io/zot/pkg/api"
|
|
|
|
"zotregistry.io/zot/pkg/api/config"
|
|
|
|
extconf "zotregistry.io/zot/pkg/extensions/config"
|
|
|
|
"zotregistry.io/zot/pkg/extensions/monitoring"
|
|
|
|
digestinfo "zotregistry.io/zot/pkg/extensions/search/digest"
|
|
|
|
"zotregistry.io/zot/pkg/log"
|
|
|
|
"zotregistry.io/zot/pkg/storage"
|
2022-01-19 14:54:17 -05:00
|
|
|
. "zotregistry.io/zot/pkg/test"
|
2021-05-26 12:22:31 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// nolint:gochecknoglobals
|
|
|
|
var (
|
|
|
|
digestInfo *digestinfo.DigestInfo
|
|
|
|
rootDir string
|
2021-09-30 08:27:13 -05:00
|
|
|
subRootDir string
|
2021-05-26 12:22:31 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type ImgResponseForDigest struct {
|
|
|
|
ImgListForDigest ImgListForDigest `json:"data"`
|
|
|
|
Errors []ErrorGQL `json:"errors"`
|
|
|
|
}
|
|
|
|
|
2021-12-13 14:23:31 -05:00
|
|
|
//nolint:tagliatelle // graphQL schema
|
2021-05-26 12:22:31 -05:00
|
|
|
type ImgListForDigest struct {
|
|
|
|
Images []ImgInfo `json:"ImageListForDigest"`
|
|
|
|
}
|
|
|
|
|
2021-12-13 14:23:31 -05:00
|
|
|
//nolint:tagliatelle // graphQL schema
|
2021-05-26 12:22:31 -05:00
|
|
|
type ImgInfo struct {
|
|
|
|
Name string `json:"Name"`
|
|
|
|
Tags []string `json:"Tags"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ErrorGQL struct {
|
|
|
|
Message string `json:"message"`
|
|
|
|
Path []string `json:"path"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2021-12-13 14:23:31 -05:00
|
|
|
if err := testSetup(); err != nil {
|
2021-05-26 12:22:31 -05:00
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func testSetup() error {
|
|
|
|
dir, err := ioutil.TempDir("", "digest_test")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-09-30 08:27:13 -05:00
|
|
|
subDir, err := ioutil.TempDir("", "sub_digest_test")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-05-26 12:22:31 -05:00
|
|
|
rootDir = dir
|
|
|
|
|
2021-09-30 08:27:13 -05:00
|
|
|
subRootDir = subDir
|
|
|
|
|
2021-05-26 12:22:31 -05:00
|
|
|
// Test images used/copied:
|
|
|
|
// IMAGE NAME TAG DIGEST CONFIG LAYERS SIZE
|
|
|
|
// zot-test 0.0.1 2bacca16 adf3bb6c 76MB
|
|
|
|
// 2d473b07 76MB
|
|
|
|
// zot-cve-test 0.0.1 63a795ca 8dd57e17 75MB
|
|
|
|
// 7a0437f0 75MB
|
|
|
|
|
2021-12-13 14:23:31 -05:00
|
|
|
err = os.Mkdir(subDir+"/a", 0o700)
|
2021-09-30 08:27:13 -05:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-11-10 09:31:03 -05:00
|
|
|
err = CopyFiles("../../../../test/data", rootDir)
|
2021-05-26 12:22:31 -05:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-11-10 09:31:03 -05:00
|
|
|
err = CopyFiles("../../../../test/data", subDir+"/a/")
|
2021-09-30 08:27:13 -05:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-05-26 12:22:31 -05:00
|
|
|
log := log.NewLogger("debug", "")
|
2021-10-15 10:05:00 -05:00
|
|
|
metrics := monitoring.NewMetricsServer(false, log)
|
2022-01-20 23:11:44 -05:00
|
|
|
storeController := storage.StoreController{
|
2022-02-09 19:51:35 -05:00
|
|
|
DefaultStore: storage.NewImageStore(rootDir, false, storage.DefaultGCDelay, false, false, log, metrics),
|
2022-01-20 23:11:44 -05:00
|
|
|
}
|
2021-09-30 08:27:13 -05:00
|
|
|
|
|
|
|
digestInfo = digestinfo.NewDigestInfo(storeController, log)
|
2021-05-26 12:22:31 -05:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDigestInfo(t *testing.T) {
|
|
|
|
Convey("Test image tag", t, func() {
|
|
|
|
// Search by manifest digest
|
2021-09-30 08:27:13 -05:00
|
|
|
imageTags, err := digestInfo.GetImageTagsByDigest("zot-cve-test", "63a795ca")
|
2021-05-26 12:22:31 -05:00
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(len(imageTags), ShouldEqual, 1)
|
|
|
|
So(*imageTags[0], ShouldEqual, "0.0.1")
|
|
|
|
|
|
|
|
// Search by config digest
|
2021-09-30 08:27:13 -05:00
|
|
|
imageTags, err = digestInfo.GetImageTagsByDigest("zot-test", "adf3bb6c")
|
2021-05-26 12:22:31 -05:00
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(len(imageTags), ShouldEqual, 1)
|
|
|
|
So(*imageTags[0], ShouldEqual, "0.0.1")
|
|
|
|
|
|
|
|
// Search by layer digest
|
2021-09-30 08:27:13 -05:00
|
|
|
imageTags, err = digestInfo.GetImageTagsByDigest("zot-cve-test", "7a0437f0")
|
2021-05-26 12:22:31 -05:00
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(len(imageTags), ShouldEqual, 1)
|
|
|
|
So(*imageTags[0], ShouldEqual, "0.0.1")
|
|
|
|
|
|
|
|
// Search by non-existent image
|
2021-09-30 08:27:13 -05:00
|
|
|
imageTags, err = digestInfo.GetImageTagsByDigest("zot-tes", "63a795ca")
|
2021-05-26 12:22:31 -05:00
|
|
|
So(err, ShouldNotBeNil)
|
|
|
|
So(len(imageTags), ShouldEqual, 0)
|
|
|
|
|
|
|
|
// Search by non-existent digest
|
2021-09-30 08:27:13 -05:00
|
|
|
imageTags, err = digestInfo.GetImageTagsByDigest("zot-test", "111")
|
2021-05-26 12:22:31 -05:00
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(len(imageTags), ShouldEqual, 0)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDigestSearchHTTP(t *testing.T) {
|
|
|
|
Convey("Test image search by digest scanning", t, func() {
|
2021-11-10 09:31:03 -05:00
|
|
|
port := GetFreePort()
|
|
|
|
baseURL := GetBaseURL(port)
|
2021-06-08 15:11:18 -05:00
|
|
|
conf := config.New()
|
2021-11-10 09:31:03 -05:00
|
|
|
conf.HTTP.Port = port
|
2021-06-08 15:11:18 -05:00
|
|
|
conf.Storage.RootDirectory = rootDir
|
2021-12-28 08:29:30 -05:00
|
|
|
defaultVal := true
|
2021-06-08 15:11:18 -05:00
|
|
|
conf.Extensions = &extconf.ExtensionConfig{
|
2021-12-28 08:29:30 -05:00
|
|
|
Search: &extconf.SearchConfig{Enable: &defaultVal},
|
2021-05-26 12:22:31 -05:00
|
|
|
}
|
|
|
|
|
2021-12-13 14:23:31 -05:00
|
|
|
ctlr := api.NewController(conf)
|
2021-05-26 12:22:31 -05:00
|
|
|
|
|
|
|
go func() {
|
|
|
|
// this blocks
|
2021-12-13 14:23:31 -05:00
|
|
|
if err := ctlr.Run(); err != nil {
|
2021-05-26 12:22:31 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
// wait till ready
|
|
|
|
for {
|
2021-11-10 09:31:03 -05:00
|
|
|
_, err := resty.R().Get(baseURL)
|
2021-05-26 12:22:31 -05:00
|
|
|
if err == nil {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
time.Sleep(100 * time.Millisecond)
|
|
|
|
}
|
|
|
|
|
|
|
|
// shut down server
|
|
|
|
defer func() {
|
|
|
|
ctx := context.Background()
|
2021-12-13 14:23:31 -05:00
|
|
|
_ = ctlr.Server.Shutdown(ctx)
|
2021-05-26 12:22:31 -05:00
|
|
|
}()
|
|
|
|
|
2021-11-10 09:31:03 -05:00
|
|
|
resp, err := resty.R().Get(baseURL + "/v2/")
|
2021-05-26 12:22:31 -05:00
|
|
|
So(resp, ShouldNotBeNil)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(resp.StatusCode(), ShouldEqual, 200)
|
|
|
|
|
2021-11-10 09:31:03 -05:00
|
|
|
resp, err = resty.R().Get(baseURL + "/query")
|
2021-05-26 12:22:31 -05:00
|
|
|
So(resp, ShouldNotBeNil)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(resp.StatusCode(), ShouldEqual, 200)
|
|
|
|
|
|
|
|
// "sha" should match all digests in all images
|
2021-11-10 09:31:03 -05:00
|
|
|
resp, err = resty.R().Get(baseURL + "/query?query={ImageListForDigest(id:\"sha\"){Name%20Tags}}")
|
2021-05-26 12:22:31 -05:00
|
|
|
So(resp, ShouldNotBeNil)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(resp.StatusCode(), ShouldEqual, 200)
|
|
|
|
|
|
|
|
var responseStruct ImgResponseForDigest
|
|
|
|
err = json.Unmarshal(resp.Body(), &responseStruct)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(len(responseStruct.Errors), ShouldEqual, 0)
|
|
|
|
So(len(responseStruct.ImgListForDigest.Images), ShouldEqual, 2)
|
|
|
|
So(len(responseStruct.ImgListForDigest.Images[0].Tags), ShouldEqual, 1)
|
|
|
|
So(len(responseStruct.ImgListForDigest.Images[0].Tags), ShouldEqual, 1)
|
|
|
|
|
|
|
|
// Call should return {"data":{"ImageListForDigest":[{"Name":"zot-test","Tags":["0.0.1"]}]}}
|
|
|
|
// "2bacca16" should match the manifest of 1 image
|
2021-11-10 09:31:03 -05:00
|
|
|
resp, err = resty.R().Get(baseURL + "/query?query={ImageListForDigest(id:\"2bacca16\"){Name%20Tags}}")
|
2021-05-26 12:22:31 -05:00
|
|
|
So(resp, ShouldNotBeNil)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(resp.StatusCode(), ShouldEqual, 200)
|
|
|
|
|
|
|
|
err = json.Unmarshal(resp.Body(), &responseStruct)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(len(responseStruct.Errors), ShouldEqual, 0)
|
|
|
|
So(len(responseStruct.ImgListForDigest.Images), ShouldEqual, 1)
|
|
|
|
So(responseStruct.ImgListForDigest.Images[0].Name, ShouldEqual, "zot-test")
|
|
|
|
So(len(responseStruct.ImgListForDigest.Images[0].Tags), ShouldEqual, 1)
|
|
|
|
So(responseStruct.ImgListForDigest.Images[0].Tags[0], ShouldEqual, "0.0.1")
|
|
|
|
|
|
|
|
// Call should return {"data":{"ImageListForDigest":[{"Name":"zot-test","Tags":["0.0.1"]}]}}
|
|
|
|
// "adf3bb6c" should match the config of 1 image
|
2021-11-10 09:31:03 -05:00
|
|
|
resp, err = resty.R().Get(baseURL + "/query?query={ImageListForDigest(id:\"adf3bb6c\"){Name%20Tags}}")
|
2021-05-26 12:22:31 -05:00
|
|
|
So(resp, ShouldNotBeNil)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(resp.StatusCode(), ShouldEqual, 200)
|
|
|
|
|
|
|
|
err = json.Unmarshal(resp.Body(), &responseStruct)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(len(responseStruct.Errors), ShouldEqual, 0)
|
|
|
|
So(len(responseStruct.ImgListForDigest.Images), ShouldEqual, 1)
|
|
|
|
So(responseStruct.ImgListForDigest.Images[0].Name, ShouldEqual, "zot-test")
|
|
|
|
So(len(responseStruct.ImgListForDigest.Images[0].Tags), ShouldEqual, 1)
|
|
|
|
So(responseStruct.ImgListForDigest.Images[0].Tags[0], ShouldEqual, "0.0.1")
|
|
|
|
|
|
|
|
// Call should return {"data":{"ImageListForDigest":[{"Name":"zot-cve-test","Tags":["0.0.1"]}]}}
|
|
|
|
// "7a0437f0" should match the layer of 1 image
|
2021-11-10 09:31:03 -05:00
|
|
|
resp, err = resty.R().Get(baseURL + "/query?query={ImageListForDigest(id:\"7a0437f0\"){Name%20Tags}}")
|
2021-05-26 12:22:31 -05:00
|
|
|
So(resp, ShouldNotBeNil)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(resp.StatusCode(), ShouldEqual, 200)
|
|
|
|
|
|
|
|
err = json.Unmarshal(resp.Body(), &responseStruct)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(len(responseStruct.Errors), ShouldEqual, 0)
|
|
|
|
So(len(responseStruct.ImgListForDigest.Images), ShouldEqual, 1)
|
|
|
|
So(responseStruct.ImgListForDigest.Images[0].Name, ShouldEqual, "zot-cve-test")
|
|
|
|
So(len(responseStruct.ImgListForDigest.Images[0].Tags), ShouldEqual, 1)
|
|
|
|
So(responseStruct.ImgListForDigest.Images[0].Tags[0], ShouldEqual, "0.0.1")
|
|
|
|
|
|
|
|
// Call should return {"data":{"ImageListForDigest":[]}}
|
|
|
|
// "1111111" should match 0 images
|
2021-11-10 09:31:03 -05:00
|
|
|
resp, err = resty.R().Get(baseURL + "/query?query={ImageListForDigest(id:\"1111111\"){Name%20Tags}}")
|
2021-05-26 12:22:31 -05:00
|
|
|
So(resp, ShouldNotBeNil)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(resp.StatusCode(), ShouldEqual, 200)
|
|
|
|
|
|
|
|
err = json.Unmarshal(resp.Body(), &responseStruct)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(len(responseStruct.Errors), ShouldEqual, 0)
|
|
|
|
So(len(responseStruct.ImgListForDigest.Images), ShouldEqual, 0)
|
|
|
|
|
|
|
|
// Call should return {"errors": [{....}]", data":null}}
|
2021-11-10 09:31:03 -05:00
|
|
|
resp, err = resty.R().Get(baseURL + "/query?query={ImageListForDigest(id:\"1111111\"){Name%20Tag343s}}")
|
2021-05-26 12:22:31 -05:00
|
|
|
So(resp, ShouldNotBeNil)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(resp.StatusCode(), ShouldEqual, 422)
|
|
|
|
|
|
|
|
err = json.Unmarshal(resp.Body(), &responseStruct)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(len(responseStruct.Errors), ShouldEqual, 1)
|
2021-09-30 08:27:13 -05:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDigestSearchHTTPSubPaths(t *testing.T) {
|
|
|
|
Convey("Test image search by digest scanning using storage subpaths", t, func() {
|
2021-11-10 09:31:03 -05:00
|
|
|
port := GetFreePort()
|
|
|
|
baseURL := GetBaseURL(port)
|
2021-06-08 15:11:18 -05:00
|
|
|
conf := config.New()
|
2021-11-10 09:31:03 -05:00
|
|
|
conf.HTTP.Port = port
|
2021-12-28 08:29:30 -05:00
|
|
|
defaultVal := true
|
2021-06-08 15:11:18 -05:00
|
|
|
conf.Extensions = &extconf.ExtensionConfig{
|
2021-12-28 08:29:30 -05:00
|
|
|
Search: &extconf.SearchConfig{Enable: &defaultVal},
|
2021-09-30 08:27:13 -05:00
|
|
|
}
|
|
|
|
|
2021-12-13 14:23:31 -05:00
|
|
|
ctlr := api.NewController(conf)
|
2021-09-30 08:27:13 -05:00
|
|
|
|
|
|
|
globalDir, err := ioutil.TempDir("", "digest_test")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer os.RemoveAll(globalDir)
|
|
|
|
|
2021-12-13 14:23:31 -05:00
|
|
|
ctlr.Config.Storage.RootDirectory = globalDir
|
2021-09-30 08:27:13 -05:00
|
|
|
|
2021-06-08 15:11:18 -05:00
|
|
|
subPathMap := make(map[string]config.StorageConfig)
|
2021-09-30 08:27:13 -05:00
|
|
|
|
2021-06-08 15:11:18 -05:00
|
|
|
subPathMap["/a"] = config.StorageConfig{RootDirectory: subRootDir}
|
2021-09-30 08:27:13 -05:00
|
|
|
|
2021-12-13 14:23:31 -05:00
|
|
|
ctlr.Config.Storage.SubPaths = subPathMap
|
2021-09-30 08:27:13 -05:00
|
|
|
|
|
|
|
go func() {
|
|
|
|
// this blocks
|
2021-12-13 14:23:31 -05:00
|
|
|
if err := ctlr.Run(); err != nil {
|
2021-09-30 08:27:13 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
// wait till ready
|
|
|
|
for {
|
2021-11-10 09:31:03 -05:00
|
|
|
_, err := resty.R().Get(baseURL)
|
2021-09-30 08:27:13 -05:00
|
|
|
if err == nil {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
time.Sleep(100 * time.Millisecond)
|
|
|
|
}
|
|
|
|
|
|
|
|
// shut down server
|
|
|
|
defer func() {
|
|
|
|
ctx := context.Background()
|
2021-12-13 14:23:31 -05:00
|
|
|
_ = ctlr.Server.Shutdown(ctx)
|
2021-09-30 08:27:13 -05:00
|
|
|
}()
|
|
|
|
|
2021-11-10 09:31:03 -05:00
|
|
|
resp, err := resty.R().Get(baseURL + "/v2/")
|
2021-09-30 08:27:13 -05:00
|
|
|
So(resp, ShouldNotBeNil)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(resp.StatusCode(), ShouldEqual, 200)
|
|
|
|
|
2021-11-10 09:31:03 -05:00
|
|
|
resp, err = resty.R().Get(baseURL + "/query")
|
2021-09-30 08:27:13 -05:00
|
|
|
So(resp, ShouldNotBeNil)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(resp.StatusCode(), ShouldEqual, 200)
|
|
|
|
|
2021-11-10 09:31:03 -05:00
|
|
|
resp, err = resty.R().Get(baseURL + "/query?query={ImageListForDigest(id:\"sha\"){Name%20Tags}}")
|
2021-09-30 08:27:13 -05:00
|
|
|
So(resp, ShouldNotBeNil)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(resp.StatusCode(), ShouldEqual, 200)
|
|
|
|
|
|
|
|
var responseStruct ImgResponseForDigest
|
|
|
|
err = json.Unmarshal(resp.Body(), &responseStruct)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(len(responseStruct.Errors), ShouldEqual, 0)
|
|
|
|
So(len(responseStruct.ImgListForDigest.Images), ShouldEqual, 2)
|
2021-05-26 12:22:31 -05:00
|
|
|
})
|
|
|
|
}
|
2021-06-08 13:37:31 -05:00
|
|
|
|
|
|
|
func TestDigestSearchDisabled(t *testing.T) {
|
|
|
|
Convey("Test disabling image search", t, func() {
|
2021-12-28 08:29:30 -05:00
|
|
|
var disabled bool
|
2021-06-08 13:37:31 -05:00
|
|
|
dir, err := ioutil.TempDir("", "digest_test")
|
|
|
|
So(err, ShouldBeNil)
|
2021-11-10 09:31:03 -05:00
|
|
|
port := GetFreePort()
|
|
|
|
baseURL := GetBaseURL(port)
|
2021-06-08 15:11:18 -05:00
|
|
|
conf := config.New()
|
2021-11-10 09:31:03 -05:00
|
|
|
conf.HTTP.Port = port
|
2021-06-08 15:11:18 -05:00
|
|
|
conf.Storage.RootDirectory = dir
|
|
|
|
conf.Extensions = &extconf.ExtensionConfig{
|
2021-12-28 08:29:30 -05:00
|
|
|
Search: &extconf.SearchConfig{Enable: &disabled},
|
2021-06-08 13:37:31 -05:00
|
|
|
}
|
|
|
|
|
2021-12-13 14:23:31 -05:00
|
|
|
ctlr := api.NewController(conf)
|
2021-06-08 13:37:31 -05:00
|
|
|
|
|
|
|
go func() {
|
|
|
|
// this blocks
|
2021-12-13 14:23:31 -05:00
|
|
|
if err := ctlr.Run(); err != nil {
|
2021-06-08 13:37:31 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
// wait till ready
|
|
|
|
for {
|
2021-11-10 09:31:03 -05:00
|
|
|
_, err := resty.R().Get(baseURL)
|
2021-06-08 13:37:31 -05:00
|
|
|
if err == nil {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
time.Sleep(100 * time.Millisecond)
|
|
|
|
}
|
|
|
|
|
|
|
|
// shut down server
|
|
|
|
defer func() {
|
|
|
|
ctx := context.Background()
|
2021-12-13 14:23:31 -05:00
|
|
|
_ = ctlr.Server.Shutdown(ctx)
|
2021-06-08 13:37:31 -05:00
|
|
|
}()
|
|
|
|
|
2021-11-10 09:31:03 -05:00
|
|
|
resp, err := resty.R().Get(baseURL + "/v2/")
|
2021-06-08 13:37:31 -05:00
|
|
|
So(resp, ShouldNotBeNil)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(resp.StatusCode(), ShouldEqual, 200)
|
|
|
|
|
2021-11-10 09:31:03 -05:00
|
|
|
resp, err = resty.R().Get(baseURL + "/query")
|
2021-06-08 13:37:31 -05:00
|
|
|
So(resp, ShouldNotBeNil)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(resp.StatusCode(), ShouldEqual, 404)
|
|
|
|
})
|
|
|
|
}
|