2021-12-03 22:50:58 -05:00
|
|
|
//go:build extended
|
2021-10-15 10:05:00 -05:00
|
|
|
// +build extended
|
|
|
|
|
2021-01-25 13:04:03 -05:00
|
|
|
package common_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"encoding/json"
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
ispec "github.com/opencontainers/image-spec/specs-go/v1"
|
|
|
|
. "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"
|
|
|
|
"zotregistry.io/zot/pkg/extensions/search/common"
|
|
|
|
"zotregistry.io/zot/pkg/log"
|
|
|
|
"zotregistry.io/zot/pkg/storage"
|
2022-01-19 14:54:17 -05:00
|
|
|
. "zotregistry.io/zot/pkg/test"
|
2021-01-25 13:04:03 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// nolint:gochecknoglobals
|
|
|
|
var (
|
|
|
|
rootDir string
|
|
|
|
subRootDir string
|
|
|
|
)
|
|
|
|
|
|
|
|
type ImgResponsWithLatestTag struct {
|
|
|
|
ImgListWithLatestTag ImgListWithLatestTag `json:"data"`
|
|
|
|
Errors []ErrorGQL `json:"errors"`
|
|
|
|
}
|
|
|
|
|
2021-12-13 14:23:31 -05:00
|
|
|
//nolint:tagliatelle // graphQL schema
|
2021-01-25 13:04:03 -05:00
|
|
|
type ImgListWithLatestTag struct {
|
|
|
|
Images []ImageInfo `json:"ImageListWithLatestTag"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ErrorGQL struct {
|
|
|
|
Message string `json:"message"`
|
|
|
|
Path []string `json:"path"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ImageInfo struct {
|
|
|
|
Name string
|
|
|
|
Latest string
|
|
|
|
LastUpdated time.Time
|
|
|
|
Description string
|
|
|
|
Licenses string
|
|
|
|
Vendor string
|
|
|
|
Size string
|
|
|
|
Labels string
|
|
|
|
}
|
|
|
|
|
|
|
|
func testSetup() error {
|
|
|
|
dir, err := ioutil.TempDir("", "search_test")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
subDir, err := ioutil.TempDir("", "sub_search_test")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
rootDir = dir
|
|
|
|
|
|
|
|
subRootDir = subDir
|
|
|
|
|
2021-11-10 09:31:03 -05:00
|
|
|
err = CopyFiles("../../../../test/data", rootDir)
|
2021-01-25 13:04:03 -05:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-11-10 09:31:03 -05:00
|
|
|
err = CopyFiles("../../../../test/data", subDir)
|
2021-01-25 13:04:03 -05:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func getTags() ([]common.TagInfo, []common.TagInfo) {
|
|
|
|
tags := make([]common.TagInfo, 0)
|
|
|
|
|
2021-12-13 14:23:31 -05:00
|
|
|
firstTag := common.TagInfo{
|
|
|
|
Name: "1.0.0",
|
2021-01-25 13:04:03 -05:00
|
|
|
Digest: "sha256:eca04f027f414362596f2632746d8a178362170b9ac9af772011fedcc3877ebb",
|
2021-12-13 14:23:31 -05:00
|
|
|
Timestamp: time.Now(),
|
|
|
|
}
|
|
|
|
secondTag := common.TagInfo{
|
|
|
|
Name: "1.0.1",
|
2021-01-25 13:04:03 -05:00
|
|
|
Digest: "sha256:eca04f027f414362596f2632746d8a179362170b9ac9af772011fedcc3877ebb",
|
2021-12-13 14:23:31 -05:00
|
|
|
Timestamp: time.Now(),
|
|
|
|
}
|
|
|
|
thirdTag := common.TagInfo{
|
|
|
|
Name: "1.0.2",
|
2021-01-25 13:04:03 -05:00
|
|
|
Digest: "sha256:eca04f027f414362596f2632746d8a170362170b9ac9af772011fedcc3877ebb",
|
2021-12-13 14:23:31 -05:00
|
|
|
Timestamp: time.Now(),
|
|
|
|
}
|
|
|
|
fourthTag := common.TagInfo{
|
|
|
|
Name: "1.0.3",
|
2021-01-25 13:04:03 -05:00
|
|
|
Digest: "sha256:eca04f027f414362596f2632746d8a171362170b9ac9af772011fedcc3877ebb",
|
2021-12-13 14:23:31 -05:00
|
|
|
Timestamp: time.Now(),
|
|
|
|
}
|
2021-01-25 13:04:03 -05:00
|
|
|
|
|
|
|
tags = append(tags, firstTag, secondTag, thirdTag, fourthTag)
|
|
|
|
|
|
|
|
infectedTags := make([]common.TagInfo, 0)
|
|
|
|
infectedTags = append(infectedTags, secondTag)
|
|
|
|
|
|
|
|
return tags, infectedTags
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestImageFormat(t *testing.T) {
|
|
|
|
Convey("Test valid image", t, func() {
|
|
|
|
log := log.NewLogger("debug", "")
|
|
|
|
dbDir := "../../../../test/data"
|
2021-09-30 08:27:13 -05:00
|
|
|
|
2021-10-15 10:05:00 -05:00
|
|
|
metrics := monitoring.NewMetricsServer(false, log)
|
2022-01-20 23:11:44 -05:00
|
|
|
defaultStore := storage.NewImageStore(dbDir, false, false, false, log, metrics)
|
2021-09-30 08:27:13 -05:00
|
|
|
storeController := storage.StoreController{DefaultStore: defaultStore}
|
|
|
|
olu := common.NewOciLayoutUtils(storeController, log)
|
|
|
|
|
|
|
|
isValidImage, err := olu.IsValidImageFormat("zot-test")
|
2021-01-25 13:04:03 -05:00
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(isValidImage, ShouldEqual, true)
|
|
|
|
|
2021-09-30 08:27:13 -05:00
|
|
|
isValidImage, err = olu.IsValidImageFormat("zot-test:0.0.1")
|
2021-01-25 13:04:03 -05:00
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(isValidImage, ShouldEqual, true)
|
|
|
|
|
2021-09-30 08:27:13 -05:00
|
|
|
isValidImage, err = olu.IsValidImageFormat("zot-test:0.0.")
|
2021-01-25 13:04:03 -05:00
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(isValidImage, ShouldEqual, false)
|
|
|
|
|
2021-09-30 08:27:13 -05:00
|
|
|
isValidImage, err = olu.IsValidImageFormat("zot-noindex-test")
|
2021-01-25 13:04:03 -05:00
|
|
|
So(err, ShouldNotBeNil)
|
|
|
|
So(isValidImage, ShouldEqual, false)
|
|
|
|
|
2021-09-30 08:27:13 -05:00
|
|
|
isValidImage, err = olu.IsValidImageFormat("zot--tet")
|
2021-01-25 13:04:03 -05:00
|
|
|
So(err, ShouldNotBeNil)
|
|
|
|
So(isValidImage, ShouldEqual, false)
|
|
|
|
|
2021-09-30 08:27:13 -05:00
|
|
|
isValidImage, err = olu.IsValidImageFormat("zot-noindex-test")
|
2021-01-25 13:04:03 -05:00
|
|
|
So(err, ShouldNotBeNil)
|
|
|
|
So(isValidImage, ShouldEqual, false)
|
|
|
|
|
2021-09-30 08:27:13 -05:00
|
|
|
isValidImage, err = olu.IsValidImageFormat("zot-squashfs-noblobs")
|
2021-01-25 13:04:03 -05:00
|
|
|
So(err, ShouldNotBeNil)
|
|
|
|
So(isValidImage, ShouldEqual, false)
|
|
|
|
|
2021-09-30 08:27:13 -05:00
|
|
|
isValidImage, err = olu.IsValidImageFormat("zot-squashfs-invalid-index")
|
2021-01-25 13:04:03 -05:00
|
|
|
So(err, ShouldNotBeNil)
|
|
|
|
So(isValidImage, ShouldEqual, false)
|
|
|
|
|
2021-09-30 08:27:13 -05:00
|
|
|
isValidImage, err = olu.IsValidImageFormat("zot-squashfs-invalid-blob")
|
2021-01-25 13:04:03 -05:00
|
|
|
So(err, ShouldNotBeNil)
|
|
|
|
So(isValidImage, ShouldEqual, false)
|
|
|
|
|
2021-09-30 08:27:13 -05:00
|
|
|
isValidImage, err = olu.IsValidImageFormat("zot-squashfs-test:0.3.22-squashfs")
|
2021-01-25 13:04:03 -05:00
|
|
|
So(err, ShouldNotBeNil)
|
|
|
|
So(isValidImage, ShouldEqual, false)
|
|
|
|
|
2021-09-30 08:27:13 -05:00
|
|
|
isValidImage, err = olu.IsValidImageFormat("zot-nonreadable-test")
|
2021-01-25 13:04:03 -05:00
|
|
|
So(err, ShouldNotBeNil)
|
|
|
|
So(isValidImage, ShouldEqual, false)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestLatestTagSearchHTTP(t *testing.T) {
|
|
|
|
Convey("Test latest image search by timestamp", t, func() {
|
|
|
|
err := testSetup()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
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
|
|
|
|
conf.Storage.SubPaths = make(map[string]config.StorageConfig)
|
|
|
|
conf.Storage.SubPaths["/a"] = config.StorageConfig{RootDirectory: subRootDir}
|
|
|
|
conf.Extensions = &extconf.ExtensionConfig{
|
|
|
|
Search: &extconf.SearchConfig{Enable: true},
|
2021-01-25 13:04:03 -05:00
|
|
|
}
|
|
|
|
|
2021-06-08 15:11:18 -05:00
|
|
|
conf.Extensions.Search.CVE = nil
|
2021-01-25 13:04:03 -05:00
|
|
|
|
2021-12-13 14:23:31 -05:00
|
|
|
ctlr := api.NewController(conf)
|
2021-01-25 13:04:03 -05:00
|
|
|
|
|
|
|
go func() {
|
|
|
|
// this blocks
|
2021-12-13 14:23:31 -05:00
|
|
|
if err := ctlr.Run(); err != nil {
|
2021-01-25 13:04:03 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
// wait till ready
|
|
|
|
for {
|
2021-11-10 09:31:03 -05:00
|
|
|
_, err := resty.R().Get(baseURL)
|
2021-01-25 13:04:03 -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-01-25 13:04:03 -05:00
|
|
|
}()
|
|
|
|
|
2021-11-10 09:31:03 -05:00
|
|
|
resp, err := resty.R().Get(baseURL + "/v2/")
|
2021-01-25 13:04:03 -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-01-25 13:04:03 -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={ImageListWithLatestTag(){Name%20Latest}}")
|
2021-01-25 13:04:03 -05:00
|
|
|
So(resp, ShouldNotBeNil)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(resp.StatusCode(), ShouldEqual, 200)
|
|
|
|
|
|
|
|
var responseStruct ImgResponsWithLatestTag
|
|
|
|
err = json.Unmarshal(resp.Body(), &responseStruct)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(len(responseStruct.ImgListWithLatestTag.Images), ShouldEqual, 4)
|
|
|
|
|
|
|
|
images := responseStruct.ImgListWithLatestTag.Images
|
|
|
|
So(images[0].Latest, ShouldEqual, "0.0.1")
|
|
|
|
|
2021-11-10 09:31:03 -05:00
|
|
|
resp, err = resty.R().Get(baseURL + "/query?query={ImageListWithLatestTag(){Name%20Latest}}")
|
2021-01-25 13:04:03 -05:00
|
|
|
So(resp, ShouldNotBeNil)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
|
2021-12-13 14:23:31 -05:00
|
|
|
err = os.Chmod(rootDir, 0o000)
|
2021-01-25 13:04:03 -05:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2021-11-10 09:31:03 -05:00
|
|
|
resp, err = resty.R().Get(baseURL + "/query?query={ImageListWithLatestTag(){Name%20Latest}}")
|
2021-01-25 13:04:03 -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.ImgListWithLatestTag.Images), ShouldEqual, 0)
|
|
|
|
|
2021-12-13 14:23:31 -05:00
|
|
|
err = os.Chmod(rootDir, 0o755)
|
2021-01-25 13:04:03 -05:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete config blob and try.
|
|
|
|
err = os.Remove(path.Join(subRootDir, "zot-test/blobs/sha256",
|
|
|
|
"adf3bb6cc81f8bd6a9d5233be5f0c1a4f1e3ed1cf5bbdfad7708cc8d4099b741"))
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2021-11-10 09:31:03 -05:00
|
|
|
resp, err = resty.R().Get(baseURL + "/query?query={ImageListWithLatestTag(){Name%20Latest}}")
|
2021-01-25 13:04:03 -05:00
|
|
|
So(resp, ShouldNotBeNil)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(resp.StatusCode(), ShouldEqual, 200)
|
|
|
|
|
|
|
|
err = os.Remove(path.Join(subRootDir, "zot-test/blobs/sha256",
|
|
|
|
"2bacca16b9df395fc855c14ccf50b12b58d35d468b8e7f25758aff90f89bf396"))
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2021-11-10 09:31:03 -05:00
|
|
|
resp, err = resty.R().Get(baseURL + "/query?query={ImageListWithLatestTag(){Name%20Latest}}")
|
2021-01-25 13:04:03 -05:00
|
|
|
So(resp, ShouldNotBeNil)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(resp.StatusCode(), ShouldEqual, 200)
|
|
|
|
|
|
|
|
err = os.Remove(path.Join(rootDir, "zot-test/blobs/sha256",
|
|
|
|
"adf3bb6cc81f8bd6a9d5233be5f0c1a4f1e3ed1cf5bbdfad7708cc8d4099b741"))
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2021-11-10 09:31:03 -05:00
|
|
|
resp, err = resty.R().Get(baseURL + "/query?query={ImageListWithLatestTag(){Name%20Latest}}")
|
2021-01-25 13:04:03 -05:00
|
|
|
So(resp, ShouldNotBeNil)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(resp.StatusCode(), ShouldEqual, 200)
|
|
|
|
|
|
|
|
// Delete manifest blob also and try
|
|
|
|
err = os.Remove(path.Join(rootDir, "zot-test/blobs/sha256",
|
|
|
|
"2bacca16b9df395fc855c14ccf50b12b58d35d468b8e7f25758aff90f89bf396"))
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2021-11-10 09:31:03 -05:00
|
|
|
resp, err = resty.R().Get(baseURL + "/query?query={ImageListWithLatestTag(){Name%20Latest}}")
|
2021-01-25 13:04:03 -05:00
|
|
|
So(resp, ShouldNotBeNil)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(resp.StatusCode(), ShouldEqual, 200)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestUtilsMethod(t *testing.T) {
|
|
|
|
Convey("Test utils", t, func() {
|
|
|
|
// Test GetRepo method
|
|
|
|
repo := common.GetRepo("test")
|
|
|
|
So(repo, ShouldEqual, "test")
|
|
|
|
|
|
|
|
repo = common.GetRepo(":")
|
|
|
|
So(repo, ShouldEqual, "")
|
|
|
|
|
|
|
|
repo = common.GetRepo("")
|
|
|
|
So(repo, ShouldEqual, "")
|
|
|
|
|
|
|
|
repo = common.GetRepo("test:123")
|
|
|
|
So(repo, ShouldEqual, "test")
|
|
|
|
|
|
|
|
repo = common.GetRepo("a/test:123")
|
|
|
|
So(repo, ShouldEqual, "a/test")
|
|
|
|
|
|
|
|
repo = common.GetRepo("a/test:123:456")
|
|
|
|
So(repo, ShouldEqual, "a/test")
|
|
|
|
|
|
|
|
// Test various labels
|
|
|
|
labels := make(map[string]string)
|
|
|
|
|
|
|
|
desc := common.GetDescription(labels)
|
|
|
|
So(desc, ShouldEqual, "")
|
|
|
|
|
|
|
|
license := common.GetLicense(labels)
|
|
|
|
So(license, ShouldEqual, "")
|
|
|
|
|
|
|
|
vendor := common.GetVendor(labels)
|
|
|
|
So(vendor, ShouldEqual, "")
|
|
|
|
|
|
|
|
categories := common.GetCategories(labels)
|
|
|
|
So(categories, ShouldEqual, "")
|
|
|
|
|
|
|
|
labels[ispec.AnnotationVendor] = "zot"
|
|
|
|
labels[ispec.AnnotationDescription] = "zot-desc"
|
|
|
|
labels[ispec.AnnotationLicenses] = "zot-license"
|
|
|
|
labels[common.AnnotationLabels] = "zot-labels"
|
|
|
|
|
|
|
|
desc = common.GetDescription(labels)
|
|
|
|
So(desc, ShouldEqual, "zot-desc")
|
|
|
|
|
|
|
|
license = common.GetLicense(labels)
|
|
|
|
So(license, ShouldEqual, "zot-license")
|
|
|
|
|
|
|
|
vendor = common.GetVendor(labels)
|
|
|
|
So(vendor, ShouldEqual, "zot")
|
|
|
|
|
|
|
|
categories = common.GetCategories(labels)
|
|
|
|
So(categories, ShouldEqual, "zot-labels")
|
|
|
|
|
|
|
|
labels = make(map[string]string)
|
|
|
|
|
|
|
|
// Use diff key
|
|
|
|
labels[common.LabelAnnotationVendor] = "zot-vendor"
|
|
|
|
labels[common.LabelAnnotationDescription] = "zot-label-desc"
|
|
|
|
labels[common.LabelAnnotationLicenses] = "zot-label-license"
|
|
|
|
|
|
|
|
desc = common.GetDescription(labels)
|
|
|
|
So(desc, ShouldEqual, "zot-label-desc")
|
|
|
|
|
|
|
|
license = common.GetLicense(labels)
|
|
|
|
So(license, ShouldEqual, "zot-label-license")
|
|
|
|
|
|
|
|
vendor = common.GetVendor(labels)
|
|
|
|
So(vendor, ShouldEqual, "zot-vendor")
|
|
|
|
|
|
|
|
routePrefix := common.GetRoutePrefix("test:latest")
|
|
|
|
So(routePrefix, ShouldEqual, "/")
|
|
|
|
|
|
|
|
routePrefix = common.GetRoutePrefix("a/test:latest")
|
|
|
|
So(routePrefix, ShouldEqual, "/a")
|
|
|
|
|
|
|
|
routePrefix = common.GetRoutePrefix("a/b/test:latest")
|
|
|
|
So(routePrefix, ShouldEqual, "/a")
|
|
|
|
|
|
|
|
allTags, infectedTags := getTags()
|
|
|
|
|
|
|
|
latestTag := common.GetLatestTag(allTags)
|
|
|
|
So(latestTag.Name, ShouldEqual, "1.0.3")
|
|
|
|
|
|
|
|
fixedTags := common.GetFixedTags(allTags, infectedTags)
|
|
|
|
So(len(fixedTags), ShouldEqual, 2)
|
|
|
|
|
|
|
|
log := log.NewLogger("debug", "")
|
|
|
|
|
|
|
|
rootDir, err := ioutil.TempDir("", "common_utils_test")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer os.RemoveAll(rootDir)
|
|
|
|
|
|
|
|
subRootDir, err := ioutil.TempDir("", "common_utils_test")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer os.RemoveAll(subRootDir)
|
|
|
|
|
2021-10-15 10:05:00 -05:00
|
|
|
metrics := monitoring.NewMetricsServer(false, log)
|
2022-01-20 23:11:44 -05:00
|
|
|
defaultStore := storage.NewImageStore(rootDir, false, false, false, log, metrics)
|
2021-01-25 13:04:03 -05:00
|
|
|
|
2022-01-20 23:11:44 -05:00
|
|
|
subStore := storage.NewImageStore(subRootDir, false, false, false, log, metrics)
|
2021-01-25 13:04:03 -05:00
|
|
|
|
2021-09-30 08:27:13 -05:00
|
|
|
subStoreMap := make(map[string]storage.ImageStore)
|
2021-01-25 13:04:03 -05:00
|
|
|
|
|
|
|
subStoreMap["/b"] = subStore
|
|
|
|
|
|
|
|
storeController := storage.StoreController{DefaultStore: defaultStore, SubStore: subStoreMap}
|
|
|
|
|
|
|
|
dir := common.GetRootDir("a/zot-cve-test", storeController)
|
|
|
|
|
|
|
|
So(dir, ShouldEqual, rootDir)
|
|
|
|
|
|
|
|
dir = common.GetRootDir("b/zot-cve-test", storeController)
|
|
|
|
|
|
|
|
So(dir, ShouldEqual, subRootDir)
|
|
|
|
})
|
|
|
|
}
|