From f61b791981e00975dd1d31d93cd322b4e1cf3095 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Tue, 22 Aug 2023 08:12:41 +0000 Subject: [PATCH 01/45] test(e2e): add zot Signed-off-by: Billy Zha --- test/e2e/README.md | 7 +++++-- test/e2e/internal/utils/init.go | 13 +++++++++++++ test/e2e/internal/utils/testdata.go | 1 + test/e2e/scripts/e2e.sh | 21 +++++++++++++++++---- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/test/e2e/README.md b/test/e2e/README.md index 26e7332a8..15be2cff1 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -30,9 +30,12 @@ go test oras.land/oras/test/e2e/suite/${suite_name} This is super handy when you want to do step-by-step debugging from command-line or via an IDE. If you need to debug certain specs, use [focused specs](https://onsi.github.io/ginkgo/#focused-specs) but don't check it in. ### 4. Testing Registry Services -The backend of E2E tests are two registry services: [oras-distribution](https://github.com/oras-project/distribution) and [upstream distribution](https://github.com/distribution/distribution). The former is expected to support image and artifact media types and referrer API; The latter is expected to only support image media type with subject and provide referrers via [tag schema](https://github.com/opencontainers/distribution-spec/blob/v1.1.0-rc1/spec.md#referrers-tag-schema). +The backend of E2E tests are three registry services: +- [oras-distribution](https://github.com/oras-project/distribution): registry service supports artifact and image types in [image-spec 1.1.0 rc2](https://github.com/opencontainers/image-spec/tree/v1.1.0-rc2) and referrer API +- [upstream distribution](https://github.com/distribution/distribution): registry service supports image media type with subject and provide referrers via [tag schema](https://github.com/opencontainers/distribution-spec/blob/v1.1.0-rc1/spec.md#referrers-tag-schema). +- [zot](https://github.com/project-zot/zot): registry service supports artifact and image types in [image-spec 1.1.0 rc4](https://github.com/opencontainers/image-spec/tree/v1.1.0-rc4) and referrer API -You can run scenario test suite against your own registry services via setting `ORAS_REGISTRY_HOST` or `ORAS_REGISTRY_FALLBACK_HOST` environmental variables. +You can run scenario test suite against your own registry services via setting `ORAS_REGISTRY_HOST`, `ORAS_REGISTRY_FALLBACK_HOST` and `ZOT_REGISTRY_HOST` environmental variables. ### 5. Constant Build & Watch This is a good choice if you want to debug certain re-runnable specs: diff --git a/test/e2e/internal/utils/init.go b/test/e2e/internal/utils/init.go index ecefaa3ad..7513d1737 100644 --- a/test/e2e/internal/utils/init.go +++ b/test/e2e/internal/utils/init.go @@ -36,6 +36,9 @@ var Host string // FallbackHost points to the registry service where fallback E2E specs will be run against. var FallbackHost string +// ZotHost points to the zot service where E2E specs will be run against. +var ZotHost string + func init() { Host = os.Getenv(RegHostKey) if Host == "" { @@ -59,6 +62,16 @@ func init() { panic(err) } + ZotHost = os.Getenv(ZotHostKey) + if ZotHost == "" { + ZotHost = "localhost:7000" + fmt.Fprintf(os.Stderr, "cannot find zot host name in %s, using %s instead\n", ZotHostKey, ZotHost) + } + ref.Registry = ZotHost + if err := ref.ValidateRegistry(); err != nil { + panic(err) + } + // setup test data pwd, err := os.Getwd() if err != nil { diff --git a/test/e2e/internal/utils/testdata.go b/test/e2e/internal/utils/testdata.go index 5adac93ef..eb7e4ab28 100644 --- a/test/e2e/internal/utils/testdata.go +++ b/test/e2e/internal/utils/testdata.go @@ -25,6 +25,7 @@ const ( // env RegHostKey = "ORAS_REGISTRY_HOST" FallbackRegHostKey = "ORAS_REGISTRY_FALLBACK_HOST" + ZotHostKey = "ZOT_REGISTRY_HOST" ) var ( diff --git a/test/e2e/scripts/e2e.sh b/test/e2e/scripts/e2e.sh index b110e38c6..1198b4873 100755 --- a/test/e2e/scripts/e2e.sh +++ b/test/e2e/scripts/e2e.sh @@ -17,6 +17,8 @@ export ORAS_REGISTRY_PORT="5000" export ORAS_REGISTRY_HOST="localhost:${ORAS_REGISTRY_PORT}" export ORAS_REGISTRY_FALLBACK_PORT="6000" export ORAS_REGISTRY_FALLBACK_HOST="localhost:${ORAS_REGISTRY_FALLBACK_PORT}" +export ZOT_REGISTRY_PORT="7000" +export ZOT_REGISTRY_HOST="localhost:${ZOT_REGISTRY_PORT}" repo_root=$1 if [ -z "${repo_root}" ]; then @@ -36,14 +38,16 @@ trap "cd $cwd" EXIT # start registries . ${repo_root}/test/e2e/scripts/common.sh +e2e_root="${repo_root}/test/e2e" +oras_container_name="oras-e2e" +upstream_container_name="oras-e2e-fallback" +zot_container_name="oras-e2e-zot" + if [ "$clean_up" = '--clean' ]; then echo " === setting deferred clean up jobs === " - trap "try_clean_up oras-e2e oras-e2e-fallback" EXIT + trap "try_clean_up $oras_container_name $upstream_container_name $zot_container_name" EXIT fi -oras_container_name="oras-e2e" -upstream_container_name="oras-e2e-fallback" -e2e_root="${repo_root}/test/e2e" echo " === preparing oras distribution === " run_registry \ ${e2e_root}/testdata/distribution/mount \ @@ -58,6 +62,13 @@ run_registry \ $upstream_container_name \ $ORAS_REGISTRY_FALLBACK_PORT +echo " === preparing zot === " +try_clean_up $zot_container_name +docker run -d -p $ZOT_REGISTRY_PORT:5000 -it \ + --name $zot_container_name \ + --mount type=bind,source="${e2e_root}/testdata/zot/",target=/etc/zot \ + --rm ghcr.io/project-zot/zot-linux-amd64:v2.0.0-rc6 + echo " === run tests === " if ! ginkgo -r -p --succinct suite; then echo " === retriving registry error logs === " @@ -65,5 +76,7 @@ if ! ginkgo -r -p --succinct suite; then docker logs -t --tail 200 $oras_container_name echo '-------- upstream distribution trace -------------' docker logs -t --tail 200 $upstream_container_name + echo '-------- zot trace -------------' + docker logs -t --tail 200 $zot_container_name exit 1 fi From 06abf607605cdb593021fa8dfe24a82aa0ed973b Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Tue, 22 Aug 2023 08:13:12 +0000 Subject: [PATCH 02/45] add auth tests Signed-off-by: Billy Zha --- test/e2e/suite/auth/auth.go | 40 ++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/test/e2e/suite/auth/auth.go b/test/e2e/suite/auth/auth.go index c15f9c4f1..49176c78e 100644 --- a/test/e2e/suite/auth/auth.go +++ b/test/e2e/suite/auth/auth.go @@ -27,38 +27,38 @@ import ( var _ = Describe("Common registry user", Ordered, func() { When("logging out", Ordered, func() { It("should use logout command to logout", func() { - ORAS("logout", Host, "--registry-config", AuthConfigPath).Exec() + ORAS("logout", ZotHost, "--registry-config", AuthConfigPath).Exec() }) It("should run commands without logging in", func() { - RunWithoutLogin("attach", Host+"/repo:tag", "-a", "test=true", "--artifact-type", "doc/example") - ORAS("copy", Host+"/repo:from", Host+"/repo:to", "--from-registry-config", AuthConfigPath, "--to-registry-config", AuthConfigPath). + RunWithoutLogin("attach", ZotHost+"/repo:tag", "-a", "test=true", "--artifact-type", "doc/example") + ORAS("copy", ZotHost+"/repo:from", ZotHost+"/repo:to", "--from-registry-config", AuthConfigPath, "--to-registry-config", AuthConfigPath). ExpectFailure(). MatchErrKeyWords("Error:", "credential required"). WithDescription("fail without logging in").Exec() - RunWithoutLogin("discover", Host+"/repo:tag") - RunWithoutLogin("push", "-a", "key=value", Host+"/repo:tag") - RunWithoutLogin("pull", Host+"/repo:tag") - RunWithoutLogin("manifest", "fetch", Host+"/repo:tag") - RunWithoutLogin("blob", "delete", Host+"/repo@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") - RunWithoutLogin("blob", "push", Host+"/repo", WriteTempFile("blob", "test")) - RunWithoutLogin("tag", Host+"/repo:tag", "tag1") - RunWithoutLogin("repo", "ls", Host) - RunWithoutLogin("repo", "tags", RegistryRef(Host, "repo", "")) - RunWithoutLogin("manifest", "fetch-config", Host+"/repo:tag") + RunWithoutLogin("discover", ZotHost+"/repo:tag") + RunWithoutLogin("push", "-a", "key=value", ZotHost+"/repo:tag") + RunWithoutLogin("pull", ZotHost+"/repo:tag") + RunWithoutLogin("manifest", "fetch", ZotHost+"/repo:tag") + RunWithoutLogin("blob", "delete", ZotHost+"/repo@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") + RunWithoutLogin("blob", "push", ZotHost+"/repo", WriteTempFile("blob", "test")) + RunWithoutLogin("tag", ZotHost+"/repo:tag", "tag1") + RunWithoutLogin("repo", "ls", ZotHost) + RunWithoutLogin("repo", "tags", RegistryRef(ZotHost, "repo", "")) + RunWithoutLogin("manifest", "fetch-config", ZotHost+"/repo:tag") }) }) When("logging in", func() { It("should use basic auth", func() { - ORAS("login", Host, "-u", Username, "-p", Password, "--registry-config", AuthConfigPath). + ORAS("login", ZotHost, "-u", Username, "-p", Password, "--registry-config", AuthConfigPath). WithTimeOut(20*time.Second). MatchContent("Login Succeeded\n"). MatchErrKeyWords("WARNING", "Using --password via the CLI is insecure", "Use --password-stdin").Exec() }) It("should fail if no username input", func() { - ORAS("login", Host, "--registry-config", AuthConfigPath). + ORAS("login", ZotHost, "--registry-config", AuthConfigPath). WithTimeOut(20 * time.Second). WithInput(strings.NewReader("")). MatchKeyWords("username:"). @@ -67,14 +67,14 @@ var _ = Describe("Common registry user", Ordered, func() { }) It("should fail if no password input", func() { - ORAS("login", Host, "--registry-config", AuthConfigPath). + ORAS("login", ZotHost, "--registry-config", AuthConfigPath). WithTimeOut(20*time.Second). MatchKeyWords("Username: ", "Password: "). WithInput(strings.NewReader(fmt.Sprintf("%s\n", Username))).ExpectFailure().Exec() }) It("should fail if password is empty", func() { - ORAS("login", Host, "--registry-config", AuthConfigPath). + ORAS("login", ZotHost, "--registry-config", AuthConfigPath). WithTimeOut(20*time.Second). MatchKeyWords("Username: ", "Password: "). MatchErrKeyWords("Error: password required"). @@ -82,14 +82,14 @@ var _ = Describe("Common registry user", Ordered, func() { }) It("should fail if no token input", func() { - ORAS("login", Host, "--registry-config", AuthConfigPath). + ORAS("login", ZotHost, "--registry-config", AuthConfigPath). WithTimeOut(20*time.Second). MatchKeyWords("Username: ", "Token: "). WithInput(strings.NewReader("\n")).ExpectFailure().Exec() }) It("should fail if token is empty", func() { - ORAS("login", Host, "--registry-config", AuthConfigPath). + ORAS("login", ZotHost, "--registry-config", AuthConfigPath). WithTimeOut(20*time.Second). MatchKeyWords("Username: ", "Token: "). MatchErrKeyWords("Error: token required"). @@ -97,7 +97,7 @@ var _ = Describe("Common registry user", Ordered, func() { }) It("should use prompted input", func() { - ORAS("login", Host, "--registry-config", AuthConfigPath). + ORAS("login", ZotHost, "--registry-config", AuthConfigPath). WithTimeOut(20*time.Second). WithInput(strings.NewReader(fmt.Sprintf("%s\n%s\n", Username, Password))). MatchKeyWords("Username: ", "Password: ", "Login Succeeded\n").Exec() From 8e644c61101220728929b3260e55d2de8d5e2a80 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Wed, 23 Aug 2023 01:57:33 +0000 Subject: [PATCH 03/45] uncomment changes Signed-off-by: Billy Zha --- test/e2e/suite/scenario/oci_artifact.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/e2e/suite/scenario/oci_artifact.go b/test/e2e/suite/scenario/oci_artifact.go index bbd744e3c..502b0b6c8 100644 --- a/test/e2e/suite/scenario/oci_artifact.go +++ b/test/e2e/suite/scenario/oci_artifact.go @@ -84,10 +84,10 @@ var _ = Describe("Common OCI artifact users:", Ordered, func() { // FIXME: oras distribution doesn't support OCI image with artifactType field // Below test can be run after https://github.com/oras-project/oras/issues/1071 is done. - // session = ORAS("discover", subject, "-o", "json", "--artifact-type", "test.artifact2").Exec() - // digest = string(Binary("jq", "-r", ".manifests[].digest").WithInput(session.Out).Exec().Out.Contents()) - // fetched = ORAS("manifest", "fetch", RegistryRef(Host, repo, digest)).MatchKeyWords(foobar.AttachFileMedia).Exec() - // MatchFile(filepath.Join(tempDir, pulledManifest), string(fetched.Out.Contents()), DefaultTimeout) + session = ORAS("discover", subject, "-o", "json", "--artifact-type", "test.artifact2").Exec() + digest = string(Binary("jq", "-r", ".manifests[].digest").WithInput(session.Out).Exec().Out.Contents()) + fetched = ORAS("manifest", "fetch", RegistryRef(Host, repo, digest)).MatchKeyWords(foobar.AttachFileMedia).Exec() + MatchFile(filepath.Join(tempDir, pulledManifest), string(fetched.Out.Contents()), DefaultTimeout) ORAS("pull", RegistryRef(Host, repo, string(digest)), "-v", "-o", pullRoot, "--include-subject"). MatchStatus(append(foobar.FileStateKeys, foobar.AttachFileStateKey), true, 4). From 0c7a3ee3f39fbf30a1c2d34f05c248ddc8ad0032 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Wed, 23 Aug 2023 04:39:38 +0000 Subject: [PATCH 04/45] move auth and scenario suite to zot Signed-off-by: Billy Zha --- test/e2e/internal/utils/init.go | 2 ++ .../internal/utils/{file.go => prepare.go} | 6 +++++ test/e2e/suite/scenario/oci_artifact.go | 26 +++++++++---------- 3 files changed, 20 insertions(+), 14 deletions(-) rename test/e2e/internal/utils/{file.go => prepare.go} (94%) diff --git a/test/e2e/internal/utils/init.go b/test/e2e/internal/utils/init.go index 7513d1737..977cd4f8d 100644 --- a/test/e2e/internal/utils/init.go +++ b/test/e2e/internal/utils/init.go @@ -124,5 +124,7 @@ func init() { gomega.Expect(cmd.Run()).ShouldNot(gomega.HaveOccurred()) cmd = exec.Command(ORASPath, "login", FallbackHost, "-u", Username, "-p", Password) gomega.Expect(cmd.Run()).ShouldNot(gomega.HaveOccurred()) + cmd = exec.Command(ORASPath, "login", ZotHost, "-u", Username, "-p", Password) + gomega.Expect(cmd.Run()).ShouldNot(gomega.HaveOccurred()) }) } diff --git a/test/e2e/internal/utils/file.go b/test/e2e/internal/utils/prepare.go similarity index 94% rename from test/e2e/internal/utils/file.go rename to test/e2e/internal/utils/prepare.go index eea029237..3359d2b86 100644 --- a/test/e2e/internal/utils/file.go +++ b/test/e2e/internal/utils/prepare.go @@ -28,6 +28,12 @@ import ( "github.com/onsi/gomega/gbytes" ) +func PrepareRepository() string { + tempDir := GinkgoT().TempDir() + Expect(CopyTestFiles(tempDir)).ShouldNot(HaveOccurred()) + return tempDir +} + // PrepareTempFiles copies test data into a temp folder and return it. func PrepareTempFiles() string { tempDir := GinkgoT().TempDir() diff --git a/test/e2e/suite/scenario/oci_artifact.go b/test/e2e/suite/scenario/oci_artifact.go index 502b0b6c8..fe9d4eb74 100644 --- a/test/e2e/suite/scenario/oci_artifact.go +++ b/test/e2e/suite/scenario/oci_artifact.go @@ -25,7 +25,7 @@ import ( "oras.land/oras/test/e2e/internal/utils/match" ) -var _ = Describe("Common OCI artifact users:", Ordered, func() { +var _ = Describe("OCI artifact users:", Ordered, func() { repo := "scenario/oci-artifact" When("pushing images and attaching", func() { tag := "artifact" @@ -37,15 +37,15 @@ var _ = Describe("Common OCI artifact users:", Ordered, func() { pulledManifest := "packed.json" pullRoot := "pulled" It("should push and pull an artifact", func() { - ORAS("push", RegistryRef(Host, repo, tag), "--artifact-type", "test-artifact", foobar.FileLayerNames[0], foobar.FileLayerNames[1], foobar.FileLayerNames[2], "-v", "--export-manifest", pulledManifest). + ORAS("push", RegistryRef(ZotHost, repo, tag), "--artifact-type", "test/artifact", foobar.FileLayerNames[0], foobar.FileLayerNames[1], foobar.FileLayerNames[2], "-v", "--export-manifest", pulledManifest). MatchStatus(foobar.FileStateKeys, true, 3). WithWorkDir(tempDir). WithDescription("push with manifest exported").Exec() - fetched := ORAS("manifest", "fetch", RegistryRef(Host, repo, tag)).Exec() + fetched := ORAS("manifest", "fetch", RegistryRef(ZotHost, repo, tag)).Exec() MatchFile(filepath.Join(tempDir, pulledManifest), string(fetched.Out.Contents()), DefaultTimeout) - ORAS("pull", RegistryRef(Host, repo, tag), "-v", "-o", pullRoot). + ORAS("pull", RegistryRef(ZotHost, repo, tag), "-v", "-o", pullRoot). MatchStatus(foobar.FileStateKeys, true, 3). WithWorkDir(tempDir). WithDescription("pull artFiles with config").Exec() @@ -58,18 +58,18 @@ var _ = Describe("Common OCI artifact users:", Ordered, func() { }) It("should attach and pull an artifact", func() { - subject := RegistryRef(Host, repo, tag) - ORAS("attach", subject, "--artifact-type", "test.artifact1", fmt.Sprint(foobar.AttachFileName, ":", foobar.AttachFileMedia), "-v", "--export-manifest", pulledManifest). + subject := RegistryRef(ZotHost, repo, tag) + ORAS("attach", subject, "--artifact-type", "test/artifact1", fmt.Sprint(foobar.AttachFileName, ":", foobar.AttachFileMedia), "-v", "--export-manifest", pulledManifest). MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, true, 1). WithWorkDir(tempDir). WithDescription("attach with manifest exported").Exec() session := ORAS("discover", subject, "-o", "json").Exec() digest := string(Binary("jq", "-r", ".manifests[].digest").WithInput(session.Out).Exec().Out.Contents()) - fetched := ORAS("manifest", "fetch", RegistryRef(Host, repo, digest)).MatchKeyWords(foobar.AttachFileMedia).Exec() + fetched := ORAS("manifest", "fetch", RegistryRef(ZotHost, repo, digest)).MatchKeyWords(foobar.AttachFileMedia).Exec() MatchFile(filepath.Join(tempDir, pulledManifest), string(fetched.Out.Contents()), DefaultTimeout) - ORAS("pull", RegistryRef(Host, repo, digest), "-v", "-o", pullRoot). + ORAS("pull", RegistryRef(ZotHost, repo, digest), "-v", "-o", pullRoot). MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, true, 1). WithWorkDir(tempDir). WithDescription("pull attached artifact").Exec() @@ -77,19 +77,17 @@ var _ = Describe("Common OCI artifact users:", Ordered, func() { WithWorkDir(tempDir). WithDescription("download identical file " + foobar.AttachFileName).Exec() - ORAS("attach", subject, "--artifact-type", "test.artifact2", fmt.Sprint(foobar.AttachFileName, ":", foobar.AttachFileMedia), "-v", "--export-manifest", pulledManifest). + ORAS("attach", subject, "--artifact-type", "test/artifact2", fmt.Sprint(foobar.AttachFileName, ":", foobar.AttachFileMedia), "-v", "--export-manifest", pulledManifest). MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, true, 1). WithWorkDir(tempDir). WithDescription("attach again with manifest exported").Exec() - // FIXME: oras distribution doesn't support OCI image with artifactType field - // Below test can be run after https://github.com/oras-project/oras/issues/1071 is done. - session = ORAS("discover", subject, "-o", "json", "--artifact-type", "test.artifact2").Exec() + session = ORAS("discover", subject, "-o", "json", "--artifact-type", "test/artifact2").Exec() digest = string(Binary("jq", "-r", ".manifests[].digest").WithInput(session.Out).Exec().Out.Contents()) - fetched = ORAS("manifest", "fetch", RegistryRef(Host, repo, digest)).MatchKeyWords(foobar.AttachFileMedia).Exec() + fetched = ORAS("manifest", "fetch", RegistryRef(ZotHost, repo, digest)).MatchKeyWords(foobar.AttachFileMedia).Exec() MatchFile(filepath.Join(tempDir, pulledManifest), string(fetched.Out.Contents()), DefaultTimeout) - ORAS("pull", RegistryRef(Host, repo, string(digest)), "-v", "-o", pullRoot, "--include-subject"). + ORAS("pull", RegistryRef(ZotHost, repo, string(digest)), "-v", "-o", pullRoot, "--include-subject"). MatchStatus(append(foobar.FileStateKeys, foobar.AttachFileStateKey), true, 4). WithWorkDir(tempDir). WithDescription("pull attached artifact and subject").Exec() From 35d8bd484dee63cdc1ac329f4fb1977cc4c5643a Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Wed, 23 Aug 2023 04:49:12 +0000 Subject: [PATCH 05/45] add password Signed-off-by: Billy Zha --- test/e2e/testdata/zot/passwd_bcrypt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/e2e/testdata/zot/passwd_bcrypt diff --git a/test/e2e/testdata/zot/passwd_bcrypt b/test/e2e/testdata/zot/passwd_bcrypt new file mode 100644 index 000000000..71e4a0113 --- /dev/null +++ b/test/e2e/testdata/zot/passwd_bcrypt @@ -0,0 +1 @@ +hello:$2y$05$7VA2NX15rMmt6Y14Ep7wReDybGvD8e7ko9tsxmvZQwnC4wBfG9Thy From 1700e2326586d5d7a8ecc9ce89f65ebd844502a5 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Wed, 23 Aug 2023 04:53:36 +0000 Subject: [PATCH 06/45] update description Signed-off-by: Billy Zha --- test/e2e/suite/command/attach.go | 26 ++++++++++++------------- test/e2e/suite/command/blob.go | 2 +- test/e2e/suite/command/cp.go | 2 +- test/e2e/suite/command/custom_header.go | 4 ++-- test/e2e/suite/command/discover.go | 4 ++-- test/e2e/suite/command/manifest.go | 2 +- test/e2e/suite/command/repo.go | 2 +- test/e2e/suite/command/resolve_host.go | 4 ++-- test/e2e/suite/command/tag.go | 2 +- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/test/e2e/suite/command/attach.go b/test/e2e/suite/command/attach.go index b0e5fba68..c9c58c2ee 100644 --- a/test/e2e/suite/command/attach.go +++ b/test/e2e/suite/command/attach.go @@ -67,14 +67,14 @@ var _ = Describe("ORAS beginners:", func() { }) }) -var _ = Describe("Common registry users:", func() { +var _ = Describe("1.1 registry users:", func() { When("running attach command", func() { It("should attach a file to a subject", func() { testRepo := attachTestRepo("simple") tempDir := PrepareTempFiles() subjectRef := RegistryRef(Host, testRepo, foobar.Tag) prepare(RegistryRef(Host, ImageRepo, foobar.Tag), subjectRef) - ORAS("attach", "--artifact-type", "test.attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)). + ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)). WithWorkDir(tempDir). MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, false, 1).Exec() }) @@ -87,7 +87,7 @@ var _ = Describe("Common registry users:", func() { subjectRef := RegistryRef(Host, testRepo, foobar.Tag) prepare(RegistryRef(Host, ImageRepo, foobar.Tag), subjectRef) // test - ORAS("attach", "--artifact-type", "test.attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia), "--export-manifest", exportName). + ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia), "--export-manifest", exportName). WithWorkDir(tempDir). MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, false, 1).Exec() // validate @@ -105,7 +105,7 @@ var _ = Describe("Common registry users:", func() { subjectRef := RegistryRef(Host, testRepo, foobar.Tag) prepare(RegistryRef(Host, ImageRepo, foobar.Tag), subjectRef) // test - ORAS("attach", "--artifact-type", "test.attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)). + ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)). WithWorkDir(tempDir). MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, false, 1).Exec() // validate @@ -124,7 +124,7 @@ var _ = Describe("Common registry users:", func() { prepare(RegistryRef(Host, ImageRepo, foobar.Tag), subjectRef) statusKey := foobar.AttachFileStateKey statusKey.Name = absAttachFileName - ORAS("attach", "--artifact-type", "test.attach", subjectRef, fmt.Sprintf("%s:%s", absAttachFileName, foobar.AttachFileMedia), "--disable-path-validation"). + ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", absAttachFileName, foobar.AttachFileMedia), "--disable-path-validation"). MatchStatus([]match.StateKey{statusKey}, false, 1). Exec() }) @@ -137,14 +137,14 @@ var _ = Describe("Common registry users:", func() { prepare(RegistryRef(Host, ImageRepo, foobar.Tag), subjectRef) statusKey := foobar.AttachFileStateKey statusKey.Name = absAttachFileName - ORAS("attach", "--artifact-type", "test.attach", subjectRef, fmt.Sprintf("%s:%s", absAttachFileName, foobar.AttachFileMedia)). + ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", absAttachFileName, foobar.AttachFileMedia)). ExpectFailure(). Exec() }) }) }) -var _ = Describe("Fallback registry users:", func() { +var _ = Describe("1.0 registry users:", func() { When("running attach command", func() { It("should attach a file via a OCI Image", func() { testRepo := attachTestRepo("fallback/image") @@ -152,7 +152,7 @@ var _ = Describe("Fallback registry users:", func() { subjectRef := RegistryRef(FallbackHost, testRepo, foobar.Tag) prepare(RegistryRef(FallbackHost, ArtifactRepo, foobar.Tag), subjectRef) // test - ORAS("attach", "--artifact-type", "test.attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)). + ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)). WithWorkDir(tempDir). MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, false, 1).Exec() @@ -170,7 +170,7 @@ var _ = Describe("Fallback registry users:", func() { subjectRef := RegistryRef(FallbackHost, testRepo, foobar.Tag) prepare(RegistryRef(FallbackHost, ArtifactRepo, foobar.Tag), subjectRef) // test - ORAS("attach", "--artifact-type", "test.attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)). + ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)). WithWorkDir(tempDir). MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, false, 1).Exec() @@ -188,7 +188,7 @@ var _ = Describe("Fallback registry users:", func() { subjectRef := RegistryRef(FallbackHost, testRepo, foobar.Tag) prepare(RegistryRef(FallbackHost, ArtifactRepo, foobar.Tag), subjectRef) // test - ORAS("attach", "--artifact-type", "test.attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia), "--distribution-spec", "v1.1-referrers-tag"). + ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia), "--distribution-spec", "v1.1-referrers-tag"). WithWorkDir(tempDir). MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, false, 1).Exec() @@ -211,7 +211,7 @@ var _ = Describe("OCI image layout users:", func() { root := PrepareTempFiles() subjectRef := LayoutRef(root, foobar.Tag) prepare(root) - ORAS("attach", "--artifact-type", "test.attach", Flags.Layout, subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)). + ORAS("attach", "--artifact-type", "test/attach", Flags.Layout, subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)). WithWorkDir(root). MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, false, 1).Exec() }) @@ -223,7 +223,7 @@ var _ = Describe("OCI image layout users:", func() { subjectRef := LayoutRef(root, foobar.Tag) prepare(root) // test - ORAS("attach", "--artifact-type", "test.attach", Flags.Layout, subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia), "--export-manifest", exportName). + ORAS("attach", "--artifact-type", "test/attach", Flags.Layout, subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia), "--export-manifest", exportName). WithWorkDir(root). MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, false, 1).Exec() // validate @@ -240,7 +240,7 @@ var _ = Describe("OCI image layout users:", func() { subjectRef := LayoutRef(root, foobar.Tag) prepare(root) // test - ORAS("attach", "--artifact-type", "test.attach", Flags.Layout, subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)). + ORAS("attach", "--artifact-type", "test/attach", Flags.Layout, subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)). WithWorkDir(root). MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, false, 1).Exec() diff --git a/test/e2e/suite/command/blob.go b/test/e2e/suite/command/blob.go index 12ca81dd2..abf1d0a83 100644 --- a/test/e2e/suite/command/blob.go +++ b/test/e2e/suite/command/blob.go @@ -164,7 +164,7 @@ var _ = Describe("ORAS beginners:", func() { }) }) -var _ = Describe("Common registry users:", func() { +var _ = Describe("1.1 registry users:", func() { repoFmt := fmt.Sprintf("command/blob/%%s/%d/%%s", GinkgoRandomSeed()) When("running `blob delete`", func() { It("should delete a blob with interactive confirmation", func() { diff --git a/test/e2e/suite/command/cp.go b/test/e2e/suite/command/cp.go index 4b49187fa..3d06cf1e4 100644 --- a/test/e2e/suite/command/cp.go +++ b/test/e2e/suite/command/cp.go @@ -68,7 +68,7 @@ func CompareRef(src, dst string) { Expect(srcManifest).To(Equal(dstManifest)) } -var _ = Describe("Common registry users:", func() { +var _ = Describe("1.1 registry users:", func() { When("running `cp`", func() { It("should copy an image to a new repository via tag", func() { src := RegistryRef(Host, ImageRepo, foobar.Tag) diff --git a/test/e2e/suite/command/custom_header.go b/test/e2e/suite/command/custom_header.go index 05408174f..1920ef14d 100644 --- a/test/e2e/suite/command/custom_header.go +++ b/test/e2e/suite/command/custom_header.go @@ -24,7 +24,7 @@ import ( . "oras.land/oras/test/e2e/internal/utils" ) -var _ = Describe("Common registry users:", func() { +var _ = Describe("1.1 registry users:", func() { headerTestRepo := func(text string) string { return fmt.Sprintf("command/headertest/%d/%s", GinkgoRandomSeed(), text) } @@ -40,7 +40,7 @@ var _ = Describe("Common registry users:", func() { tempDir := PrepareTempFiles() subjectRef := RegistryRef(Host, testRepo, foobar.Tag) prepare(RegistryRef(Host, ImageRepo, foobar.Tag), subjectRef) - ORAS("attach", "--artifact-type", "test.attach", subjectRef, + ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia), "-d", "-H", FoobarHeaderInput, "-H", AbHeaderInput). WithWorkDir(tempDir).MatchRequestHeaders(FoobarHeader, AbHeader).Exec() diff --git a/test/e2e/suite/command/discover.go b/test/e2e/suite/command/discover.go index 22d717d02..15d3ba771 100644 --- a/test/e2e/suite/command/discover.go +++ b/test/e2e/suite/command/discover.go @@ -66,7 +66,7 @@ var _ = Describe("ORAS beginners:", func() { }) }) -var _ = Describe("Common registry users:", func() { +var _ = Describe("1.1 registry users:", func() { subjectRef := RegistryRef(Host, ArtifactRepo, foobar.Tag) When("running discover command with json output", func() { format := "json" @@ -137,7 +137,7 @@ var _ = Describe("Common registry users:", func() { }) }) -var _ = Describe("Fallback registry users:", func() { +var _ = Describe("1.0 registry users:", func() { subjectRef := RegistryRef(FallbackHost, ArtifactRepo, foobar.Tag) When("running discover command", func() { It("should discover direct referrers of a subject via json output", func() { diff --git a/test/e2e/suite/command/manifest.go b/test/e2e/suite/command/manifest.go index 109e4ecc3..44d8f4ff0 100644 --- a/test/e2e/suite/command/manifest.go +++ b/test/e2e/suite/command/manifest.go @@ -168,7 +168,7 @@ var _ = Describe("ORAS beginners:", func() { }) }) -var _ = Describe("Common registry users:", func() { +var _ = Describe("1.1 registry users:", func() { repoFmt := fmt.Sprintf("command/manifest/%%s/%d/%%s", GinkgoRandomSeed()) When("running `manifest fetch`", func() { It("should fetch manifest list with digest", func() { diff --git a/test/e2e/suite/command/repo.go b/test/e2e/suite/command/repo.go index 9cfa3e15e..844c9f5f1 100644 --- a/test/e2e/suite/command/repo.go +++ b/test/e2e/suite/command/repo.go @@ -64,7 +64,7 @@ var _ = Describe("ORAS beginners:", func() { }) }) -var _ = Describe("Common registry users:", func() { +var _ = Describe("1.1 registry users:", func() { When("running `repo ls`", func() { It("should list repositories", func() { ORAS("repository", "list", Host).MatchKeyWords(ImageRepo).Exec() diff --git a/test/e2e/suite/command/resolve_host.go b/test/e2e/suite/command/resolve_host.go index 4a5815a21..a6e95bd47 100644 --- a/test/e2e/suite/command/resolve_host.go +++ b/test/e2e/suite/command/resolve_host.go @@ -67,7 +67,7 @@ func ResolveFlags(reg string, host string, flagType resolveType) []string { return []string{fp + resolveFlag, fmt.Sprintf("%s:80:127.0.0.1:%s", host, port), fp + usernameFlag, Username, fp + passwordFlag, Password, fp + plainHttpFlag} } -var _ = Describe("Common registry users:", func() { +var _ = Describe("1.1 registry users:", func() { if strings.HasPrefix(Host, "localhost:") { When("custom host is provided", func() { // mockedHost represents a non-existent host name which @@ -85,7 +85,7 @@ var _ = Describe("Common registry users:", func() { tempDir := PrepareTempFiles() prepare(RegistryRef(Host, ImageRepo, foobar.Tag), RegistryRef(Host, repo, foobar.Tag)) - ORAS(append([]string{"attach", "--artifact-type", "test.attach", RegistryRef(mockedHost, repo, foobar.Tag), fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)}, unary...)...). + ORAS(append([]string{"attach", "--artifact-type", "test/attach", RegistryRef(mockedHost, repo, foobar.Tag), fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)}, unary...)...). WithWorkDir(tempDir). MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, false, 1).Exec() // validate diff --git a/test/e2e/suite/command/tag.go b/test/e2e/suite/command/tag.go index d5836ee26..2a012acc2 100644 --- a/test/e2e/suite/command/tag.go +++ b/test/e2e/suite/command/tag.go @@ -42,7 +42,7 @@ var _ = Describe("ORAS beginners:", func() { }) }) -var _ = Describe("Common registry users:", func() { +var _ = Describe("1.1 registry users:", func() { var tagAndValidate = func(reg string, repo string, tagOrDigest string, digest string, tags ...string) { out := ORAS(append([]string{"tag", RegistryRef(reg, repo, tagOrDigest)}, tags...)...).MatchKeyWords(tags...).Exec().Out hint := regexp.QuoteMeta(fmt.Sprintf("Tagging [registry] %s", RegistryRef(reg, repo, digest))) From 7267ca47714b48fabe6776f16bc6b68df9314c38 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Wed, 23 Aug 2023 06:44:35 +0000 Subject: [PATCH 07/45] separate prepare script out Signed-off-by: Billy Zha --- Makefile | 2 +- test/e2e/README.md | 31 +++++++++++------- test/e2e/scripts/e2e.sh | 62 ++++++++++------------------------- test/e2e/scripts/prepare.sh | 64 +++++++++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 58 deletions(-) create mode 100644 test/e2e/scripts/prepare.sh diff --git a/Makefile b/Makefile index df548f223..ffd8d526c 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ test: tidy vendor check-encoding ## tidy and run tests .PHONY: teste2e teste2e: ## run end to end tests - ./test/e2e/scripts/e2e.sh $(shell git rev-parse --show-toplevel) --clean + ./test/e2e/scripts/e2e.sh $(shell git rev-parse --show-toplevel) --clean .PHONY: covhtml covhtml: ## look at code coverage diff --git a/test/e2e/README.md b/test/e2e/README.md index 15be2cff1..5837e3a47 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -5,8 +5,8 @@ Install [git](https://git-scm.com/download/linux), [docker](https://docs.docker. ## Run E2E Script ```shell -REPO_ROOT=$(git rev-parse --show-toplevel) # REPO_ROOT is root folder of oras CLI code -$REPO_ROOT/test/e2e/scripts/e2e.sh $REPO_ROOT --clean +# in root folder of oras CLI code +make teste2e ``` If the tests fails with errors like `ginkgo: not found`, use below command to add GOPATH into the PATH variable @@ -15,13 +15,20 @@ PATH+=:$(go env GOPATH)/bin ``` ## Development -### 1. Using IDE +### 1. Prepare E2E Test Environment +You may use the prepare script to setup an E2E test environment before developing E2E tests: +```shell +REPO_ROOT=$(git rev-parse --show-toplevel) # REPO_ROOT is root folder of oras CLI code +$REPO_ROOT/test/e2e/scripts/prepare.sh $REPO_ROOT +``` + +### 2. Using IDE Since E2E test suites are added as an nested module, the module file and checksum file are separated from oras CLI. To develop E2E tests, it's better to set the working directory to `$REPO_ROOT/test/e2e/` or open your IDE at it. -### 2. Testing pre-built ORAS Binary +### 3. Testing pre-built ORAS Binary By default, Gomega builds a temp binary every time before running e2e tests, which makes sure that latest code changes in the working directory are covered. If you are making changes to E2E test code only, set `ORAS_PATH` towards your pre-built ORAS binary to skip building and speed up the test. -### 3. Debugging via `go test` +### 4. Debugging via `go test` E2E specs can be ran natively without `ginkgo`: ```shell # run below command in the target test suite folder @@ -29,7 +36,7 @@ go test oras.land/oras/test/e2e/suite/${suite_name} ``` This is super handy when you want to do step-by-step debugging from command-line or via an IDE. If you need to debug certain specs, use [focused specs](https://onsi.github.io/ginkgo/#focused-specs) but don't check it in. -### 4. Testing Registry Services +### 5. Testing Registry Services The backend of E2E tests are three registry services: - [oras-distribution](https://github.com/oras-project/distribution): registry service supports artifact and image types in [image-spec 1.1.0 rc2](https://github.com/opencontainers/image-spec/tree/v1.1.0-rc2) and referrer API - [upstream distribution](https://github.com/distribution/distribution): registry service supports image media type with subject and provide referrers via [tag schema](https://github.com/opencontainers/distribution-spec/blob/v1.1.0-rc1/spec.md#referrers-tag-schema). @@ -37,17 +44,17 @@ The backend of E2E tests are three registry services: You can run scenario test suite against your own registry services via setting `ORAS_REGISTRY_HOST`, `ORAS_REGISTRY_FALLBACK_HOST` and `ZOT_REGISTRY_HOST` environmental variables. -### 5. Constant Build & Watch +### 6. Constant Build & Watch This is a good choice if you want to debug certain re-runnable specs: ```shell cd $REPO_ROOT/test/e2e ginkgo watch -r ``` -### 6. Trouble-shooting CLI +### 7. Trouble-shooting CLI The executed commands should be shown in the ginkgo logs after `[It]`, with full execution output in the E2E log. -### 7. Adding New Tests +### 8. Adding New Tests Three suites will be maintained for E2E testing: - command: contains test specs for single oras command execution - auth: contains test specs similar to command specs but specific to auth. It cannot be ran in parallel with command suite specs @@ -62,9 +69,9 @@ Describe: Expect: (detailed checks for execution results) ``` -### 8. Adding New Test Data +### 9. Adding New Test Data -#### 8.1 Command Suite +#### 9.1 Command Suite Command suite uses pre-baked test data, which is a bunch of layered archive files compressed from registry storage. Test data are all stored in `$REPO_ROOT/test/e2e/testdata/distribution/` but separated in different sub-folders: oras distribution uses `mount` and upstream distribution uses `mount_fallback`. For both registries, the repository name should follow the convention of `command/$repo_suffix`. To add a new layer to the test data, use the below command to compress the `docker` folder from the root directory of the registry storage and copy it to the corresponding subfolder in `$REPO_ROOT/test/e2e/testdata/distribution/mount`. @@ -138,5 +145,5 @@ graph TD; end end ``` -#### 8.2 Scenario Suite +#### 9.2 Scenario Suite Test files used by scenario-based specs are placed in `$REPO_ROOT/test/e2e/testdata/files`. \ No newline at end of file diff --git a/test/e2e/scripts/e2e.sh b/test/e2e/scripts/e2e.sh index 1198b4873..3e9b7989c 100755 --- a/test/e2e/scripts/e2e.sh +++ b/test/e2e/scripts/e2e.sh @@ -13,62 +13,34 @@ # See the License for the specific language governing permissions and # limitations under the License. -export ORAS_REGISTRY_PORT="5000" -export ORAS_REGISTRY_HOST="localhost:${ORAS_REGISTRY_PORT}" -export ORAS_REGISTRY_FALLBACK_PORT="6000" -export ORAS_REGISTRY_FALLBACK_HOST="localhost:${ORAS_REGISTRY_FALLBACK_PORT}" -export ZOT_REGISTRY_PORT="7000" -export ZOT_REGISTRY_HOST="localhost:${ZOT_REGISTRY_PORT}" +# help +help () { + echo "Usage" + echo " e2e.sh [--clean]" + exit 1 +} +# 1. Prepare repo_root=$1 if [ -z "${repo_root}" ]; then echo "repository root path is not provided." - echo "Usage" - echo " e2e.sh [--clean]" - exit 1 + help fi -clean_up=$2 -echo " === installing ginkgo === " -repo_root=$(realpath --canonicalize-existing ${repo_root}) -cwd=$(pwd) -cd ${repo_root}/test/e2e && go install github.com/onsi/ginkgo/v2/ginkgo@latest -trap "cd $cwd" EXIT - -# start registries -. ${repo_root}/test/e2e/scripts/common.sh +clean=$2 +if [ "${clean}" != '--clean' ] && [ -n "${clean}" ]; then + echo "invalid flag found: ${clean}" + help +fi -e2e_root="${repo_root}/test/e2e" -oras_container_name="oras-e2e" -upstream_container_name="oras-e2e-fallback" -zot_container_name="oras-e2e-zot" +. ${repo_root}/test/e2e/scripts/prepare.sh $1 $2 -if [ "$clean_up" = '--clean' ]; then +if [ "${clean}" = '--clean' ]; then echo " === setting deferred clean up jobs === " - trap "try_clean_up $oras_container_name $upstream_container_name $zot_container_name" EXIT + trap "try_clean_up $ORAS_CTR_NAME $UPSTREAM_CTR_NAME $ZOT_CTR_NAME" EXIT fi -echo " === preparing oras distribution === " -run_registry \ - ${e2e_root}/testdata/distribution/mount \ - ghcr.io/oras-project/registry:v1.0.0-rc.4 \ - $oras_container_name \ - $ORAS_REGISTRY_PORT - -echo " === preparing upstream distribution === " -run_registry \ - ${e2e_root}/testdata/distribution/mount_fallback \ - registry:2.8.1 \ - $upstream_container_name \ - $ORAS_REGISTRY_FALLBACK_PORT - -echo " === preparing zot === " -try_clean_up $zot_container_name -docker run -d -p $ZOT_REGISTRY_PORT:5000 -it \ - --name $zot_container_name \ - --mount type=bind,source="${e2e_root}/testdata/zot/",target=/etc/zot \ - --rm ghcr.io/project-zot/zot-linux-amd64:v2.0.0-rc6 - +# 2. Test echo " === run tests === " if ! ginkgo -r -p --succinct suite; then echo " === retriving registry error logs === " diff --git a/test/e2e/scripts/prepare.sh b/test/e2e/scripts/prepare.sh new file mode 100644 index 000000000..1098777c6 --- /dev/null +++ b/test/e2e/scripts/prepare.sh @@ -0,0 +1,64 @@ +#!/bin/sh -e + +# Copyright The ORAS Authors. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +export ORAS_REGISTRY_PORT="5000" +export ORAS_REGISTRY_HOST="localhost:${ORAS_REGISTRY_PORT}" +export ORAS_REGISTRY_FALLBACK_PORT="6000" +export ORAS_REGISTRY_FALLBACK_HOST="localhost:${ORAS_REGISTRY_FALLBACK_PORT}" +export ZOT_REGISTRY_PORT="7000" +export ZOT_REGISTRY_HOST="localhost:${ZOT_REGISTRY_PORT}" +export ORAS_CTR_NAME="oras-e2e" +export UPSTREAM_CTR_NAME="oras-e2e-fallback" +export ZOT_CTR_NAME="oras-e2e-zot" + +repo_root=$1 +if [ -z "${repo_root}" ]; then + echo "repository root path is not provided." + echo "Usage" + echo " prepare.sh " + exit 1 +fi +e2e_root="${repo_root}/test/e2e" + +echo " === installing ginkgo === " +repo_root=$(realpath --canonicalize-existing ${repo_root}) +cwd=$(pwd) +cd ${repo_root}/test/e2e && go install github.com/onsi/ginkgo/v2/ginkgo@latest +trap "cd $cwd" EXIT + +# start registries +. ${repo_root}/test/e2e/scripts/common.sh + + +echo " === preparing oras distribution === " +run_registry \ + ${e2e_root}/testdata/distribution/mount \ + ghcr.io/oras-project/registry:v1.0.0-rc.4 \ + $ORAS_CTR_NAME \ + $ORAS_REGISTRY_PORT + +echo " === preparing upstream distribution === " +run_registry \ + ${e2e_root}/testdata/distribution/mount_fallback \ + registry:2.8.1 \ + $UPSTREAM_CTR_NAME \ + $ORAS_REGISTRY_FALLBACK_PORT + +echo " === preparing zot === " +try_clean_up $ZOT_CTR_NAME +docker run -d -p $ZOT_REGISTRY_PORT:5000 -it \ + --name $ZOT_CTR_NAME \ + --mount type=bind,source="${e2e_root}/testdata/zot/",target=/etc/zot \ + --rm ghcr.io/project-zot/zot-linux-amd64:v2.0.0-rc6 From a2cc4ea857068a488f9a7388ef8562ab89b03599 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Wed, 23 Aug 2023 07:06:46 +0000 Subject: [PATCH 08/45] check in zot config Signed-off-by: Billy Zha --- test/e2e/testdata/zot/config.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test/e2e/testdata/zot/config.json diff --git a/test/e2e/testdata/zot/config.json b/test/e2e/testdata/zot/config.json new file mode 100644 index 000000000..3eab8b75d --- /dev/null +++ b/test/e2e/testdata/zot/config.json @@ -0,0 +1,17 @@ +{ + "storage": { + "rootDirectory": "/var/lib/registry" + }, + "http": { + "address": "0.0.0.0", + "port": "5000", + "auth": { + "htpasswd": { + "path": "/etc/zot/passwd_bcrypt" + } + } + }, + "log": { + "level": "debug" + } +} \ No newline at end of file From e5f73987598f056acd22711edfeff309e7b73b32 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Wed, 23 Aug 2023 07:09:05 +0000 Subject: [PATCH 09/45] add run access Signed-off-by: Billy Zha --- test/e2e/scripts/prepare.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 test/e2e/scripts/prepare.sh diff --git a/test/e2e/scripts/prepare.sh b/test/e2e/scripts/prepare.sh old mode 100644 new mode 100755 From 2feed93ba54ef9b9481fd00e6200c16177094c06 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Wed, 23 Aug 2023 07:17:05 +0000 Subject: [PATCH 10/45] fix prepare bug Signed-off-by: Billy Zha --- test/e2e/scripts/prepare.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/e2e/scripts/prepare.sh b/test/e2e/scripts/prepare.sh index 1098777c6..cb5593d29 100755 --- a/test/e2e/scripts/prepare.sh +++ b/test/e2e/scripts/prepare.sh @@ -30,7 +30,6 @@ if [ -z "${repo_root}" ]; then echo " prepare.sh " exit 1 fi -e2e_root="${repo_root}/test/e2e" echo " === installing ginkgo === " repo_root=$(realpath --canonicalize-existing ${repo_root}) @@ -40,25 +39,27 @@ trap "cd $cwd" EXIT # start registries . ${repo_root}/test/e2e/scripts/common.sh - - -echo " === preparing oras distribution === " +echo " >>> preparing: oras distribution >>> " +e2e_root="${repo_root}/test/e2e" run_registry \ ${e2e_root}/testdata/distribution/mount \ ghcr.io/oras-project/registry:v1.0.0-rc.4 \ $ORAS_CTR_NAME \ $ORAS_REGISTRY_PORT +echo " <<< prepared : oras distribution <<< " -echo " === preparing upstream distribution === " +echo " >>> preparing: upstream distribution >>> " run_registry \ ${e2e_root}/testdata/distribution/mount_fallback \ registry:2.8.1 \ $UPSTREAM_CTR_NAME \ $ORAS_REGISTRY_FALLBACK_PORT +echo " prepared : upstream distribution " -echo " === preparing zot === " +echo " >>> preparing: zot >>> " try_clean_up $ZOT_CTR_NAME docker run -d -p $ZOT_REGISTRY_PORT:5000 -it \ --name $ZOT_CTR_NAME \ --mount type=bind,source="${e2e_root}/testdata/zot/",target=/etc/zot \ --rm ghcr.io/project-zot/zot-linux-amd64:v2.0.0-rc6 +echo " <<< prepared : zot <<< " From 96fc8899b841d4812b2f8f6d7422d43ac49ca208 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Thu, 24 Aug 2023 02:05:59 +0000 Subject: [PATCH 11/45] remove prepare changes Signed-off-by: Billy Zha --- test/e2e/internal/utils/prepare.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/e2e/internal/utils/prepare.go b/test/e2e/internal/utils/prepare.go index 3359d2b86..eea029237 100644 --- a/test/e2e/internal/utils/prepare.go +++ b/test/e2e/internal/utils/prepare.go @@ -28,12 +28,6 @@ import ( "github.com/onsi/gomega/gbytes" ) -func PrepareRepository() string { - tempDir := GinkgoT().TempDir() - Expect(CopyTestFiles(tempDir)).ShouldNot(HaveOccurred()) - return tempDir -} - // PrepareTempFiles copies test data into a temp folder and return it. func PrepareTempFiles() string { tempDir := GinkgoT().TempDir() From 2c2b597e02d42b716a401c014c819307d04412af Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Fri, 25 Aug 2023 05:55:05 +0000 Subject: [PATCH 12/45] run zot container via current user Signed-off-by: Billy Zha --- test/e2e/scripts/prepare.sh | 3 ++- test/e2e/testdata/zot/config.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/test/e2e/scripts/prepare.sh b/test/e2e/scripts/prepare.sh index cb5593d29..e040507ef 100755 --- a/test/e2e/scripts/prepare.sh +++ b/test/e2e/scripts/prepare.sh @@ -58,8 +58,9 @@ echo " prepared : upstream distribution " echo " >>> preparing: zot >>> " try_clean_up $ZOT_CTR_NAME -docker run -d -p $ZOT_REGISTRY_PORT:5000 -it \ +docker run --pull always -dp $ZOT_REGISTRY_PORT:5000 \ --name $ZOT_CTR_NAME \ + -u $(id -u $(whoami)) \ --mount type=bind,source="${e2e_root}/testdata/zot/",target=/etc/zot \ --rm ghcr.io/project-zot/zot-linux-amd64:v2.0.0-rc6 echo " <<< prepared : zot <<< " diff --git a/test/e2e/testdata/zot/config.json b/test/e2e/testdata/zot/config.json index 3eab8b75d..843360d91 100644 --- a/test/e2e/testdata/zot/config.json +++ b/test/e2e/testdata/zot/config.json @@ -1,6 +1,6 @@ { "storage": { - "rootDirectory": "/var/lib/registry" + "rootDirectory": "/etc/zot" }, "http": { "address": "0.0.0.0", From 6f9f3c2a12ad250400bac76dcd06bb09f1786f63 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Fri, 25 Aug 2023 05:58:45 +0000 Subject: [PATCH 13/45] rename zot Signed-off-by: Billy Zha --- test/e2e/internal/utils/init.go | 16 +++++----- test/e2e/internal/utils/testdata.go | 2 +- test/e2e/suite/auth/auth.go | 40 ++++++++++++------------- test/e2e/suite/scenario/oci_artifact.go | 16 +++++----- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/test/e2e/internal/utils/init.go b/test/e2e/internal/utils/init.go index 977cd4f8d..5218aa367 100644 --- a/test/e2e/internal/utils/init.go +++ b/test/e2e/internal/utils/init.go @@ -36,8 +36,8 @@ var Host string // FallbackHost points to the registry service where fallback E2E specs will be run against. var FallbackHost string -// ZotHost points to the zot service where E2E specs will be run against. -var ZotHost string +// ZOTHost points to the zot service where E2E specs will be run against. +var ZOTHost string func init() { Host = os.Getenv(RegHostKey) @@ -62,12 +62,12 @@ func init() { panic(err) } - ZotHost = os.Getenv(ZotHostKey) - if ZotHost == "" { - ZotHost = "localhost:7000" - fmt.Fprintf(os.Stderr, "cannot find zot host name in %s, using %s instead\n", ZotHostKey, ZotHost) + ZOTHost = os.Getenv(ZOTHostKey) + if ZOTHost == "" { + ZOTHost = "localhost:7000" + fmt.Fprintf(os.Stderr, "cannot find zot host name in %s, using %s instead\n", ZOTHostKey, ZOTHost) } - ref.Registry = ZotHost + ref.Registry = ZOTHost if err := ref.ValidateRegistry(); err != nil { panic(err) } @@ -124,7 +124,7 @@ func init() { gomega.Expect(cmd.Run()).ShouldNot(gomega.HaveOccurred()) cmd = exec.Command(ORASPath, "login", FallbackHost, "-u", Username, "-p", Password) gomega.Expect(cmd.Run()).ShouldNot(gomega.HaveOccurred()) - cmd = exec.Command(ORASPath, "login", ZotHost, "-u", Username, "-p", Password) + cmd = exec.Command(ORASPath, "login", ZOTHost, "-u", Username, "-p", Password) gomega.Expect(cmd.Run()).ShouldNot(gomega.HaveOccurred()) }) } diff --git a/test/e2e/internal/utils/testdata.go b/test/e2e/internal/utils/testdata.go index eb7e4ab28..c29cce1f8 100644 --- a/test/e2e/internal/utils/testdata.go +++ b/test/e2e/internal/utils/testdata.go @@ -25,7 +25,7 @@ const ( // env RegHostKey = "ORAS_REGISTRY_HOST" FallbackRegHostKey = "ORAS_REGISTRY_FALLBACK_HOST" - ZotHostKey = "ZOT_REGISTRY_HOST" + ZOTHostKey = "ZOT_REGISTRY_HOST" ) var ( diff --git a/test/e2e/suite/auth/auth.go b/test/e2e/suite/auth/auth.go index 49176c78e..e664e6cbc 100644 --- a/test/e2e/suite/auth/auth.go +++ b/test/e2e/suite/auth/auth.go @@ -27,38 +27,38 @@ import ( var _ = Describe("Common registry user", Ordered, func() { When("logging out", Ordered, func() { It("should use logout command to logout", func() { - ORAS("logout", ZotHost, "--registry-config", AuthConfigPath).Exec() + ORAS("logout", ZOTHost, "--registry-config", AuthConfigPath).Exec() }) It("should run commands without logging in", func() { - RunWithoutLogin("attach", ZotHost+"/repo:tag", "-a", "test=true", "--artifact-type", "doc/example") - ORAS("copy", ZotHost+"/repo:from", ZotHost+"/repo:to", "--from-registry-config", AuthConfigPath, "--to-registry-config", AuthConfigPath). + RunWithoutLogin("attach", ZOTHost+"/repo:tag", "-a", "test=true", "--artifact-type", "doc/example") + ORAS("copy", ZOTHost+"/repo:from", ZOTHost+"/repo:to", "--from-registry-config", AuthConfigPath, "--to-registry-config", AuthConfigPath). ExpectFailure(). MatchErrKeyWords("Error:", "credential required"). WithDescription("fail without logging in").Exec() - RunWithoutLogin("discover", ZotHost+"/repo:tag") - RunWithoutLogin("push", "-a", "key=value", ZotHost+"/repo:tag") - RunWithoutLogin("pull", ZotHost+"/repo:tag") - RunWithoutLogin("manifest", "fetch", ZotHost+"/repo:tag") - RunWithoutLogin("blob", "delete", ZotHost+"/repo@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") - RunWithoutLogin("blob", "push", ZotHost+"/repo", WriteTempFile("blob", "test")) - RunWithoutLogin("tag", ZotHost+"/repo:tag", "tag1") - RunWithoutLogin("repo", "ls", ZotHost) - RunWithoutLogin("repo", "tags", RegistryRef(ZotHost, "repo", "")) - RunWithoutLogin("manifest", "fetch-config", ZotHost+"/repo:tag") + RunWithoutLogin("discover", ZOTHost+"/repo:tag") + RunWithoutLogin("push", "-a", "key=value", ZOTHost+"/repo:tag") + RunWithoutLogin("pull", ZOTHost+"/repo:tag") + RunWithoutLogin("manifest", "fetch", ZOTHost+"/repo:tag") + RunWithoutLogin("blob", "delete", ZOTHost+"/repo@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") + RunWithoutLogin("blob", "push", ZOTHost+"/repo", WriteTempFile("blob", "test")) + RunWithoutLogin("tag", ZOTHost+"/repo:tag", "tag1") + RunWithoutLogin("repo", "ls", ZOTHost) + RunWithoutLogin("repo", "tags", RegistryRef(ZOTHost, "repo", "")) + RunWithoutLogin("manifest", "fetch-config", ZOTHost+"/repo:tag") }) }) When("logging in", func() { It("should use basic auth", func() { - ORAS("login", ZotHost, "-u", Username, "-p", Password, "--registry-config", AuthConfigPath). + ORAS("login", ZOTHost, "-u", Username, "-p", Password, "--registry-config", AuthConfigPath). WithTimeOut(20*time.Second). MatchContent("Login Succeeded\n"). MatchErrKeyWords("WARNING", "Using --password via the CLI is insecure", "Use --password-stdin").Exec() }) It("should fail if no username input", func() { - ORAS("login", ZotHost, "--registry-config", AuthConfigPath). + ORAS("login", ZOTHost, "--registry-config", AuthConfigPath). WithTimeOut(20 * time.Second). WithInput(strings.NewReader("")). MatchKeyWords("username:"). @@ -67,14 +67,14 @@ var _ = Describe("Common registry user", Ordered, func() { }) It("should fail if no password input", func() { - ORAS("login", ZotHost, "--registry-config", AuthConfigPath). + ORAS("login", ZOTHost, "--registry-config", AuthConfigPath). WithTimeOut(20*time.Second). MatchKeyWords("Username: ", "Password: "). WithInput(strings.NewReader(fmt.Sprintf("%s\n", Username))).ExpectFailure().Exec() }) It("should fail if password is empty", func() { - ORAS("login", ZotHost, "--registry-config", AuthConfigPath). + ORAS("login", ZOTHost, "--registry-config", AuthConfigPath). WithTimeOut(20*time.Second). MatchKeyWords("Username: ", "Password: "). MatchErrKeyWords("Error: password required"). @@ -82,14 +82,14 @@ var _ = Describe("Common registry user", Ordered, func() { }) It("should fail if no token input", func() { - ORAS("login", ZotHost, "--registry-config", AuthConfigPath). + ORAS("login", ZOTHost, "--registry-config", AuthConfigPath). WithTimeOut(20*time.Second). MatchKeyWords("Username: ", "Token: "). WithInput(strings.NewReader("\n")).ExpectFailure().Exec() }) It("should fail if token is empty", func() { - ORAS("login", ZotHost, "--registry-config", AuthConfigPath). + ORAS("login", ZOTHost, "--registry-config", AuthConfigPath). WithTimeOut(20*time.Second). MatchKeyWords("Username: ", "Token: "). MatchErrKeyWords("Error: token required"). @@ -97,7 +97,7 @@ var _ = Describe("Common registry user", Ordered, func() { }) It("should use prompted input", func() { - ORAS("login", ZotHost, "--registry-config", AuthConfigPath). + ORAS("login", ZOTHost, "--registry-config", AuthConfigPath). WithTimeOut(20*time.Second). WithInput(strings.NewReader(fmt.Sprintf("%s\n%s\n", Username, Password))). MatchKeyWords("Username: ", "Password: ", "Login Succeeded\n").Exec() diff --git a/test/e2e/suite/scenario/oci_artifact.go b/test/e2e/suite/scenario/oci_artifact.go index fe9d4eb74..326146464 100644 --- a/test/e2e/suite/scenario/oci_artifact.go +++ b/test/e2e/suite/scenario/oci_artifact.go @@ -37,15 +37,15 @@ var _ = Describe("OCI artifact users:", Ordered, func() { pulledManifest := "packed.json" pullRoot := "pulled" It("should push and pull an artifact", func() { - ORAS("push", RegistryRef(ZotHost, repo, tag), "--artifact-type", "test/artifact", foobar.FileLayerNames[0], foobar.FileLayerNames[1], foobar.FileLayerNames[2], "-v", "--export-manifest", pulledManifest). + ORAS("push", RegistryRef(ZOTHost, repo, tag), "--artifact-type", "test/artifact", foobar.FileLayerNames[0], foobar.FileLayerNames[1], foobar.FileLayerNames[2], "-v", "--export-manifest", pulledManifest). MatchStatus(foobar.FileStateKeys, true, 3). WithWorkDir(tempDir). WithDescription("push with manifest exported").Exec() - fetched := ORAS("manifest", "fetch", RegistryRef(ZotHost, repo, tag)).Exec() + fetched := ORAS("manifest", "fetch", RegistryRef(ZOTHost, repo, tag)).Exec() MatchFile(filepath.Join(tempDir, pulledManifest), string(fetched.Out.Contents()), DefaultTimeout) - ORAS("pull", RegistryRef(ZotHost, repo, tag), "-v", "-o", pullRoot). + ORAS("pull", RegistryRef(ZOTHost, repo, tag), "-v", "-o", pullRoot). MatchStatus(foobar.FileStateKeys, true, 3). WithWorkDir(tempDir). WithDescription("pull artFiles with config").Exec() @@ -58,7 +58,7 @@ var _ = Describe("OCI artifact users:", Ordered, func() { }) It("should attach and pull an artifact", func() { - subject := RegistryRef(ZotHost, repo, tag) + subject := RegistryRef(ZOTHost, repo, tag) ORAS("attach", subject, "--artifact-type", "test/artifact1", fmt.Sprint(foobar.AttachFileName, ":", foobar.AttachFileMedia), "-v", "--export-manifest", pulledManifest). MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, true, 1). WithWorkDir(tempDir). @@ -66,10 +66,10 @@ var _ = Describe("OCI artifact users:", Ordered, func() { session := ORAS("discover", subject, "-o", "json").Exec() digest := string(Binary("jq", "-r", ".manifests[].digest").WithInput(session.Out).Exec().Out.Contents()) - fetched := ORAS("manifest", "fetch", RegistryRef(ZotHost, repo, digest)).MatchKeyWords(foobar.AttachFileMedia).Exec() + fetched := ORAS("manifest", "fetch", RegistryRef(ZOTHost, repo, digest)).MatchKeyWords(foobar.AttachFileMedia).Exec() MatchFile(filepath.Join(tempDir, pulledManifest), string(fetched.Out.Contents()), DefaultTimeout) - ORAS("pull", RegistryRef(ZotHost, repo, digest), "-v", "-o", pullRoot). + ORAS("pull", RegistryRef(ZOTHost, repo, digest), "-v", "-o", pullRoot). MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, true, 1). WithWorkDir(tempDir). WithDescription("pull attached artifact").Exec() @@ -84,10 +84,10 @@ var _ = Describe("OCI artifact users:", Ordered, func() { session = ORAS("discover", subject, "-o", "json", "--artifact-type", "test/artifact2").Exec() digest = string(Binary("jq", "-r", ".manifests[].digest").WithInput(session.Out).Exec().Out.Contents()) - fetched = ORAS("manifest", "fetch", RegistryRef(ZotHost, repo, digest)).MatchKeyWords(foobar.AttachFileMedia).Exec() + fetched = ORAS("manifest", "fetch", RegistryRef(ZOTHost, repo, digest)).MatchKeyWords(foobar.AttachFileMedia).Exec() MatchFile(filepath.Join(tempDir, pulledManifest), string(fetched.Out.Contents()), DefaultTimeout) - ORAS("pull", RegistryRef(ZotHost, repo, string(digest)), "-v", "-o", pullRoot, "--include-subject"). + ORAS("pull", RegistryRef(ZOTHost, repo, string(digest)), "-v", "-o", pullRoot, "--include-subject"). MatchStatus(append(foobar.FileStateKeys, foobar.AttachFileStateKey), true, 4). WithWorkDir(tempDir). WithDescription("pull attached artifact and subject").Exec() From 0a0029216e326443b8f9f09d54ad69d4f4788bb9 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Fri, 25 Aug 2023 08:15:31 +0000 Subject: [PATCH 14/45] add images repo for command suite and attach tests Signed-off-by: Billy Zha --- .gitignore | 7 +++ test/e2e/internal/utils/prepare.go | 16 ++++++ test/e2e/suite/command/attach.go | 45 +++++++--------- ...1815e2881f1eec22958d604301904c5353041794c1 | 4 ++ ...3c1d30413413422d706483bfa0f98a5e886266e7ae | 1 + ...b5cc8fc5cc1fb637dfaedb3a9afc89bf16db9277e1 | Bin 0 -> 10240 bytes ...16f7e8649e94fb4fc21fe77e8310c060f61caaff8a | 1 + ...772dc6ab72130d9ac1906aed2fc7589a5cd145433c | 1 + ...007a025c594ce12aa7e6da27d21c7b14b50112e255 | 1 + ...8ed157ba7d1edfe7f9b8766728b8a1f25c0d9c14c1 | 1 + ...10591f0203bb6e07f11e2fb0ce1b8508e9aac4ebe2 | 5 ++ ...a28c6bc5806b7fa581c9ad7883be955a64e3cc034f | 1 + ...b721fe9b5c338d10ee429ea04fae5511b68fbf8fb9 | 1 + ...6cb4e7df0ab8a9d24adc57825099f522fe009a22bb | 1 + ...8c309f0b5afb2cc513b7a3d456b6cc29fe641386c5 | 4 ++ .../testdata/zot/command/images/index.json | 49 ++++++++++++++++++ .../testdata/zot/command/images/oci-layout | 1 + 17 files changed, 113 insertions(+), 26 deletions(-) create mode 100644 test/e2e/testdata/zot/command/images/blobs/sha256/1fd9a5fc54b634130102861815e2881f1eec22958d604301904c5353041794c1 create mode 100644 test/e2e/testdata/zot/command/images/blobs/sha256/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae create mode 100644 test/e2e/testdata/zot/command/images/blobs/sha256/2ef548696ac7dd66ef38aab5cc8fc5cc1fb637dfaedb3a9afc89bf16db9277e1 create mode 100644 test/e2e/testdata/zot/command/images/blobs/sha256/44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a create mode 100644 test/e2e/testdata/zot/command/images/blobs/sha256/4f93460061882467e6fb3b772dc6ab72130d9ac1906aed2fc7589a5cd145433c create mode 100644 test/e2e/testdata/zot/command/images/blobs/sha256/58efe73e78fe043ca31b89007a025c594ce12aa7e6da27d21c7b14b50112e255 create mode 100644 test/e2e/testdata/zot/command/images/blobs/sha256/9d84a5716c66a1d1b9c13f8ed157ba7d1edfe7f9b8766728b8a1f25c0d9c14c1 create mode 100644 test/e2e/testdata/zot/command/images/blobs/sha256/a5dfce5d28768e985f91f610591f0203bb6e07f11e2fb0ce1b8508e9aac4ebe2 create mode 100644 test/e2e/testdata/zot/command/images/blobs/sha256/e2bfc9cc6a84ec2d7365b5a28c6bc5806b7fa581c9ad7883be955a64e3cc034f create mode 100644 test/e2e/testdata/zot/command/images/blobs/sha256/fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9 create mode 100644 test/e2e/testdata/zot/command/images/blobs/sha256/fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb create mode 100644 test/e2e/testdata/zot/command/images/blobs/sha256/fe9dbc99451d0517d65e048c309f0b5afb2cc513b7a3d456b6cc29fe641386c5 create mode 100644 test/e2e/testdata/zot/command/images/index.json create mode 100644 test/e2e/testdata/zot/command/images/oci-layout diff --git a/.gitignore b/.gitignore index 0c2f8f30d..cb04bf2f0 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,10 @@ _dist/ # Distribution storage files for local E2E testing test/e2e/testdata/distribution/mount/docker/ test/e2e/testdata/distribution/mount_fallback/docker/ + + +# OCI Layout Files ZOT storage files for local E2E testing +test/e2e/testdata/zot/ +!test/e2e/testdata/zot/command/images +!test/e2e/testdata/zot/config.json +!test/e2e/testdata/zot/passwd_bcrypt \ No newline at end of file diff --git a/test/e2e/internal/utils/prepare.go b/test/e2e/internal/utils/prepare.go index eea029237..3416e6641 100644 --- a/test/e2e/internal/utils/prepare.go +++ b/test/e2e/internal/utils/prepare.go @@ -28,6 +28,22 @@ import ( "github.com/onsi/gomega/gbytes" ) +// CopyZotRepo copies oci layout data between repostories. +func CopyZotRepo(fromRepo string, toRepo string) { + zotRoot := filepath.Join(TestDataRoot, "zot") + fromRepo = filepath.Join(zotRoot, fromRepo) + toRepo = filepath.Join(zotRoot, toRepo) + Expect(CopyFiles(fromRepo, toRepo)).ShouldNot(HaveOccurred()) +} + +// PrepareTempOCI prepares an OCI layout root via copying from an ZOT repo and +// return the path. +func PrepareTempOCI(fromZotRepo string) string { + root := PrepareTempFiles() + Expect(CopyFiles(filepath.Join(TestDataRoot, "zot", fromZotRepo), root)).ShouldNot(HaveOccurred()) + return root +} + // PrepareTempFiles copies test data into a temp folder and return it. func PrepareTempFiles() string { tempDir := GinkgoT().TempDir() diff --git a/test/e2e/suite/command/attach.go b/test/e2e/suite/command/attach.go index c9c58c2ee..d827b987c 100644 --- a/test/e2e/suite/command/attach.go +++ b/test/e2e/suite/command/attach.go @@ -46,22 +46,22 @@ var _ = Describe("ORAS beginners:", func() { }) It("should fail when no subject reference provided", func() { - ORAS("attach", "--artifact-type", "oras.test").ExpectFailure().MatchErrKeyWords("Error:").Exec() + ORAS("attach", "--artifact-type", "oras/test").ExpectFailure().MatchErrKeyWords("Error:").Exec() }) It("should fail if no file reference or manifest annotation provided for registry", func() { - ORAS("attach", "--artifact-type", "oras.test", RegistryRef(Host, ImageRepo, foobar.Tag)). + ORAS("attach", "--artifact-type", "oras/test", RegistryRef(ZOTHost, ImageRepo, foobar.Tag)). ExpectFailure().MatchErrKeyWords("Error: no blob or manifest annotation are provided").Exec() }) It("should fail if no file reference or manifest annotation provided for OCI layout", func() { root := GinkgoT().TempDir() - ORAS("attach", "--artifact-type", "oras.test", LayoutRef(root, foobar.Tag)). + ORAS("attach", "--artifact-type", "oras/test", LayoutRef(root, foobar.Tag)). ExpectFailure().MatchErrKeyWords("Error: no blob or manifest annotation are provided").Exec() }) It("should fail if distribution spec is unkown", func() { - ORAS("attach", "--artifact-type", "oras.test", RegistryRef(Host, ImageRepo, foobar.Tag), "--distribution-spec", "???"). + ORAS("attach", "--artifact-type", "oras/test", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "--distribution-spec", "???"). ExpectFailure().MatchErrKeyWords("unknown distribution specification flag").Exec() }) }) @@ -71,11 +71,10 @@ var _ = Describe("1.1 registry users:", func() { When("running attach command", func() { It("should attach a file to a subject", func() { testRepo := attachTestRepo("simple") - tempDir := PrepareTempFiles() - subjectRef := RegistryRef(Host, testRepo, foobar.Tag) - prepare(RegistryRef(Host, ImageRepo, foobar.Tag), subjectRef) + CopyZotRepo(ImageRepo, testRepo) + subjectRef := RegistryRef(ZOTHost, testRepo, foobar.Tag) ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)). - WithWorkDir(tempDir). + WithWorkDir(PrepareTempFiles()). MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, false, 1).Exec() }) @@ -84,8 +83,8 @@ var _ = Describe("1.1 registry users:", func() { testRepo := attachTestRepo("export-manifest") tempDir := PrepareTempFiles() exportName := "manifest.json" - subjectRef := RegistryRef(Host, testRepo, foobar.Tag) - prepare(RegistryRef(Host, ImageRepo, foobar.Tag), subjectRef) + subjectRef := RegistryRef(ZOTHost, testRepo, foobar.Tag) + CopyZotRepo(ImageRepo, testRepo) // test ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia), "--export-manifest", exportName). WithWorkDir(tempDir). @@ -95,15 +94,15 @@ var _ = Describe("1.1 registry users:", func() { bytes := ORAS("discover", subjectRef, "-o", "json").Exec().Out.Contents() Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred()) Expect(len(index.Manifests)).To(Equal(1)) - fetched := ORAS("manifest", "fetch", RegistryRef(Host, testRepo, index.Manifests[0].Digest.String())).Exec().Out.Contents() + fetched := ORAS("manifest", "fetch", RegistryRef(ZOTHost, testRepo, index.Manifests[0].Digest.String())).Exec().Out.Contents() MatchFile(filepath.Join(tempDir, exportName), string(fetched), DefaultTimeout) }) It("should attach a file via a OCI Image", func() { testRepo := attachTestRepo("image") tempDir := PrepareTempFiles() - subjectRef := RegistryRef(Host, testRepo, foobar.Tag) - prepare(RegistryRef(Host, ImageRepo, foobar.Tag), subjectRef) + subjectRef := RegistryRef(ZOTHost, testRepo, foobar.Tag) + CopyZotRepo(ImageRepo, testRepo) // test ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)). WithWorkDir(tempDir). @@ -120,8 +119,8 @@ var _ = Describe("1.1 registry users:", func() { testRepo := attachTestRepo("simple") absAttachFileName := filepath.Join(PrepareTempFiles(), foobar.AttachFileName) - subjectRef := RegistryRef(Host, testRepo, foobar.Tag) - prepare(RegistryRef(Host, ImageRepo, foobar.Tag), subjectRef) + subjectRef := RegistryRef(ZOTHost, testRepo, foobar.Tag) + CopyZotRepo(ImageRepo, testRepo) statusKey := foobar.AttachFileStateKey statusKey.Name = absAttachFileName ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", absAttachFileName, foobar.AttachFileMedia), "--disable-path-validation"). @@ -133,8 +132,8 @@ var _ = Describe("1.1 registry users:", func() { testRepo := attachTestRepo("simple") absAttachFileName := filepath.Join(PrepareTempFiles(), foobar.AttachFileName) - subjectRef := RegistryRef(Host, testRepo, foobar.Tag) - prepare(RegistryRef(Host, ImageRepo, foobar.Tag), subjectRef) + subjectRef := RegistryRef(ZOTHost, testRepo, foobar.Tag) + CopyZotRepo(ImageRepo, testRepo) statusKey := foobar.AttachFileStateKey statusKey.Name = absAttachFileName ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", absAttachFileName, foobar.AttachFileMedia)). @@ -204,13 +203,9 @@ var _ = Describe("1.0 registry users:", func() { var _ = Describe("OCI image layout users:", func() { When("running attach command", func() { - prepare := func(root string) { - ORAS("cp", RegistryRef(Host, ImageRepo, foobar.Tag), Flags.ToLayout, LayoutRef(root, foobar.Tag)).Exec() - } It("should attach a file to a subject", func() { - root := PrepareTempFiles() + root := PrepareTempOCI(ImageRepo) subjectRef := LayoutRef(root, foobar.Tag) - prepare(root) ORAS("attach", "--artifact-type", "test/attach", Flags.Layout, subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)). WithWorkDir(root). MatchStatus([]match.StateKey{foobar.AttachFileStateKey}, false, 1).Exec() @@ -218,10 +213,9 @@ var _ = Describe("OCI image layout users:", func() { It("should attach a file to a subject and export the built manifest", func() { // prepare - root := PrepareTempFiles() exportName := "manifest.json" + root := PrepareTempOCI(ImageRepo) subjectRef := LayoutRef(root, foobar.Tag) - prepare(root) // test ORAS("attach", "--artifact-type", "test/attach", Flags.Layout, subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia), "--export-manifest", exportName). WithWorkDir(root). @@ -236,9 +230,8 @@ var _ = Describe("OCI image layout users:", func() { MatchFile(filepath.Join(root, exportName), string(fetched), DefaultTimeout) }) It("should attach a file via a OCI Image", func() { - root := PrepareTempFiles() + root := PrepareTempOCI(ImageRepo) subjectRef := LayoutRef(root, foobar.Tag) - prepare(root) // test ORAS("attach", "--artifact-type", "test/attach", Flags.Layout, subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)). WithWorkDir(root). diff --git a/test/e2e/testdata/zot/command/images/blobs/sha256/1fd9a5fc54b634130102861815e2881f1eec22958d604301904c5353041794c1 b/test/e2e/testdata/zot/command/images/blobs/sha256/1fd9a5fc54b634130102861815e2881f1eec22958d604301904c5353041794c1 new file mode 100644 index 000000000..42968ffca --- /dev/null +++ b/test/e2e/testdata/zot/command/images/blobs/sha256/1fd9a5fc54b634130102861815e2881f1eec22958d604301904c5353041794c1 @@ -0,0 +1,4 @@ +{ + "architecture": "arm64", + "os": "linux" +} \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/images/blobs/sha256/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae b/test/e2e/testdata/zot/command/images/blobs/sha256/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae new file mode 100644 index 000000000..191028156 --- /dev/null +++ b/test/e2e/testdata/zot/command/images/blobs/sha256/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae @@ -0,0 +1 @@ +foo \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/images/blobs/sha256/2ef548696ac7dd66ef38aab5cc8fc5cc1fb637dfaedb3a9afc89bf16db9277e1 b/test/e2e/testdata/zot/command/images/blobs/sha256/2ef548696ac7dd66ef38aab5cc8fc5cc1fb637dfaedb3a9afc89bf16db9277e1 new file mode 100644 index 0000000000000000000000000000000000000000..428f90aab2bd378850dcefe70f7d46eb6e3ddb44 GIT binary patch literal 10240 zcmeIvK?=e!5QX76O1wasX`*uluTfB_5?ZJc#nYRvD&4s1qVUgVl1vDXFa0&=u_^B& z+m+UGcd5<%sK0$4)zc)FVykwFQBBm^q%J|Xi?qD_e3WhqLGHKV(|5KER;z#W)%Cq> z&-4F>*Er?NVK14 Date: Fri, 25 Aug 2023 08:31:12 +0000 Subject: [PATCH 15/45] update blob tests Signed-off-by: Billy Zha --- test/e2e/internal/utils/prepare.go | 4 +- test/e2e/suite/command/attach.go | 10 ++-- test/e2e/suite/command/blob.go | 89 ++++++++++++++---------------- 3 files changed, 48 insertions(+), 55 deletions(-) diff --git a/test/e2e/internal/utils/prepare.go b/test/e2e/internal/utils/prepare.go index 3416e6641..5d92fc347 100644 --- a/test/e2e/internal/utils/prepare.go +++ b/test/e2e/internal/utils/prepare.go @@ -28,8 +28,8 @@ import ( "github.com/onsi/gomega/gbytes" ) -// CopyZotRepo copies oci layout data between repostories. -func CopyZotRepo(fromRepo string, toRepo string) { +// CopyZOTRepo copies oci layout data between repostories. +func CopyZOTRepo(fromRepo string, toRepo string) { zotRoot := filepath.Join(TestDataRoot, "zot") fromRepo = filepath.Join(zotRoot, fromRepo) toRepo = filepath.Join(zotRoot, toRepo) diff --git a/test/e2e/suite/command/attach.go b/test/e2e/suite/command/attach.go index d827b987c..0c813d9e7 100644 --- a/test/e2e/suite/command/attach.go +++ b/test/e2e/suite/command/attach.go @@ -71,7 +71,7 @@ var _ = Describe("1.1 registry users:", func() { When("running attach command", func() { It("should attach a file to a subject", func() { testRepo := attachTestRepo("simple") - CopyZotRepo(ImageRepo, testRepo) + CopyZOTRepo(ImageRepo, testRepo) subjectRef := RegistryRef(ZOTHost, testRepo, foobar.Tag) ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)). WithWorkDir(PrepareTempFiles()). @@ -84,7 +84,7 @@ var _ = Describe("1.1 registry users:", func() { tempDir := PrepareTempFiles() exportName := "manifest.json" subjectRef := RegistryRef(ZOTHost, testRepo, foobar.Tag) - CopyZotRepo(ImageRepo, testRepo) + CopyZOTRepo(ImageRepo, testRepo) // test ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia), "--export-manifest", exportName). WithWorkDir(tempDir). @@ -102,7 +102,7 @@ var _ = Describe("1.1 registry users:", func() { testRepo := attachTestRepo("image") tempDir := PrepareTempFiles() subjectRef := RegistryRef(ZOTHost, testRepo, foobar.Tag) - CopyZotRepo(ImageRepo, testRepo) + CopyZOTRepo(ImageRepo, testRepo) // test ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia)). WithWorkDir(tempDir). @@ -120,7 +120,7 @@ var _ = Describe("1.1 registry users:", func() { absAttachFileName := filepath.Join(PrepareTempFiles(), foobar.AttachFileName) subjectRef := RegistryRef(ZOTHost, testRepo, foobar.Tag) - CopyZotRepo(ImageRepo, testRepo) + CopyZOTRepo(ImageRepo, testRepo) statusKey := foobar.AttachFileStateKey statusKey.Name = absAttachFileName ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", absAttachFileName, foobar.AttachFileMedia), "--disable-path-validation"). @@ -133,7 +133,7 @@ var _ = Describe("1.1 registry users:", func() { absAttachFileName := filepath.Join(PrepareTempFiles(), foobar.AttachFileName) subjectRef := RegistryRef(ZOTHost, testRepo, foobar.Tag) - CopyZotRepo(ImageRepo, testRepo) + CopyZOTRepo(ImageRepo, testRepo) statusKey := foobar.AttachFileStateKey statusKey.Name = absAttachFileName ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", absAttachFileName, foobar.AttachFileMedia)). diff --git a/test/e2e/suite/command/blob.go b/test/e2e/suite/command/blob.go index abf1d0a83..778f6e7ed 100644 --- a/test/e2e/suite/command/blob.go +++ b/test/e2e/suite/command/blob.go @@ -39,13 +39,13 @@ var _ = Describe("ORAS beginners:", func() { When("running `blob push`", func() { It("should fail to read blob content and password from stdin at the same time", func() { repo := fmt.Sprintf(repoFmt, "push", "password-stdin") - ORAS("blob", "push", RegistryRef(Host, repo, ""), "--password-stdin", "-"). + ORAS("blob", "push", RegistryRef(ZOTHost, repo, ""), "--password-stdin", "-"). ExpectFailure(). MatchErrKeyWords("Error: `-` read file from input and `--password-stdin` read password from input cannot be both used").Exec() }) It("should fail to push a blob from stdin but no blob size provided", func() { repo := fmt.Sprintf(repoFmt, "push", "no-size") - ORAS("blob", "push", RegistryRef(Host, repo, pushDigest), "-"). + ORAS("blob", "push", RegistryRef(ZOTHost, repo, pushDigest), "-"). WithInput(strings.NewReader(pushContent)). ExpectFailure(). MatchErrKeyWords("Error: `--size` must be provided if the blob is read from stdin").Exec() @@ -53,14 +53,14 @@ var _ = Describe("ORAS beginners:", func() { It("should fail to push a blob from stdin if invalid blob size provided", func() { repo := fmt.Sprintf(repoFmt, "push", "invalid-stdin-size") - ORAS("blob", "push", RegistryRef(Host, repo, pushDigest), "-", "--size", "3"). + ORAS("blob", "push", RegistryRef(ZOTHost, repo, pushDigest), "-", "--size", "3"). WithInput(strings.NewReader(pushContent)).ExpectFailure(). Exec() }) It("should fail to push a blob from stdin if invalid digest provided", func() { repo := fmt.Sprintf(repoFmt, "push", "invalid-stdin-digest") - ORAS("blob", "push", RegistryRef(Host, repo, invalidDigest), "-", "--size", strconv.Itoa(len(pushContent))). + ORAS("blob", "push", RegistryRef(ZOTHost, repo, invalidDigest), "-", "--size", strconv.Itoa(len(pushContent))). WithInput(strings.NewReader(pushContent)).ExpectFailure(). Exec() }) @@ -68,7 +68,7 @@ var _ = Describe("ORAS beginners:", func() { It("should fail to push a blob from file if invalid blob size provided", func() { repo := fmt.Sprintf(repoFmt, "push", "invalid-file-digest") blobPath := WriteTempFile("blob", pushContent) - ORAS("blob", "push", RegistryRef(Host, repo, pushDigest), blobPath, "--size", "3"). + ORAS("blob", "push", RegistryRef(ZOTHost, repo, pushDigest), blobPath, "--size", "3"). ExpectFailure(). Exec() }) @@ -76,7 +76,7 @@ var _ = Describe("ORAS beginners:", func() { It("should fail to push a blob from file if invalid digest provided", func() { repo := fmt.Sprintf(repoFmt, "push", "invalid-stdin-size") blobPath := WriteTempFile("blob", pushContent) - ORAS("blob", "push", RegistryRef(Host, repo, invalidDigest), blobPath, "--size", strconv.Itoa(len(pushContent))). + ORAS("blob", "push", RegistryRef(ZOTHost, repo, invalidDigest), blobPath, "--size", strconv.Itoa(len(pushContent))). WithInput(strings.NewReader(pushContent)).ExpectFailure(). Exec() }) @@ -99,22 +99,22 @@ var _ = Describe("ORAS beginners:", func() { }) It("should fail if neither output path nor descriptor flag are not provided", func() { - ORAS("blob", "fetch", RegistryRef(Host, ImageRepo, "sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae")). + ORAS("blob", "fetch", RegistryRef(ZOTHost, ImageRepo, "sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae")). ExpectFailure().Exec() }) It("should fail if no digest provided", func() { - ORAS("blob", "fetch", RegistryRef(Host, ImageRepo, "")). + ORAS("blob", "fetch", RegistryRef(ZOTHost, ImageRepo, "")). ExpectFailure().Exec() }) It("should fail if provided digest doesn't existed", func() { - ORAS("blob", "fetch", RegistryRef(Host, ImageRepo, "sha256:2aaa2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a")). + ORAS("blob", "fetch", RegistryRef(ZOTHost, ImageRepo, "sha256:2aaa2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a")). ExpectFailure().Exec() }) It("should fail if output path points to stdout and descriptor flag is provided", func() { - ORAS("blob", "fetch", RegistryRef(Host, ImageRepo, ""), "--descriptor", "--output", "-"). + ORAS("blob", "fetch", RegistryRef(ZOTHost, ImageRepo, ""), "--descriptor", "--output", "-"). ExpectFailure().Exec() }) @@ -127,27 +127,27 @@ var _ = Describe("ORAS beginners:", func() { When("running `blob delete`", func() { It("should fail if no blob reference is provided", func() { dstRepo := fmt.Sprintf(repoFmt, "delete", "no-ref") - ORAS("cp", RegistryRef(Host, ImageRepo, foobar.Digest), RegistryRef(Host, dstRepo, foobar.Digest)).Exec() + CopyZOTRepo(ImageRepo, dstRepo) ORAS("blob", "delete").ExpectFailure().Exec() - ORAS("blob", "fetch", RegistryRef(Host, dstRepo, foobar.FooBlobDigest), "--output", "-").MatchContent(foobar.FooBlobContent).Exec() + ORAS("blob", "fetch", RegistryRef(ZOTHost, dstRepo, foobar.FooBlobDigest), "--output", "-").MatchContent(foobar.FooBlobContent).Exec() }) It("should fail if no force flag and descriptor flag is provided", func() { dstRepo := fmt.Sprintf(repoFmt, "delete", "no-confirm") - ORAS("cp", RegistryRef(Host, ImageRepo, foobar.Digest), RegistryRef(Host, dstRepo, foobar.Digest)).Exec() - ORAS("blob", "delete", RegistryRef(Host, dstRepo, foobar.FooBlobDigest), "--descriptor").ExpectFailure().Exec() - ORAS("blob", "fetch", RegistryRef(Host, dstRepo, foobar.FooBlobDigest), "--output", "-").MatchContent(foobar.FooBlobContent).Exec() + CopyZOTRepo(ImageRepo, dstRepo) + ORAS("blob", "delete", RegistryRef(ZOTHost, dstRepo, foobar.FooBlobDigest), "--descriptor").ExpectFailure().Exec() + ORAS("blob", "fetch", RegistryRef(ZOTHost, dstRepo, foobar.FooBlobDigest), "--output", "-").MatchContent(foobar.FooBlobContent).Exec() }) It("should fail if the blob reference is not in the form of ", func() { dstRepo := fmt.Sprintf(repoFmt, "delete", "wrong-ref-form") - ORAS("blob", "delete", fmt.Sprintf("%s/%s:%s", Host, dstRepo, "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), "--descriptor", "--force").ExpectFailure().Exec() - ORAS("blob", "delete", fmt.Sprintf("%s/%s:%s", Host, dstRepo, "test"), "--descriptor", "--force").ExpectFailure().Exec() - ORAS("blob", "delete", fmt.Sprintf("%s/%s@%s", Host, dstRepo, "test"), "--descriptor", "--force").ExpectFailure().Exec() + ORAS("blob", "delete", fmt.Sprintf("%s/%s:%s", ZOTHost, dstRepo, "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), "--descriptor", "--force").ExpectFailure().Exec() + ORAS("blob", "delete", fmt.Sprintf("%s/%s:%s", ZOTHost, dstRepo, "test"), "--descriptor", "--force").ExpectFailure().Exec() + ORAS("blob", "delete", fmt.Sprintf("%s/%s@%s", ZOTHost, dstRepo, "test"), "--descriptor", "--force").ExpectFailure().Exec() }) It("should fail to delete a non-existent blob without force flag set", func() { - toDeleteRef := RegistryRef(Host, ImageRepo, invalidDigest) + toDeleteRef := RegistryRef(ZOTHost, ImageRepo, invalidDigest) ORAS("blob", "delete", toDeleteRef). ExpectFailure(). MatchErrKeyWords(toDeleteRef, "the specified blob does not exist"). @@ -155,7 +155,7 @@ var _ = Describe("ORAS beginners:", func() { }) It("should fail to delete a non-existent blob and output descriptor, with force flag set", func() { - toDeleteRef := RegistryRef(Host, ImageRepo, invalidDigest) + toDeleteRef := RegistryRef(ZOTHost, ImageRepo, invalidDigest) ORAS("blob", "delete", toDeleteRef, "--force", "--descriptor"). ExpectFailure(). MatchErrKeyWords(toDeleteRef, "the specified blob does not exist"). @@ -169,8 +169,8 @@ var _ = Describe("1.1 registry users:", func() { When("running `blob delete`", func() { It("should delete a blob with interactive confirmation", func() { dstRepo := fmt.Sprintf(repoFmt, "delete", "prompt-confirmation") - ORAS("cp", RegistryRef(Host, ImageRepo, foobar.Digest), RegistryRef(Host, dstRepo, foobar.Digest)).Exec() - toDeleteRef := RegistryRef(Host, dstRepo, foobar.FooBlobDigest) + CopyZOTRepo(ImageRepo, dstRepo) + toDeleteRef := RegistryRef(ZOTHost, dstRepo, foobar.FooBlobDigest) ORAS("blob", "delete", toDeleteRef). WithInput(strings.NewReader("y")). MatchKeyWords("Deleted", toDeleteRef).Exec() @@ -183,14 +183,14 @@ var _ = Describe("1.1 registry users:", func() { It("should delete a blob with force flag and output descriptor", func() { dstRepo := fmt.Sprintf(repoFmt, "delete", "flag-confirmation") - ORAS("cp", RegistryRef(Host, ImageRepo, foobar.Digest), RegistryRef(Host, dstRepo, foobar.Digest)).Exec() - toDeleteRef := RegistryRef(Host, dstRepo, foobar.FooBlobDigest) + CopyZOTRepo(ImageRepo, dstRepo) + toDeleteRef := RegistryRef(ZOTHost, dstRepo, foobar.FooBlobDigest) ORAS("blob", "delete", toDeleteRef, "--force", "--descriptor").MatchContent(foobar.FooBlobDescriptor).Exec() ORAS("blob", "delete", toDeleteRef).WithDescription("validate").ExpectFailure().MatchErrKeyWords("Error:", toDeleteRef, "the specified blob does not exist").Exec() }) It("should return success when deleting a non-existent blob with force flag set", func() { - toDeleteRef := RegistryRef(Host, ImageRepo, invalidDigest) + toDeleteRef := RegistryRef(ZOTHost, ImageRepo, invalidDigest) ORAS("blob", "delete", toDeleteRef, "--force"). MatchKeyWords("Missing", toDeleteRef). Exec() @@ -201,11 +201,11 @@ var _ = Describe("1.1 registry users:", func() { mediaType := "test.media" repo := fmt.Sprintf(repoFmt, "push", "blob-file-media-type") blobPath := WriteTempFile("blob", pushContent) - ORAS("blob", "push", RegistryRef(Host, repo, ""), blobPath, "--media-type", mediaType, "--descriptor"). + ORAS("blob", "push", RegistryRef(ZOTHost, repo, ""), blobPath, "--media-type", mediaType, "--descriptor"). MatchContent(fmt.Sprintf(pushDescFmt, mediaType)).Exec() - ORAS("blob", "fetch", RegistryRef(Host, repo, pushDigest), "--output", "-").MatchContent(pushContent).Exec() + ORAS("blob", "fetch", RegistryRef(ZOTHost, repo, pushDigest), "--output", "-").MatchContent(pushContent).Exec() - ORAS("blob", "push", RegistryRef(Host, repo, ""), blobPath, "-v"). + ORAS("blob", "push", RegistryRef(ZOTHost, repo, ""), blobPath, "-v"). WithDescription("skip the pushing if the blob already exists in the target repo"). MatchKeyWords("Exists").Exec() }) @@ -213,49 +213,42 @@ var _ = Describe("1.1 registry users:", func() { It("should push a blob from a stdin and output the descriptor with specific media-type", func() { mediaType := "test.media" repo := fmt.Sprintf(repoFmt, "push", "blob-file-media-type") - ORAS("blob", "push", RegistryRef(Host, repo, pushDigest), "-", "--media-type", mediaType, "--descriptor", "--size", strconv.Itoa(len(pushContent))). + ORAS("blob", "push", RegistryRef(ZOTHost, repo, pushDigest), "-", "--media-type", mediaType, "--descriptor", "--size", strconv.Itoa(len(pushContent))). WithInput(strings.NewReader(pushContent)). MatchContent(fmt.Sprintf(pushDescFmt, mediaType)).Exec() - ORAS("blob", "fetch", RegistryRef(Host, repo, pushDigest), "--output", "-").MatchContent(pushContent).Exec() + ORAS("blob", "fetch", RegistryRef(ZOTHost, repo, pushDigest), "--output", "-").MatchContent(pushContent).Exec() }) }) When("running `blob fetch`", func() { It("should fetch blob descriptor ", func() { - ORAS("blob", "fetch", RegistryRef(Host, ImageRepo, foobar.FooBlobDigest), "--descriptor"). + ORAS("blob", "fetch", RegistryRef(ZOTHost, ImageRepo, foobar.FooBlobDigest), "--descriptor"). MatchContent(foobar.FooBlobDescriptor).Exec() }) It("should fetch blob content and output to stdout", func() { - ORAS("blob", "fetch", RegistryRef(Host, ImageRepo, foobar.FooBlobDigest), "--output", "-"). + ORAS("blob", "fetch", RegistryRef(ZOTHost, ImageRepo, foobar.FooBlobDigest), "--output", "-"). MatchContent(foobar.FooBlobContent).Exec() }) It("should fetch blob content and output to a file", func() { tempDir := GinkgoT().TempDir() contentPath := filepath.Join(tempDir, "fetched") - ORAS("blob", "fetch", RegistryRef(Host, ImageRepo, foobar.FooBlobDigest), "--output", contentPath). + ORAS("blob", "fetch", RegistryRef(ZOTHost, ImageRepo, foobar.FooBlobDigest), "--output", contentPath). WithWorkDir(tempDir).Exec() MatchFile(contentPath, foobar.FooBlobContent, DefaultTimeout) }) It("should fetch blob descriptor and output content to a file", func() { - tempDir := GinkgoT().TempDir() - contentPath := filepath.Join(tempDir, "fetched") - ORAS("blob", "fetch", RegistryRef(Host, ImageRepo, foobar.FooBlobDigest), "--output", contentPath, "--descriptor"). - MatchContent(foobar.FooBlobDescriptor). - WithWorkDir(tempDir).Exec() + contentPath := filepath.Join(GinkgoT().TempDir(), "fetched") + ORAS("blob", "fetch", RegistryRef(ZOTHost, ImageRepo, foobar.FooBlobDigest), "--output", contentPath, "--descriptor"). + MatchContent(foobar.FooBlobDescriptor).Exec() MatchFile(contentPath, foobar.FooBlobContent, DefaultTimeout) }) }) }) var _ = Describe("OCI image layout users:", func() { - prepare := func(from string) string { - tmpRoot := GinkgoT().TempDir() - ORAS("cp", from, Flags.ToLayout, tmpRoot).WithDescription("prepare image from registry to OCI layout").Exec() - return tmpRoot - } When("running `blob delete`", func() { It("should not support deleting a blob", func() { - toDeleteRef := LayoutRef(prepare(RegistryRef(Host, ImageRepo, foobar.Tag)), foobar.FooBlobDigest) + toDeleteRef := LayoutRef(PrepareTempOCI(ImageRepo), foobar.FooBlobDigest) ORAS("blob", "delete", Flags.Layout, toDeleteRef). WithInput(strings.NewReader("y")). MatchErrKeyWords("Error:", "unknown flag", Flags.Layout). @@ -266,17 +259,17 @@ var _ = Describe("OCI image layout users:", func() { When("running `blob fetch`", func() { It("should fetch blob descriptor", func() { - root := prepare(RegistryRef(Host, ImageRepo, foobar.Tag)) + root := PrepareTempOCI(ImageRepo) ORAS("blob", "fetch", Flags.Layout, LayoutRef(root, foobar.FooBlobDigest), "--descriptor"). MatchContent(foobar.FooBlobDescriptor).Exec() }) It("should fetch blob content and output to stdout", func() { - root := prepare(RegistryRef(Host, ImageRepo, foobar.Tag)) + root := PrepareTempOCI(ImageRepo) ORAS("blob", "fetch", Flags.Layout, LayoutRef(root, foobar.FooBlobDigest), "--output", "-"). MatchContent(foobar.FooBlobContent).Exec() }) It("should fetch blob content and output to a file", func() { - root := prepare(RegistryRef(Host, ImageRepo, foobar.Tag)) + root := PrepareTempOCI(ImageRepo) tempDir := GinkgoT().TempDir() contentPath := filepath.Join(tempDir, "fetched") ORAS("blob", "fetch", Flags.Layout, LayoutRef(root, foobar.FooBlobDigest), "--output", contentPath). @@ -284,7 +277,7 @@ var _ = Describe("OCI image layout users:", func() { MatchFile(contentPath, foobar.FooBlobContent, DefaultTimeout) }) It("should fetch blob descriptor and output content to a file", func() { - root := prepare(RegistryRef(Host, ImageRepo, foobar.Tag)) + root := PrepareTempOCI(ImageRepo) tempDir := GinkgoT().TempDir() contentPath := filepath.Join(tempDir, "fetched") ORAS("blob", "fetch", Flags.Layout, LayoutRef(root, foobar.FooBlobDigest), "--output", contentPath, "--descriptor"). From 8efd1852d475d4cc21e823a95927efe14e037e9a Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Mon, 28 Aug 2023 04:11:36 +0000 Subject: [PATCH 16/45] add doc Signed-off-by: Billy Zha --- test/e2e/README.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test/e2e/README.md b/test/e2e/README.md index 5837e3a47..a9e030441 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -38,7 +38,7 @@ This is super handy when you want to do step-by-step debugging from command-line ### 5. Testing Registry Services The backend of E2E tests are three registry services: -- [oras-distribution](https://github.com/oras-project/distribution): registry service supports artifact and image types in [image-spec 1.1.0 rc2](https://github.com/opencontainers/image-spec/tree/v1.1.0-rc2) and referrer API +- [oras-distribution](https://github.com/oras-project/distribution): registry service supports artifact and image types in [image-spec 1.1.0 rc2](https://github.com/opencontainers/image-spec/tree/v1.1.0-rc2) and referrer API. Will be deprecated when [image-spec 1.1.0 rc2](https://github.com/opencontainers/image-spec/tree/v1.1.0-rc2) is not supported by oras CLI. - [upstream distribution](https://github.com/distribution/distribution): registry service supports image media type with subject and provide referrers via [tag schema](https://github.com/opencontainers/distribution-spec/blob/v1.1.0-rc1/spec.md#referrers-tag-schema). - [zot](https://github.com/project-zot/zot): registry service supports artifact and image types in [image-spec 1.1.0 rc4](https://github.com/opencontainers/image-spec/tree/v1.1.0-rc4) and referrer API @@ -72,12 +72,13 @@ Describe: ### 9. Adding New Test Data #### 9.1 Command Suite -Command suite uses pre-baked test data, which is a bunch of layered archive files compressed from registry storage. Test data are all stored in `$REPO_ROOT/test/e2e/testdata/distribution/` but separated in different sub-folders: oras distribution uses `mount` and upstream distribution uses `mount_fallback`. +Command suite uses two kinds of pre-baked test data: +- Layered distribution archive files: those test data is compressed from registry runtime storage directly and is stored in `$REPO_ROOT/test/e2e/testdata/distribution/`. ORAS distribution uses sub-folder `mount` and upstream distribution uses sub-folder `mount_fallback`. For both registries, the repository name should follow the convention of `command/$repo_suffix`. To add a new layer to the test data, use the below command to compress the `docker` folder from the root directory of the registry storage and copy it to the corresponding subfolder in `$REPO_ROOT/test/e2e/testdata/distribution/mount`. + ```shell + tar -cvzf ${repo_suffix}.tar.gz --owner=0 --group=0 docker/ + ``` +- OCI layout files: those test data are stored in `$REPO_ROOT/test/e2e/testdata/zot/` and used by ZOT registry service. You may use stable release of ORAS CLI to build it. When adding new artifacts in, please make sure the repository folder is excluded in `$REPO_ROOT/.gitignore`. -For both registries, the repository name should follow the convention of `command/$repo_suffix`. To add a new layer to the test data, use the below command to compress the `docker` folder from the root directory of the registry storage and copy it to the corresponding subfolder in `$REPO_ROOT/test/e2e/testdata/distribution/mount`. -```shell -tar -cvzf ${repo_suffix}.tar.gz --owner=0 --group=0 docker/ -``` ##### Test Data for ORAS-Distribution ```mermaid @@ -145,5 +146,9 @@ graph TD; end end ``` + +##### Test Data for ZOT +Still WIP. + #### 9.2 Scenario Suite Test files used by scenario-based specs are placed in `$REPO_ROOT/test/e2e/testdata/files`. \ No newline at end of file From f3cf89ee2d8e230578089e53c33b161475aae938 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Mon, 28 Aug 2023 04:13:42 +0000 Subject: [PATCH 17/45] doc clean Signed-off-by: Billy Zha --- test/e2e/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/README.md b/test/e2e/README.md index a9e030441..b217a9a2a 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -73,11 +73,11 @@ Describe: #### 9.1 Command Suite Command suite uses two kinds of pre-baked test data: -- Layered distribution archive files: those test data is compressed from registry runtime storage directly and is stored in `$REPO_ROOT/test/e2e/testdata/distribution/`. ORAS distribution uses sub-folder `mount` and upstream distribution uses sub-folder `mount_fallback`. For both registries, the repository name should follow the convention of `command/$repo_suffix`. To add a new layer to the test data, use the below command to compress the `docker` folder from the root directory of the registry storage and copy it to the corresponding subfolder in `$REPO_ROOT/test/e2e/testdata/distribution/mount`. +- Layered distribution archive files: test data compressed from registry runtime storage directly and stored in `$REPO_ROOT/test/e2e/testdata/distribution/`. ORAS distribution uses sub-folder `mount` and upstream distribution uses sub-folder `mount_fallback`. For both registries, the repository name should follow the convention of `command/$repo_suffix`. To add a new layer to the test data, use the below command to compress the `docker` folder from the root directory of the registry storage and copy it to the corresponding subfolder in `$REPO_ROOT/test/e2e/testdata/distribution/mount`. ```shell tar -cvzf ${repo_suffix}.tar.gz --owner=0 --group=0 docker/ ``` -- OCI layout files: those test data are stored in `$REPO_ROOT/test/e2e/testdata/zot/` and used by ZOT registry service. You may use stable release of ORAS CLI to build it. When adding new artifacts in, please make sure the repository folder is excluded in `$REPO_ROOT/.gitignore`. +- OCI layout files: test data stored in `$REPO_ROOT/test/e2e/testdata/zot/` and used by ZOT registry service. You may use stable release of ORAS CLI to build it. When adding new artifacts in, please make sure the repository folder is excluded in `$REPO_ROOT/.gitignore`. ##### Test Data for ORAS-Distribution From dea043d239b21c85469d169e7c5292bf10e49123 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Mon, 28 Aug 2023 07:15:32 +0000 Subject: [PATCH 18/45] fix e2e Signed-off-by: Billy Zha --- .gitignore | 1 + test/e2e/internal/utils/testdata.go | 2 +- test/e2e/suite/command/blob.go | 16 ++++++---------- test/e2e/suite/command/discover.go | 2 +- test/e2e/suite/command/repo.go | 14 +++++++------- ...b453c1d30413413422d706483bfa0f98a5e886266e7ae | 1 + test/e2e/testdata/zot/command/blobs/index.json | 1 + test/e2e/testdata/zot/command/blobs/oci-layout | 1 + 8 files changed, 19 insertions(+), 19 deletions(-) create mode 100644 test/e2e/testdata/zot/command/blobs/blobs/sha256/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae create mode 100644 test/e2e/testdata/zot/command/blobs/index.json create mode 100644 test/e2e/testdata/zot/command/blobs/oci-layout diff --git a/.gitignore b/.gitignore index cb04bf2f0..163bf6ab3 100644 --- a/.gitignore +++ b/.gitignore @@ -54,5 +54,6 @@ test/e2e/testdata/distribution/mount_fallback/docker/ # OCI Layout Files ZOT storage files for local E2E testing test/e2e/testdata/zot/ !test/e2e/testdata/zot/command/images +!test/e2e/testdata/zot/command/blobs !test/e2e/testdata/zot/config.json !test/e2e/testdata/zot/passwd_bcrypt \ No newline at end of file diff --git a/test/e2e/internal/utils/testdata.go b/test/e2e/internal/utils/testdata.go index c29cce1f8..b4aab0f84 100644 --- a/test/e2e/internal/utils/testdata.go +++ b/test/e2e/internal/utils/testdata.go @@ -19,8 +19,8 @@ const ( PreviewDesc = "** This command is in preview and under development. **" ExampleDesc = "\nExample - " ImageRepo = "command/images" + BlobRepo = "command/blobs" ArtifactRepo = "command/artifacts" - Repo = "command/images" Namespace = "command" // env RegHostKey = "ORAS_REGISTRY_HOST" diff --git a/test/e2e/suite/command/blob.go b/test/e2e/suite/command/blob.go index 778f6e7ed..1eceee148 100644 --- a/test/e2e/suite/command/blob.go +++ b/test/e2e/suite/command/blob.go @@ -52,9 +52,11 @@ var _ = Describe("ORAS beginners:", func() { }) It("should fail to push a blob from stdin if invalid blob size provided", func() { + content := "another-test" + digest := "sha256:c897eff15c4586525388034f8246346681cb48d75a619039c566c4939a18102e" repo := fmt.Sprintf(repoFmt, "push", "invalid-stdin-size") - ORAS("blob", "push", RegistryRef(ZOTHost, repo, pushDigest), "-", "--size", "3"). - WithInput(strings.NewReader(pushContent)).ExpectFailure(). + ORAS("blob", "push", RegistryRef(ZOTHost, repo, digest), "-", "--size", "3"). + WithInput(strings.NewReader(content)).ExpectFailure(). Exec() }) @@ -169,24 +171,18 @@ var _ = Describe("1.1 registry users:", func() { When("running `blob delete`", func() { It("should delete a blob with interactive confirmation", func() { dstRepo := fmt.Sprintf(repoFmt, "delete", "prompt-confirmation") - CopyZOTRepo(ImageRepo, dstRepo) + CopyZOTRepo(BlobRepo, dstRepo) toDeleteRef := RegistryRef(ZOTHost, dstRepo, foobar.FooBlobDigest) ORAS("blob", "delete", toDeleteRef). WithInput(strings.NewReader("y")). MatchKeyWords("Deleted", toDeleteRef).Exec() - ORAS("blob", "delete", toDeleteRef). - WithDescription("validate"). - WithInput(strings.NewReader("y")). - ExpectFailure(). - MatchErrKeyWords("Error:", toDeleteRef, "the specified blob does not exist").Exec() }) It("should delete a blob with force flag and output descriptor", func() { dstRepo := fmt.Sprintf(repoFmt, "delete", "flag-confirmation") - CopyZOTRepo(ImageRepo, dstRepo) + CopyZOTRepo(BlobRepo, dstRepo) toDeleteRef := RegistryRef(ZOTHost, dstRepo, foobar.FooBlobDigest) ORAS("blob", "delete", toDeleteRef, "--force", "--descriptor").MatchContent(foobar.FooBlobDescriptor).Exec() - ORAS("blob", "delete", toDeleteRef).WithDescription("validate").ExpectFailure().MatchErrKeyWords("Error:", toDeleteRef, "the specified blob does not exist").Exec() }) It("should return success when deleting a non-existent blob with force flag set", func() { diff --git a/test/e2e/suite/command/discover.go b/test/e2e/suite/command/discover.go index 15d3ba771..5690f535c 100644 --- a/test/e2e/suite/command/discover.go +++ b/test/e2e/suite/command/discover.go @@ -61,7 +61,7 @@ var _ = Describe("ORAS beginners:", func() { }) It("should fail when no tag or digest found in provided subject reference", func() { - ORAS("discover", RegistryRef(Host, Repo, "")).ExpectFailure().MatchErrKeyWords("Error:", "invalid image reference").Exec() + ORAS("discover", RegistryRef(Host, ImageRepo, "")).ExpectFailure().MatchErrKeyWords("Error:", "invalid image reference").Exec() }) }) }) diff --git a/test/e2e/suite/command/repo.go b/test/e2e/suite/command/repo.go index 844c9f5f1..2176001d0 100644 --- a/test/e2e/suite/command/repo.go +++ b/test/e2e/suite/command/repo.go @@ -42,7 +42,7 @@ var _ = Describe("ORAS beginners:", func() { It("should fail listing repositories if wrong registry provided", func() { ORAS("repo", "ls").ExpectFailure().MatchErrKeyWords("Error:").Exec() - ORAS("repo", "ls", RegistryRef(Host, Repo, "some-tag")).ExpectFailure().MatchErrKeyWords("Error:").Exec() + ORAS("repo", "ls", RegistryRef(Host, ImageRepo, "some-tag")).ExpectFailure().MatchErrKeyWords("Error:").Exec() }) }) When("running `repo tags`", func() { @@ -70,16 +70,16 @@ var _ = Describe("1.1 registry users:", func() { ORAS("repository", "list", Host).MatchKeyWords(ImageRepo).Exec() }) It("should list repositories under provided namespace", func() { - ORAS("repo", "ls", RegistryRef(Host, Namespace, "")).MatchKeyWords(Repo[len(Namespace)+1:]).Exec() + ORAS("repo", "ls", RegistryRef(Host, Namespace, "")).MatchKeyWords(ImageRepo[len(Namespace)+1:]).Exec() }) It("should not list repositories without a fully matched namespace", func() { repo := "command-draft/images" - ORAS("cp", RegistryRef(Host, Repo, foobar.Tag), RegistryRef(Host, repo, foobar.Tag)). + ORAS("cp", RegistryRef(Host, ImageRepo, foobar.Tag), RegistryRef(Host, repo, foobar.Tag)). WithDescription("prepare destination repo: " + repo). Exec() - ORAS("repo", "ls", Host).MatchKeyWords(Repo, repo).Exec() - session := ORAS("repo", "ls", RegistryRef(Host, Namespace, "")).MatchKeyWords(Repo[len(Namespace)+1:]).Exec() + ORAS("repo", "ls", Host).MatchKeyWords(ImageRepo, repo).Exec() + session := ORAS("repo", "ls", RegistryRef(Host, Namespace, "")).MatchKeyWords(ImageRepo[len(Namespace)+1:]).Exec() Expect(session.Out).ShouldNot(gbytes.Say(repo[len(Namespace)+1:])) }) @@ -115,10 +115,10 @@ var _ = Describe("1.1 registry users:", func() { repo := repoWithName("filter-tag") tags := []string{foobar.Tag, "bax", "bay", "baz"} refWithTags := fmt.Sprintf("%s:%s", RegistryRef(Host, repo, ""), strings.Join(tags, ",")) - ORAS("cp", RegistryRef(Host, Repo, foobar.Tag), refWithTags). + ORAS("cp", RegistryRef(Host, ImageRepo, foobar.Tag), refWithTags). WithDescription("prepare: copy and create multiple tags to " + refWithTags). Exec() - ORAS("cp", RegistryRef(Host, Repo, multi_arch.Tag), RegistryRef(Host, Repo, "")). + ORAS("cp", RegistryRef(Host, ImageRepo, multi_arch.Tag), RegistryRef(Host, ImageRepo, "")). WithDescription("prepare: copy tag with different digest"). Exec() // test diff --git a/test/e2e/testdata/zot/command/blobs/blobs/sha256/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae b/test/e2e/testdata/zot/command/blobs/blobs/sha256/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae new file mode 100644 index 000000000..191028156 --- /dev/null +++ b/test/e2e/testdata/zot/command/blobs/blobs/sha256/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae @@ -0,0 +1 @@ +foo \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/blobs/index.json b/test/e2e/testdata/zot/command/blobs/index.json new file mode 100644 index 000000000..442b81d76 --- /dev/null +++ b/test/e2e/testdata/zot/command/blobs/index.json @@ -0,0 +1 @@ +{"schemaVersion":2,"manifests":null} \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/blobs/oci-layout b/test/e2e/testdata/zot/command/blobs/oci-layout new file mode 100644 index 000000000..1343d370f --- /dev/null +++ b/test/e2e/testdata/zot/command/blobs/oci-layout @@ -0,0 +1 @@ +{"imageLayoutVersion":"1.0.0"} \ No newline at end of file From 1945b87308138491e2aaad147f0662a48c1ca00b Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Mon, 28 Aug 2023 08:53:20 +0000 Subject: [PATCH 19/45] test(e2e): migrate `oras push` specs to ZOT Signed-off-by: Billy Zha --- test/e2e/suite/command/push.go | 44 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/test/e2e/suite/command/push.go b/test/e2e/suite/command/push.go index 0fe788a79..fcc8f6f52 100644 --- a/test/e2e/suite/command/push.go +++ b/test/e2e/suite/command/push.go @@ -42,7 +42,7 @@ var _ = Describe("ORAS beginners:", func() { }) }) -var _ = Describe("Remote registry users:", func() { +var _ = Describe("1.1 registry users:", func() { tag := "e2e" When("pushing to registy without OCI artifact support", func() { repoPrefix := fmt.Sprintf("command/push/%d", GinkgoRandomSeed()) @@ -53,7 +53,7 @@ var _ = Describe("Remote registry users:", func() { It("should push files without customized media types", func() { repo := fmt.Sprintf("%s/%s", repoPrefix, "no-mediatype") tempDir := PrepareTempFiles() - ref := RegistryRef(Host, repo, tag) + ref := RegistryRef(ZOTHost, repo, tag) ORAS("push", ref, foobar.FileBarName, "-v"). MatchStatus(statusKeys, true, len(statusKeys)). @@ -68,7 +68,7 @@ var _ = Describe("Remote registry users:", func() { It("should push files with path validation disabled", func() { repo := fmt.Sprintf("%s/%s", repoPrefix, "disable-path-validation") - ref := RegistryRef(Host, repo, tag) + ref := RegistryRef(ZOTHost, repo, tag) absBarName := filepath.Join(PrepareTempFiles(), foobar.FileBarName) ORAS("push", ref, absBarName, "-v", "--disable-path-validation"). @@ -90,7 +90,7 @@ var _ = Describe("Remote registry users:", func() { It("should fail path validation when pushing file with absolute path", func() { repo := fmt.Sprintf("%s/%s", repoPrefix, "path-validation") - ref := RegistryRef(Host, repo, tag) + ref := RegistryRef(ZOTHost, repo, tag) absBarName := filepath.Join(PrepareTempFiles(), foobar.FileBarName) // test ORAS("push", ref, absBarName, "-v"). @@ -104,30 +104,30 @@ var _ = Describe("Remote registry users:", func() { tempDir := PrepareTempFiles() extraTag := "2e2" - ORAS("push", fmt.Sprintf("%s,%s", RegistryRef(Host, repo, tag), extraTag), foobar.FileBarName, "-v"). + ORAS("push", fmt.Sprintf("%s,%s", RegistryRef(ZOTHost, repo, tag), extraTag), foobar.FileBarName, "-v"). MatchStatus(statusKeys, true, len(statusKeys)). WithWorkDir(tempDir).Exec() // validate - fetched := ORAS("manifest", "fetch", RegistryRef(Host, repo, tag)).Exec().Out.Contents() + fetched := ORAS("manifest", "fetch", RegistryRef(ZOTHost, repo, tag)).Exec().Out.Contents() var manifest ocispec.Manifest Expect(json.Unmarshal(fetched, &manifest)).ShouldNot(HaveOccurred()) Expect(manifest.Layers).Should(ContainElements(foobar.BlobBarDescriptor("application/vnd.oci.image.layer.v1.tar"))) - fetched = ORAS("manifest", "fetch", RegistryRef(Host, repo, extraTag)).Exec().Out.Contents() + fetched = ORAS("manifest", "fetch", RegistryRef(ZOTHost, repo, extraTag)).Exec().Out.Contents() Expect(json.Unmarshal(fetched, &manifest)).ShouldNot(HaveOccurred()) Expect(manifest.Layers).Should(ContainElements(foobar.BlobBarDescriptor("application/vnd.oci.image.layer.v1.tar"))) }) It("should push files with customized media types", func() { repo := fmt.Sprintf("%s/%s", repoPrefix, "layer-mediatype") - layerType := "layer.type" + layerType := "layer/type" tempDir := PrepareTempFiles() - ORAS("push", RegistryRef(Host, repo, tag), foobar.FileBarName+":"+layerType, "-v"). + ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName+":"+layerType, "-v"). MatchStatus(statusKeys, true, len(statusKeys)). WithWorkDir(tempDir).Exec() // validate - fetched := ORAS("manifest", "fetch", RegistryRef(Host, repo, tag)).Exec().Out.Contents() + fetched := ORAS("manifest", "fetch", RegistryRef(ZOTHost, repo, tag)).Exec().Out.Contents() var manifest ocispec.Manifest Expect(json.Unmarshal(fetched, &manifest)).ShouldNot(HaveOccurred()) Expect(manifest.Layers).Should(ContainElements(foobar.BlobBarDescriptor(layerType))) @@ -135,14 +135,14 @@ var _ = Describe("Remote registry users:", func() { It("should push files with manifest exported", func() { repo := fmt.Sprintf("%s/%s", repoPrefix, "export-manifest") - layerType := "layer.type" + layerType := "layer/type" tempDir := PrepareTempFiles() exportPath := "packed.json" - ORAS("push", RegistryRef(Host, repo, tag), foobar.FileBarName+":"+layerType, "-v", "--export-manifest", exportPath). + ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName+":"+layerType, "-v", "--export-manifest", exportPath). MatchStatus(statusKeys, true, len(statusKeys)). WithWorkDir(tempDir).Exec() // validate - fetched := ORAS("manifest", "fetch", RegistryRef(Host, repo, tag)).Exec().Out.Contents() + fetched := ORAS("manifest", "fetch", RegistryRef(ZOTHost, repo, tag)).Exec().Out.Contents() MatchFile(filepath.Join(tempDir, exportPath), string(fetched), DefaultTimeout) }) @@ -150,14 +150,14 @@ var _ = Describe("Remote registry users:", func() { repo := fmt.Sprintf("%s/%s", repoPrefix, "config") tempDir := PrepareTempFiles() - ORAS("push", RegistryRef(Host, repo, tag), "--config", foobar.FileConfigName, foobar.FileBarName, "-v"). + ORAS("push", RegistryRef(ZOTHost, repo, tag), "--config", foobar.FileConfigName, foobar.FileBarName, "-v"). MatchStatus([]match.StateKey{ foobar.FileConfigStateKey, foobar.FileBarStateKey, }, true, 2). WithWorkDir(tempDir).Exec() // validate - fetched := ORAS("manifest", "fetch", RegistryRef(Host, repo, tag)).Exec().Out.Contents() + fetched := ORAS("manifest", "fetch", RegistryRef(ZOTHost, repo, tag)).Exec().Out.Contents() var manifest ocispec.Manifest Expect(json.Unmarshal(fetched, &manifest)).ShouldNot(HaveOccurred()) Expect(manifest.Config).Should(Equal(ocispec.Descriptor{ @@ -168,18 +168,18 @@ var _ = Describe("Remote registry users:", func() { }) It("should push files with customized config file and mediatype", func() { - repo := fmt.Sprintf("%s/%s", repoPrefix, "config-mediatype") + repo := fmt.Sprintf("%s/%s", repoPrefix, "config/mediatype") configType := "config.type" tempDir := PrepareTempFiles() - ORAS("push", RegistryRef(Host, repo, tag), "--config", fmt.Sprintf("%s:%s", foobar.FileConfigName, configType), foobar.FileBarName, "-v"). + ORAS("push", RegistryRef(ZOTHost, repo, tag), "--config", fmt.Sprintf("%s:%s", foobar.FileConfigName, configType), foobar.FileBarName, "-v"). MatchStatus([]match.StateKey{ {Digest: "46b68ac1696c", Name: configType}, foobar.FileBarStateKey, }, true, 2). WithWorkDir(tempDir).Exec() // validate - fetched := ORAS("manifest", "fetch", RegistryRef(Host, repo, tag)).Exec().Out.Contents() + fetched := ORAS("manifest", "fetch", RegistryRef(ZOTHost, repo, tag)).Exec().Out.Contents() var manifest ocispec.Manifest Expect(json.Unmarshal(fetched, &manifest)).ShouldNot(HaveOccurred()) Expect(manifest.Config).Should(Equal(ocispec.Descriptor{ @@ -195,11 +195,11 @@ var _ = Describe("Remote registry users:", func() { value := "image-anno-value" tempDir := PrepareTempFiles() // test - ORAS("push", RegistryRef(Host, repo, tag), foobar.FileBarName, "-v", "--annotation", fmt.Sprintf("%s=%s", key, value)). + ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName, "-v", "--annotation", fmt.Sprintf("%s=%s", key, value)). MatchStatus(statusKeys, true, len(statusKeys)). WithWorkDir(tempDir).Exec() // validate - fetched := ORAS("manifest", "fetch", RegistryRef(Host, repo, tag)).Exec().Out.Contents() + fetched := ORAS("manifest", "fetch", RegistryRef(ZOTHost, repo, tag)).Exec().Out.Contents() var manifest ocispec.Manifest Expect(json.Unmarshal(fetched, &manifest)).ShouldNot(HaveOccurred()) Expect(manifest.Annotations[key]).To(Equal(value)) @@ -209,13 +209,13 @@ var _ = Describe("Remote registry users:", func() { repo := fmt.Sprintf("%s/%s", repoPrefix, "file-annotation") tempDir := PrepareTempFiles() - ORAS("push", RegistryRef(Host, repo, tag), foobar.FileBarName, "-v", "--annotation-file", "foobar/annotation.json", "--config", foobar.FileConfigName). + ORAS("push", RegistryRef(ZOTHost, repo, tag), foobar.FileBarName, "-v", "--annotation-file", "foobar/annotation.json", "--config", foobar.FileConfigName). MatchStatus(statusKeys, true, 1). WithWorkDir(tempDir).Exec() // validate // see testdata\files\foobar\annotation.json - fetched := ORAS("manifest", "fetch", RegistryRef(Host, repo, tag)).Exec().Out.Contents() + fetched := ORAS("manifest", "fetch", RegistryRef(ZOTHost, repo, tag)).Exec().Out.Contents() var manifest ocispec.Manifest Expect(json.Unmarshal(fetched, &manifest)).ShouldNot(HaveOccurred()) Expect(manifest.Annotations["hi"]).To(Equal("manifest")) From f028e6183b69ce7c308836fb754e6fd119533998 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Mon, 28 Aug 2023 08:58:30 +0000 Subject: [PATCH 20/45] fix e2e Signed-off-by: Billy Zha --- test/e2e/suite/command/push.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/suite/command/push.go b/test/e2e/suite/command/push.go index fcc8f6f52..ef5cd9c12 100644 --- a/test/e2e/suite/command/push.go +++ b/test/e2e/suite/command/push.go @@ -316,7 +316,7 @@ var _ = Describe("OCI image layout users:", func() { }) It("should push files with customized config file and mediatype", func() { - configType := "config.type" + configType := "config/type" tempDir := PrepareTempFiles() ref := LayoutRef(tempDir, tag) ORAS("push", Flags.Layout, ref, "--config", fmt.Sprintf("%s:%s", foobar.FileConfigName, configType), foobar.FileBarName, "-v"). From a25d23f0e9c37de67c3934e895c448a3a65be93a Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Tue, 29 Aug 2023 03:17:14 +0000 Subject: [PATCH 21/45] fix e2e Signed-off-by: Billy Zha --- test/e2e/suite/command/push.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/suite/command/push.go b/test/e2e/suite/command/push.go index fcc8f6f52..ef5cd9c12 100644 --- a/test/e2e/suite/command/push.go +++ b/test/e2e/suite/command/push.go @@ -316,7 +316,7 @@ var _ = Describe("OCI image layout users:", func() { }) It("should push files with customized config file and mediatype", func() { - configType := "config.type" + configType := "config/type" tempDir := PrepareTempFiles() ref := LayoutRef(tempDir, tag) ORAS("push", Flags.Layout, ref, "--config", fmt.Sprintf("%s:%s", foobar.FileConfigName, configType), foobar.FileBarName, "-v"). From df78befa115b4dd46c1e4fc5b84f10976934ce75 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Tue, 29 Aug 2023 04:53:42 +0000 Subject: [PATCH 22/45] test(e2e): migrate specs for `oras pull` Signed-off-by: Billy Zha --- .gitignore | 5 +- test/e2e/suite/command/pull.go | 51 ++++++++----------- ...3eed4a446712eb6fdf08a665a4f2352d6d2f8bdf17 | 1 + ...3c1d30413413422d706483bfa0f98a5e886266e7ae | 1 + ...586f84d252530b7b5fe1c4104532767e6da4e04e47 | 1 + ...16f7e8649e94fb4fc21fe77e8310c060f61caaff8a | 1 + ...888b9351d80f6f5458dca9d3abef6560e7be255a3d | 1 + ...eb40e8175760dbb8615d2f815a6ca5239c901c6b38 | 1 + ...b721fe9b5c338d10ee429ea04fae5511b68fbf8fb9 | 1 + ...6cb4e7df0ab8a9d24adc57825099f522fe009a22bb | 1 + .../testdata/zot/command/artifacts/index.json | 23 +++++++++ .../testdata/zot/command/artifacts/oci-layout | 1 + 12 files changed, 57 insertions(+), 31 deletions(-) create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/0e007dcb9ded7f49c4dc8e3eed4a446712eb6fdf08a665a4f2352d6d2f8bdf17 create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47 create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/ae2d56717c9334fdc5fdb1888b9351d80f6f5458dca9d3abef6560e7be255a3d create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/f5d51c0823fc419652bb6beb40e8175760dbb8615d2f815a6ca5239c901c6b38 create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9 create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb create mode 100644 test/e2e/testdata/zot/command/artifacts/index.json create mode 100644 test/e2e/testdata/zot/command/artifacts/oci-layout diff --git a/.gitignore b/.gitignore index 163bf6ab3..f925d1241 100644 --- a/.gitignore +++ b/.gitignore @@ -53,7 +53,8 @@ test/e2e/testdata/distribution/mount_fallback/docker/ # OCI Layout Files ZOT storage files for local E2E testing test/e2e/testdata/zot/ -!test/e2e/testdata/zot/command/images -!test/e2e/testdata/zot/command/blobs +!test/e2e/testdata/zot/command/images/ +!test/e2e/testdata/zot/command/artifacts/ +!test/e2e/testdata/zot/command/blobs/ !test/e2e/testdata/zot/config.json !test/e2e/testdata/zot/passwd_bcrypt \ No newline at end of file diff --git a/test/e2e/suite/command/pull.go b/test/e2e/suite/command/pull.go index 21dfce721..504171609 100644 --- a/test/e2e/suite/command/pull.go +++ b/test/e2e/suite/command/pull.go @@ -51,7 +51,7 @@ var _ = Describe("Remote registry users:", func() { pullRoot := "pulled" tempDir := PrepareTempFiles() stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageConfigStateKey(configName)) - ORAS("pull", RegistryRef(Host, ImageRepo, foobar.Tag), "-v", "--config", configName, "-o", pullRoot). + ORAS("pull", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "-v", "--config", configName, "-o", pullRoot). MatchStatus(stateKeys, true, len(stateKeys)). WithWorkDir(tempDir).Exec() // check config @@ -67,7 +67,7 @@ var _ = Describe("Remote registry users:", func() { WithWorkDir(tempDir).Exec() } - ORAS("pull", RegistryRef(Host, ImageRepo, foobar.Tag), "-v", "-o", pullRoot, "--keep-old-files"). + ORAS("pull", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "-v", "-o", pullRoot, "--keep-old-files"). ExpectFailure(). WithDescription("fail if overwrite old files are disabled") }) @@ -76,7 +76,7 @@ var _ = Describe("Remote registry users:", func() { pullRoot := "pulled" tempDir := PrepareTempFiles() stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageConfigStateKey(oras.MediaTypeUnknownConfig)) - ORAS("pull", RegistryRef(Host, ImageRepo, foobar.Tag), "-v", "--config", fmt.Sprintf("%s:%s", configName, "???"), "-o", pullRoot). + ORAS("pull", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "-v", "--config", fmt.Sprintf("%s:%s", configName, "???"), "-o", pullRoot). MatchStatus(stateKeys, true, len(stateKeys)). WithWorkDir(tempDir).Exec() // check config @@ -96,13 +96,13 @@ var _ = Describe("Remote registry users:", func() { foobar.ManifestStateKey), foobar.ImageReferrersStateKeys..., ) - ORAS("pull", RegistryRef(Host, ArtifactRepo, foobar.SignatureImageReferrer.Digest.String()), "-v", "--include-subject"). + ORAS("pull", RegistryRef(ZOTHost, ArtifactRepo, foobar.SignatureImageReferrer.Digest.String()), "-v", "--include-subject"). MatchStatus(stateKeys, true, len(stateKeys)). WithWorkDir(tempDir).Exec() }) It("should pull specific platform", func() { - ORAS("pull", RegistryRef(Host, ImageRepo, "multi"), "--platform", "linux/amd64", "-v", "-o", GinkgoT().TempDir()). + ORAS("pull", RegistryRef(ZOTHost, ImageRepo, "multi"), "--platform", "linux/amd64", "-v", "-o", GinkgoT().TempDir()). MatchStatus(multi_arch.LinuxAMD64StateKeys, true, len(multi_arch.LinuxAMD64StateKeys)).Exec() }) }) @@ -113,19 +113,15 @@ var _ = Describe("OCI image layout users:", func() { var ( configName = "test.config" ) - prepare := func(root string, repo string, tagOrDigest string) { - ORAS("cp", RegistryRef(Host, repo, tagOrDigest), Flags.ToLayout, LayoutRef(root, tagOrDigest), "-r").WithDescription("prepare oci layout test env").Exec() - } It("should pull all files in an image to a target folder", func() { pullRoot := "pulled" - tempDir := PrepareTempFiles() - prepare(tempDir, ArtifactRepo, foobar.Tag) + root := PrepareTempOCI(ImageRepo) stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageConfigStateKey(configName)) - ORAS("pull", Flags.Layout, LayoutRef(tempDir, foobar.Tag), "-v", "--config", configName, "-o", pullRoot). + ORAS("pull", Flags.Layout, LayoutRef(root, foobar.Tag), "-v", "--config", configName, "-o", pullRoot). MatchStatus(stateKeys, true, len(stateKeys)). - WithWorkDir(tempDir).Exec() + WithWorkDir(root).Exec() // check config - configPath := filepath.Join(tempDir, pullRoot, configName) + configPath := filepath.Join(root, pullRoot, configName) Expect(configPath).Should(BeAnExistingFile()) f, err := os.Open(configPath) Expect(err).ShouldNot(HaveOccurred()) @@ -133,50 +129,47 @@ var _ = Describe("OCI image layout users:", func() { Eventually(gbytes.BufferReader(f)).Should(gbytes.Say("{}")) for _, f := range foobar.ImageLayerNames { // check layers - Binary("diff", filepath.Join(tempDir, "foobar", f), filepath.Join(pullRoot, f)). - WithWorkDir(tempDir).Exec() + Binary("diff", filepath.Join(root, "foobar", f), filepath.Join(pullRoot, f)). + WithWorkDir(root).Exec() } - ORAS("pull", Flags.Layout, LayoutRef(tempDir, foobar.Tag), "-v", "-o", pullRoot, "--keep-old-files"). + ORAS("pull", Flags.Layout, LayoutRef(root, foobar.Tag), "-v", "-o", pullRoot, "--keep-old-files"). ExpectFailure(). WithDescription("fail if overwrite old files are disabled") }) It("should skip config if media type does not match", func() { pullRoot := "pulled" - tempDir := PrepareTempFiles() - prepare(tempDir, ArtifactRepo, foobar.Tag) + root := PrepareTempOCI(ImageRepo) stateKeys := append(foobar.ImageLayerStateKeys, foobar.ManifestStateKey, foobar.ImageConfigStateKey(oras.MediaTypeUnknownConfig)) - ORAS("pull", Flags.Layout, LayoutRef(tempDir, foobar.Tag), "-v", "--config", fmt.Sprintf("%s:%s", configName, "???"), "-o", pullRoot). + ORAS("pull", Flags.Layout, LayoutRef(root, foobar.Tag), "-v", "--config", fmt.Sprintf("%s:%s", configName, "???"), "-o", pullRoot). MatchStatus(stateKeys, true, len(stateKeys)). - WithWorkDir(tempDir).Exec() + WithWorkDir(root).Exec() // check config Expect(filepath.Join(pullRoot, configName)).ShouldNot(BeAnExistingFile()) for _, f := range foobar.ImageLayerNames { // check layers - Binary("diff", filepath.Join(tempDir, "foobar", f), filepath.Join(pullRoot, f)). - WithWorkDir(tempDir). + Binary("diff", filepath.Join(root, "foobar", f), filepath.Join(pullRoot, f)). + WithWorkDir(root). WithDescription("should download identical file " + f).Exec() } }) It("should pull subject", func() { - tempDir := GinkgoT().TempDir() - prepare(tempDir, ArtifactRepo, foobar.Tag) + root := PrepareTempOCI(ArtifactRepo) stateKeys := append(append( foobar.ImageLayerStateKeys, foobar.ManifestStateKey), foobar.ImageReferrersStateKeys..., ) - ORAS("pull", Flags.Layout, LayoutRef(tempDir, foobar.SignatureImageReferrer.Digest.String()), "-v", "--include-subject"). + ORAS("pull", Flags.Layout, LayoutRef(root, foobar.SignatureImageReferrer.Digest.String()), "-v", "--include-subject"). MatchStatus(stateKeys, true, len(stateKeys)). - WithWorkDir(tempDir).Exec() + WithWorkDir(root).Exec() }) It("should pull specific platform", func() { - tempDir := GinkgoT().TempDir() - prepare(tempDir, ImageRepo, multi_arch.Tag) - ORAS("pull", Flags.Layout, LayoutRef(tempDir, multi_arch.Tag), "--platform", "linux/amd64", "-v", "-o", tempDir). + root := PrepareTempOCI(ImageRepo) + ORAS("pull", Flags.Layout, LayoutRef(root, multi_arch.Tag), "--platform", "linux/amd64", "-v", "-o", root). MatchStatus(multi_arch.LinuxAMD64StateKeys, true, len(multi_arch.LinuxAMD64StateKeys)).Exec() }) }) diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/0e007dcb9ded7f49c4dc8e3eed4a446712eb6fdf08a665a4f2352d6d2f8bdf17 b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/0e007dcb9ded7f49c4dc8e3eed4a446712eb6fdf08a665a4f2352d6d2f8bdf17 new file mode 100644 index 000000000..a51f76dac --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/0e007dcb9ded7f49c4dc8e3eed4a446712eb6fdf08a665a4f2352d6d2f8bdf17 @@ -0,0 +1 @@ +{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"test.signature.file","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:ae2d56717c9334fdc5fdb1888b9351d80f6f5458dca9d3abef6560e7be255a3d","size":16,"annotations":{"org.opencontainers.image.title":"signature"}}],"subject":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47","size":660},"annotations":{"org.opencontainers.image.created":"2023-01-18T08:37:57Z"}} \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae new file mode 100644 index 000000000..191028156 --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae @@ -0,0 +1 @@ +foo \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47 b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47 new file mode 100644 index 000000000..73ffd55d3 --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47 @@ -0,0 +1 @@ +{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"test.sbom.file","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:f5d51c0823fc419652bb6beb40e8175760dbb8615d2f815a6ca5239c901c6b38","size":11,"annotations":{"org.opencontainers.image.title":"sbom"}}],"subject":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb","size":851},"annotations":{"org.opencontainers.image.created":"2023-01-18T08:37:42Z"}} \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/ae2d56717c9334fdc5fdb1888b9351d80f6f5458dca9d3abef6560e7be255a3d b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/ae2d56717c9334fdc5fdb1888b9351d80f6f5458dca9d3abef6560e7be255a3d new file mode 100644 index 000000000..c180babc7 --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/ae2d56717c9334fdc5fdb1888b9351d80f6f5458dca9d3abef6560e7be255a3d @@ -0,0 +1 @@ +mocked signature \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/f5d51c0823fc419652bb6beb40e8175760dbb8615d2f815a6ca5239c901c6b38 b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/f5d51c0823fc419652bb6beb40e8175760dbb8615d2f815a6ca5239c901c6b38 new file mode 100644 index 000000000..68b8080ee --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/f5d51c0823fc419652bb6beb40e8175760dbb8615d2f815a6ca5239c901c6b38 @@ -0,0 +1 @@ +mocked sbom \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9 b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9 new file mode 100644 index 000000000..ba0e162e1 --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9 @@ -0,0 +1 @@ +bar \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb new file mode 100644 index 000000000..0ddf954a1 --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb @@ -0,0 +1 @@ +{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"application/vnd.unknown.config.v1+json","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae","size":3,"annotations":{"org.opencontainers.image.title":"foo1"}},{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae","size":3,"annotations":{"org.opencontainers.image.title":"foo2"}},{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9","size":3,"annotations":{"org.opencontainers.image.title":"bar"}}]} \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/index.json b/test/e2e/testdata/zot/command/artifacts/index.json new file mode 100644 index 000000000..e1a345312 --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/index.json @@ -0,0 +1,23 @@ +{ + "schemaVersion": 2, + "manifests": [ + { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "digest": "sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb", + "size": 851, + "annotations": { + "org.opencontainers.image.ref.name": "foobar" + } + }, + { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "digest": "sha256:32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47", + "size": 660 + }, + { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "digest": "sha256:0e007dcb9ded7f49c4dc8e3eed4a446712eb6fdf08a665a4f2352d6d2f8bdf17", + "size": 670 + } + ] +} \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/oci-layout b/test/e2e/testdata/zot/command/artifacts/oci-layout new file mode 100644 index 000000000..1343d370f --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/oci-layout @@ -0,0 +1 @@ +{"imageLayoutVersion":"1.0.0"} \ No newline at end of file From 1e9bbd8e587fbb8f0c4ddbe2adc7017ea928d8c7 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Tue, 29 Aug 2023 04:54:18 +0000 Subject: [PATCH 23/45] fix e2e Signed-off-by: Billy Zha --- test/e2e/suite/command/push.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/suite/command/push.go b/test/e2e/suite/command/push.go index ef5cd9c12..e10d47f3a 100644 --- a/test/e2e/suite/command/push.go +++ b/test/e2e/suite/command/push.go @@ -169,7 +169,7 @@ var _ = Describe("1.1 registry users:", func() { It("should push files with customized config file and mediatype", func() { repo := fmt.Sprintf("%s/%s", repoPrefix, "config/mediatype") - configType := "config.type" + configType := "config/type" tempDir := PrepareTempFiles() ORAS("push", RegistryRef(ZOTHost, repo, tag), "--config", fmt.Sprintf("%s:%s", foobar.FileConfigName, configType), foobar.FileBarName, "-v"). From 003c2c949fd4429c8775185d581cac733c16b859 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Tue, 29 Aug 2023 05:51:47 +0000 Subject: [PATCH 24/45] test(e2e): migrate `oras tag` specs to ZOT Signed-off-by: Billy Zha --- test/e2e/suite/command/tag.go | 48 ++++++++++------------------------- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/test/e2e/suite/command/tag.go b/test/e2e/suite/command/tag.go index 2a012acc2..3895d0424 100644 --- a/test/e2e/suite/command/tag.go +++ b/test/e2e/suite/command/tag.go @@ -33,7 +33,7 @@ var _ = Describe("ORAS beginners:", func() { }) It("should fail when provided manifest reference is not found", func() { - ORAS("tag", RegistryRef(Host, ImageRepo, "i-dont-think-this-tag-exists"), "tagged").ExpectFailure().MatchErrKeyWords("Error:").Exec() + ORAS("tag", RegistryRef(ZOTHost, ImageRepo, "i-dont-think-this-tag-exists"), "tagged").ExpectFailure().MatchErrKeyWords("Error:").Exec() }) It("should fail when provided invalid reference", func() { @@ -52,16 +52,16 @@ var _ = Describe("1.1 registry users:", func() { } When("running `tag`", func() { It("should add a tag to an existent manifest when providing tag reference", func() { - tagAndValidate(Host, ImageRepo, multi_arch.Tag, multi_arch.Digest, "tag-via-tag") + tagAndValidate(ZOTHost, ImageRepo, multi_arch.Tag, multi_arch.Digest, "tag-via-tag") }) It("should add a tag to an existent manifest when providing digest reference", func() { - tagAndValidate(Host, ImageRepo, multi_arch.Digest, multi_arch.Digest, "tag-via-digest") + tagAndValidate(ZOTHost, ImageRepo, multi_arch.Digest, multi_arch.Digest, "tag-via-digest") }) It("should add multiple tags to an existent manifest when providing digest reference", func() { - tagAndValidate(Host, ImageRepo, multi_arch.Digest, multi_arch.Digest, "tag1-via-digest", "tag2-via-digest", "tag3-via-digest") + tagAndValidate(ZOTHost, ImageRepo, multi_arch.Digest, multi_arch.Digest, "tag1-via-digest", "tag2-via-digest", "tag3-via-digest") }) It("should add multiple tags to an existent manifest when providing tag reference", func() { - tagAndValidate(Host, ImageRepo, multi_arch.Tag, multi_arch.Digest, "tag1-via-tag", "tag1-via-tag", "tag1-via-tag") + tagAndValidate(ZOTHost, ImageRepo, multi_arch.Tag, multi_arch.Digest, "tag1-via-tag", "tag1-via-tag", "tag1-via-tag") }) }) }) @@ -75,51 +75,29 @@ var _ = Describe("OCI image layout users:", func() { ORAS("repo", "tags", Flags.Layout, LayoutRef(root, "")).MatchKeyWords(tags...).Exec() } When("running `tag`", func() { - prepare := func() string { - root := GinkgoT().TempDir() - ORAS("cp", RegistryRef(Host, ImageRepo, multi_arch.Tag), Flags.ToLayout, LayoutRef(root, multi_arch.Tag)).Exec() - return root - } It("should add a tag to an existent manifest when providing tag reference", func() { - tagAndValidate(prepare(), multi_arch.Tag, multi_arch.Digest, "tag-via-tag") + tagAndValidate(PrepareTempOCI(ImageRepo), multi_arch.Tag, multi_arch.Digest, "tag-via-tag") }) It("should add a tag to an existent manifest when providing digest reference", func() { - tagAndValidate(prepare(), multi_arch.Digest, multi_arch.Digest, "tag-via-digest") + tagAndValidate(PrepareTempOCI(ImageRepo), multi_arch.Digest, multi_arch.Digest, "tag-via-digest") }) It("should add multiple tags to an existent manifest when providing digest reference", func() { - tagAndValidate(prepare(), multi_arch.Digest, multi_arch.Digest, "tag1-via-digest", "tag2-via-digest", "tag3-via-digest") + tagAndValidate(PrepareTempOCI(ImageRepo), multi_arch.Digest, multi_arch.Digest, "tag1-via-digest", "tag2-via-digest", "tag3-via-digest") }) It("should add multiple tags to an existent manifest when providing tag reference", func() { - tagAndValidate(prepare(), multi_arch.Tag, multi_arch.Digest, "tag1-via-tag", "tag1-via-tag", "tag1-via-tag") + tagAndValidate(PrepareTempOCI(ImageRepo), multi_arch.Tag, multi_arch.Digest, "tag1-via-tag", "tag1-via-tag", "tag1-via-tag") }) - }) -}) - -var _ = Describe("OCI image layout users:", func() { - var tagAndValidate = func(root string, tagOrDigest string, digest string, tags ...string) { - out := ORAS(append([]string{"tag", LayoutRef(root, tagOrDigest), Flags.Layout}, tags...)...).MatchKeyWords(tags...).Exec().Out - hint := regexp.QuoteMeta(fmt.Sprintf("Tagging [oci-layout] %s", LayoutRef(root, digest))) - gomega.Expect(out).To(gbytes.Say(hint)) - gomega.Expect(out).NotTo(gbytes.Say(hint)) // should only say hint once - ORAS("repo", "tags", Flags.Layout, LayoutRef(root, "")).MatchKeyWords(tags...).Exec() - } - When("running `tag`", func() { - prepare := func() string { - root := GinkgoT().TempDir() - ORAS("cp", RegistryRef(Host, ImageRepo, multi_arch.Tag), Flags.ToLayout, LayoutRef(root, multi_arch.Tag)).Exec() - return root - } It("should add a tag to an existent manifest when providing tag reference", func() { - tagAndValidate(prepare(), multi_arch.Tag, multi_arch.Digest, "tag-via-tag") + tagAndValidate(PrepareTempOCI(ImageRepo), multi_arch.Tag, multi_arch.Digest, "tag-via-tag") }) It("should add a tag to an existent manifest when providing digest reference", func() { - tagAndValidate(prepare(), multi_arch.Digest, multi_arch.Digest, "tag-via-digest") + tagAndValidate(PrepareTempOCI(ImageRepo), multi_arch.Digest, multi_arch.Digest, "tag-via-digest") }) It("should add multiple tags to an existent manifest when providing digest reference", func() { - tagAndValidate(prepare(), multi_arch.Digest, multi_arch.Digest, "tag1-via-digest", "tag2-via-digest", "tag3-via-digest") + tagAndValidate(PrepareTempOCI(ImageRepo), multi_arch.Digest, multi_arch.Digest, "tag1-via-digest", "tag2-via-digest", "tag3-via-digest") }) It("should add multiple tags to an existent manifest when providing tag reference", func() { - tagAndValidate(prepare(), multi_arch.Tag, multi_arch.Digest, "tag1-via-tag", "tag1-via-tag", "tag1-via-tag") + tagAndValidate(PrepareTempOCI(ImageRepo), multi_arch.Tag, multi_arch.Digest, "tag1-via-tag", "tag1-via-tag", "tag1-via-tag") }) }) }) From e654e069c837238ca43f90af9700699e36205849 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Tue, 29 Aug 2023 05:45:13 +0000 Subject: [PATCH 25/45] test(e2e): migrate `oras tag` specs to ZOT Signed-off-by: Billy Zha --- test/e2e/suite/command/tag.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/suite/command/tag.go b/test/e2e/suite/command/tag.go index 3895d0424..bcb494adb 100644 --- a/test/e2e/suite/command/tag.go +++ b/test/e2e/suite/command/tag.go @@ -66,7 +66,7 @@ var _ = Describe("1.1 registry users:", func() { }) }) -var _ = Describe("OCI image layout users:", func() { +var _ = Describe("OCI image layout users:", Focus, func() { var tagAndValidate = func(root string, tagOrDigest string, digest string, tags ...string) { out := ORAS(append([]string{"tag", LayoutRef(root, tagOrDigest), Flags.Layout}, tags...)...).MatchKeyWords(tags...).Exec().Out hint := regexp.QuoteMeta(fmt.Sprintf("Tagging [oci-layout] %s", LayoutRef(root, digest))) From d57f9bcad50816d7aef41ecaec3101630d7b494b Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Tue, 29 Aug 2023 05:51:28 +0000 Subject: [PATCH 26/45] test(e2e): migrate `oras repo` specs to ZOT Signed-off-by: Billy Zha --- test/e2e/suite/command/repo.go | 52 +++++++++++++--------------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/test/e2e/suite/command/repo.go b/test/e2e/suite/command/repo.go index 2176001d0..4079e3810 100644 --- a/test/e2e/suite/command/repo.go +++ b/test/e2e/suite/command/repo.go @@ -42,7 +42,7 @@ var _ = Describe("ORAS beginners:", func() { It("should fail listing repositories if wrong registry provided", func() { ORAS("repo", "ls").ExpectFailure().MatchErrKeyWords("Error:").Exec() - ORAS("repo", "ls", RegistryRef(Host, ImageRepo, "some-tag")).ExpectFailure().MatchErrKeyWords("Error:").Exec() + ORAS("repo", "ls", RegistryRef(ZOTHost, ImageRepo, "some-tag")).ExpectFailure().MatchErrKeyWords("Error:").Exec() }) }) When("running `repo tags`", func() { @@ -57,8 +57,8 @@ var _ = Describe("ORAS beginners:", func() { It("should fail listing repositories if wrong registry provided", func() { ORAS("repo", "tags").ExpectFailure().MatchErrKeyWords("Error:").Exec() - ORAS("repo", "tags", Host).ExpectFailure().MatchErrKeyWords("Error:").Exec() - ORAS("repo", "tags", RegistryRef(Host, ImageRepo, "some-tag")).ExpectFailure().MatchErrKeyWords("Error:").Exec() + ORAS("repo", "tags", ZOTHost).ExpectFailure().MatchErrKeyWords("Error:").Exec() + ORAS("repo", "tags", RegistryRef(ZOTHost, ImageRepo, "some-tag")).ExpectFailure().MatchErrKeyWords("Error:").Exec() }) }) }) @@ -67,27 +67,27 @@ var _ = Describe("ORAS beginners:", func() { var _ = Describe("1.1 registry users:", func() { When("running `repo ls`", func() { It("should list repositories", func() { - ORAS("repository", "list", Host).MatchKeyWords(ImageRepo).Exec() + ORAS("repository", "list", ZOTHost).MatchKeyWords(ImageRepo).Exec() }) It("should list repositories under provided namespace", func() { - ORAS("repo", "ls", RegistryRef(Host, Namespace, "")).MatchKeyWords(ImageRepo[len(Namespace)+1:]).Exec() + ORAS("repo", "ls", RegistryRef(ZOTHost, Namespace, "")).MatchKeyWords(ImageRepo[len(Namespace)+1:]).Exec() }) It("should not list repositories without a fully matched namespace", func() { repo := "command-draft/images" - ORAS("cp", RegistryRef(Host, ImageRepo, foobar.Tag), RegistryRef(Host, repo, foobar.Tag)). + ORAS("cp", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), RegistryRef(ZOTHost, repo, foobar.Tag)). WithDescription("prepare destination repo: " + repo). Exec() - ORAS("repo", "ls", Host).MatchKeyWords(ImageRepo, repo).Exec() - session := ORAS("repo", "ls", RegistryRef(Host, Namespace, "")).MatchKeyWords(ImageRepo[len(Namespace)+1:]).Exec() + ORAS("repo", "ls", ZOTHost).MatchKeyWords(ImageRepo, repo).Exec() + session := ORAS("repo", "ls", RegistryRef(ZOTHost, Namespace, "")).MatchKeyWords(ImageRepo[len(Namespace)+1:]).Exec() Expect(session.Out).ShouldNot(gbytes.Say(repo[len(Namespace)+1:])) }) It("should list repositories via short command", func() { - ORAS("repo", "ls", Host).MatchKeyWords(ImageRepo).Exec() + ORAS("repo", "ls", ZOTHost).MatchKeyWords(ImageRepo).Exec() }) It("should list partial repositories via `last` flag", func() { - session := ORAS("repo", "ls", Host, "--last", ImageRepo).Exec() + session := ORAS("repo", "ls", ZOTHost, "--last", ImageRepo).Exec() repoRegex := regexp.QuoteMeta(ImageRepo + "\n") Expect(session.Out).ShouldNot(gbytes.Say(repoRegex)) }) @@ -97,7 +97,7 @@ var _ = Describe("1.1 registry users:", func() { repoWithName := func(name string) string { return fmt.Sprintf("command/images/repo/tags/%d/%s", GinkgoRandomSeed(), name) } - repoRef := RegistryRef(Host, ImageRepo, "") + repoRef := RegistryRef(ZOTHost, ImageRepo, "") It("should list tags", func() { ORAS("repository", "show-tags", repoRef).MatchKeyWords(multi_arch.Tag, foobar.Tag).Exec() }) @@ -114,20 +114,20 @@ var _ = Describe("1.1 registry users:", func() { // prepare repo := repoWithName("filter-tag") tags := []string{foobar.Tag, "bax", "bay", "baz"} - refWithTags := fmt.Sprintf("%s:%s", RegistryRef(Host, repo, ""), strings.Join(tags, ",")) - ORAS("cp", RegistryRef(Host, ImageRepo, foobar.Tag), refWithTags). + refWithTags := fmt.Sprintf("%s:%s", RegistryRef(ZOTHost, repo, ""), strings.Join(tags, ",")) + ORAS("cp", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), refWithTags). WithDescription("prepare: copy and create multiple tags to " + refWithTags). Exec() - ORAS("cp", RegistryRef(Host, ImageRepo, multi_arch.Tag), RegistryRef(Host, ImageRepo, "")). + ORAS("cp", RegistryRef(ZOTHost, ImageRepo, multi_arch.Tag), RegistryRef(ZOTHost, ImageRepo, "")). WithDescription("prepare: copy tag with different digest"). Exec() // test - viaTag := ORAS("repo", "tags", "-v", RegistryRef(Host, repo, foobar.Tag)). + viaTag := ORAS("repo", "tags", "-v", RegistryRef(ZOTHost, repo, foobar.Tag)). MatchKeyWords(tags...). MatchErrKeyWords(feature.Experimental.Mark, foobar.Digest).Exec().Out Expect(viaTag).ShouldNot(gbytes.Say(multi_arch.Tag)) - viaDigest := ORAS("repo", "tags", "-v", RegistryRef(Host, repo, foobar.Digest)). + viaDigest := ORAS("repo", "tags", "-v", RegistryRef(ZOTHost, repo, foobar.Digest)). MatchKeyWords(tags...). MatchErrKeyWords(feature.Experimental.Mark, foobar.Digest).Exec().Out Expect(viaDigest).ShouldNot(gbytes.Say(multi_arch.Tag)) @@ -137,29 +137,19 @@ var _ = Describe("1.1 registry users:", func() { var _ = Describe("OCI image layout users:", func() { When("running `repo tags`", func() { - prepare := func(srcRef, repoRoot string, tags ...string) { - ORAS("cp", srcRef, LayoutRef(repoRoot, strings.Join(tags, ",")), Flags.ToLayout). - WithDescription("prepare in OCI layout"). - Exec() - } - foobarImageRef := RegistryRef(Host, ImageRepo, foobar.Tag) - multiImageRef := RegistryRef(Host, ImageRepo, multi_arch.Tag) tagOutput := foobar.Tag + "\n" It("should list tags", func() { - root := GinkgoT().TempDir() - prepare(foobarImageRef, root, foobar.Tag) + root := PrepareTempOCI(ImageRepo) ORAS("repository", "show-tags", root, Flags.Layout).MatchKeyWords(tagOutput).Exec() }) It("should list tags via short command", func() { - root := GinkgoT().TempDir() - prepare(foobarImageRef, root, foobar.Tag) + root := PrepareTempOCI(ImageRepo) ORAS("repository", "tags", root, Flags.Layout).MatchKeyWords(tagOutput).Exec() }) It("should list partial tags via `last` flag", func() { // prepare - root := GinkgoT().TempDir() extra := "zzz" - prepare(foobarImageRef, root, foobar.Tag, extra) + root := PrepareTempOCI(ImageRepo) // test session := ORAS("repository", "tags", root, "--last", foobar.Tag, Flags.Layout).MatchKeyWords(extra).Exec() Expect(session.Out).ShouldNot(gbytes.Say(regexp.QuoteMeta(tagOutput))) @@ -167,10 +157,8 @@ var _ = Describe("OCI image layout users:", func() { It("should list out tags associated to the provided reference", func() { // prepare - root := GinkgoT().TempDir() tags := []string{foobar.Tag, "bax", "bay", "baz"} - prepare(foobarImageRef, root, tags...) - prepare(multiImageRef, root, multi_arch.Tag) + root := PrepareTempOCI(ImageRepo) // test viaTag := ORAS("repo", "tags", "-v", LayoutRef(root, foobar.Tag), Flags.Layout). WithDescription("via tag"). From 0c7187cbf5e09e1f54e6c7a3d94c1ff9ff1b0ebe Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Tue, 29 Aug 2023 05:58:15 +0000 Subject: [PATCH 27/45] remove focus Signed-off-by: Billy Zha --- test/e2e/suite/command/tag.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/suite/command/tag.go b/test/e2e/suite/command/tag.go index bcb494adb..3895d0424 100644 --- a/test/e2e/suite/command/tag.go +++ b/test/e2e/suite/command/tag.go @@ -66,7 +66,7 @@ var _ = Describe("1.1 registry users:", func() { }) }) -var _ = Describe("OCI image layout users:", Focus, func() { +var _ = Describe("OCI image layout users:", func() { var tagAndValidate = func(root string, tagOrDigest string, digest string, tags ...string) { out := ORAS(append([]string{"tag", LayoutRef(root, tagOrDigest), Flags.Layout}, tags...)...).MatchKeyWords(tags...).Exec().Out hint := regexp.QuoteMeta(fmt.Sprintf("Tagging [oci-layout] %s", LayoutRef(root, digest))) From 1f18415eb1a7619d591ab8a7e1f8a423d765ac31 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Tue, 29 Aug 2023 07:05:25 +0000 Subject: [PATCH 28/45] test(e2e): migrate `oras repo` specs to ZOT Signed-off-by: Billy Zha --- test/e2e/suite/command/repo.go | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/test/e2e/suite/command/repo.go b/test/e2e/suite/command/repo.go index 4079e3810..3cbe628cf 100644 --- a/test/e2e/suite/command/repo.go +++ b/test/e2e/suite/command/repo.go @@ -86,11 +86,6 @@ var _ = Describe("1.1 registry users:", func() { It("should list repositories via short command", func() { ORAS("repo", "ls", ZOTHost).MatchKeyWords(ImageRepo).Exec() }) - It("should list partial repositories via `last` flag", func() { - session := ORAS("repo", "ls", ZOTHost, "--last", ImageRepo).Exec() - repoRegex := regexp.QuoteMeta(ImageRepo + "\n") - Expect(session.Out).ShouldNot(gbytes.Say(repoRegex)) - }) }) When("running `repo tags`", func() { @@ -105,10 +100,6 @@ var _ = Describe("1.1 registry users:", func() { ORAS("repo", "tags", repoRef).MatchKeyWords(multi_arch.Tag, foobar.Tag).Exec() }) - It("should list partial tags via `last` flag", func() { - session := ORAS("repo", "tags", repoRef, "--last", foobar.Tag).MatchKeyWords(multi_arch.Tag).Exec() - Expect(session.Out).ShouldNot(gbytes.Say(foobar.Tag)) - }) It("Should list out tags associated to the provided reference", func() { // prepare @@ -135,8 +126,25 @@ var _ = Describe("1.1 registry users:", func() { }) }) +var _ = Describe("1.0 registry users:", func() { + When("running `repo ls`", func() { + It("should list partial repositories via `last` flag", func() { + session := ORAS("repo", "ls", FallbackHost, "--last", ArtifactRepo).Exec() + repoRegex := regexp.QuoteMeta(ImageRepo + "\n") + Expect(session.Out).ShouldNot(gbytes.Say(repoRegex)) + }) + }) +}) + var _ = Describe("OCI image layout users:", func() { When("running `repo tags`", func() { + prepare := func(repo string, fromTag string, toTags ...string) string { + root := PrepareTempOCI(repo) + ORAS("tag", LayoutRef(root, fromTag), strings.Join(toTags, " "), Flags.Layout). + WithDescription("prepare in OCI layout"). + Exec() + return root + } tagOutput := foobar.Tag + "\n" It("should list tags", func() { root := PrepareTempOCI(ImageRepo) @@ -149,7 +157,7 @@ var _ = Describe("OCI image layout users:", func() { It("should list partial tags via `last` flag", func() { // prepare extra := "zzz" - root := PrepareTempOCI(ImageRepo) + root := prepare(ImageRepo, foobar.Tag, extra) // test session := ORAS("repository", "tags", root, "--last", foobar.Tag, Flags.Layout).MatchKeyWords(extra).Exec() Expect(session.Out).ShouldNot(gbytes.Say(regexp.QuoteMeta(tagOutput))) @@ -158,7 +166,7 @@ var _ = Describe("OCI image layout users:", func() { It("should list out tags associated to the provided reference", func() { // prepare tags := []string{foobar.Tag, "bax", "bay", "baz"} - root := PrepareTempOCI(ImageRepo) + root := prepare(ImageRepo, foobar.Tag, tags...) // test viaTag := ORAS("repo", "tags", "-v", LayoutRef(root, foobar.Tag), Flags.Layout). WithDescription("via tag"). From cd370e35663c57a7a5bd065c9f967a65075e56bb Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Tue, 29 Aug 2023 07:25:04 +0000 Subject: [PATCH 29/45] test(e2e): migrate `oras manifest` specs to ZOT Signed-off-by: Billy Zha --- test/e2e/suite/command/manifest.go | 169 ++++++++++++++--------------- 1 file changed, 84 insertions(+), 85 deletions(-) diff --git a/test/e2e/suite/command/manifest.go b/test/e2e/suite/command/manifest.go index 44d8f4ff0..68174b2c3 100644 --- a/test/e2e/suite/command/manifest.go +++ b/test/e2e/suite/command/manifest.go @@ -72,7 +72,7 @@ var _ = Describe("ORAS beginners:", func() { It("should fail pushing with a manifest from stdin without media type flag", func() { tag := "from-stdin" - ORAS("manifest", "push", RegistryRef(Host, ImageRepo, tag), "-", "--password-stdin", "--media-type", "application/vnd.oci.image.manifest.v1+json"). + ORAS("manifest", "push", RegistryRef(ZOTHost, ImageRepo, tag), "-", "--password-stdin", "--media-type", "application/vnd.oci.image.manifest.v1+json"). ExpectFailure(). MatchErrKeyWords("`-`", "`--password-stdin`", " cannot be both used").Exec() }) @@ -100,20 +100,20 @@ var _ = Describe("ORAS beginners:", func() { tempTag := "to-delete" It("should cancel deletion without confirmation", func() { dstRepo := fmt.Sprintf(repoFmt, "delete", "no-confirm") - prepare(RegistryRef(Host, ImageRepo, foobar.Tag), RegistryRef(Host, dstRepo, tempTag)) - ORAS("manifest", "delete", RegistryRef(Host, dstRepo, tempTag)). + prepare(RegistryRef(ZOTHost, ImageRepo, foobar.Tag), RegistryRef(ZOTHost, dstRepo, tempTag)) + ORAS("manifest", "delete", RegistryRef(ZOTHost, dstRepo, tempTag)). MatchKeyWords("Operation cancelled.", "Are you sure you want to delete the manifest ", " and all tags associated with it?").Exec() - validateTag(RegistryRef(Host, dstRepo, ""), tempTag, false) + validateTag(RegistryRef(ZOTHost, dstRepo, ""), tempTag, false) }) It("should fail if descriptor flag is provided without confirmation flag", func() { dstRepo := fmt.Sprintf(repoFmt, "delete", "descriptor-without-confirm") - prepare(RegistryRef(Host, ImageRepo, foobar.Tag), RegistryRef(Host, dstRepo, tempTag)) - ORAS("manifest", "delete", RegistryRef(Host, dstRepo, tempTag), "--descriptor").ExpectFailure().Exec() + prepare(RegistryRef(ZOTHost, ImageRepo, foobar.Tag), RegistryRef(ZOTHost, dstRepo, tempTag)) + ORAS("manifest", "delete", RegistryRef(ZOTHost, dstRepo, tempTag), "--descriptor").ExpectFailure().Exec() }) It("should fail to delete a non-existent manifest via digest without force flag set", func() { - toDeleteRef := RegistryRef(Host, ImageRepo, invalidDigest) + toDeleteRef := RegistryRef(ZOTHost, ImageRepo, invalidDigest) ORAS("manifest", "delete", toDeleteRef). ExpectFailure(). MatchErrKeyWords(toDeleteRef, "the specified manifest does not exist"). @@ -121,7 +121,7 @@ var _ = Describe("ORAS beginners:", func() { }) It("should fail to delete a non-existent manifest and output descriptor via digest, with force flag set", func() { - toDeleteRef := RegistryRef(Host, ImageRepo, invalidDigest) + toDeleteRef := RegistryRef(ZOTHost, ImageRepo, invalidDigest) ORAS("manifest", "delete", toDeleteRef, "--force", "--descriptor"). ExpectFailure(). MatchErrKeyWords(toDeleteRef, "the specified manifest does not exist"). @@ -129,7 +129,7 @@ var _ = Describe("ORAS beginners:", func() { }) It("should fail to delete a non-existent manifest and output descriptor via tag, without force flag set", func() { - toDeleteRef := RegistryRef(Host, ImageRepo, "this.tag.should-not.be-existed") + toDeleteRef := RegistryRef(ZOTHost, ImageRepo, "this.tag.should-not.be-existed") ORAS("manifest", "delete", toDeleteRef, "--force", "--descriptor"). ExpectFailure(). MatchErrKeyWords(toDeleteRef, "the specified manifest does not exist"). @@ -138,14 +138,14 @@ var _ = Describe("ORAS beginners:", func() { It("should fail if no manifest reference provided", func() { dstRepo := fmt.Sprintf(repoFmt, "delete", "no-reference") - prepare(RegistryRef(Host, ImageRepo, foobar.Tag), RegistryRef(Host, dstRepo, tempTag)) + prepare(RegistryRef(ZOTHost, ImageRepo, foobar.Tag), RegistryRef(ZOTHost, dstRepo, tempTag)) ORAS("manifest", "delete").ExpectFailure().Exec() }) It("should fail if no digest provided", func() { dstRepo := fmt.Sprintf(repoFmt, "delete", "no-reference") - prepare(RegistryRef(Host, ImageRepo, foobar.Tag), RegistryRef(Host, dstRepo, "")) - ORAS("manifest", "delete", RegistryRef(Host, dstRepo, "")).ExpectFailure().MatchErrKeyWords("name@digest").Exec() + prepare(RegistryRef(ZOTHost, ImageRepo, foobar.Tag), RegistryRef(ZOTHost, dstRepo, "")) + ORAS("manifest", "delete", RegistryRef(ZOTHost, dstRepo, "")).ExpectFailure().MatchErrKeyWords("name@digest").Exec() }) }) When("running `manifest fetch-config`", func() { @@ -159,10 +159,10 @@ var _ = Describe("ORAS beginners:", func() { }) It("should fail if provided reference does not exist", func() { - ORAS("manifest", "fetch-config", RegistryRef(Host, ImageRepo, "this-tag-should-not-exist")).ExpectFailure().Exec() + ORAS("manifest", "fetch-config", RegistryRef(ZOTHost, ImageRepo, "this-tag-should-not-exist")).ExpectFailure().Exec() }) It("should fail fetching a config of non-image manifest type", func() { - ORAS("manifest", "fetch-config", RegistryRef(Host, ImageRepo, multi_arch.Tag)).ExpectFailure().Exec() + ORAS("manifest", "fetch-config", RegistryRef(ZOTHost, ImageRepo, multi_arch.Tag)).ExpectFailure().Exec() }) }) }) @@ -172,108 +172,103 @@ var _ = Describe("1.1 registry users:", func() { repoFmt := fmt.Sprintf("command/manifest/%%s/%d/%%s", GinkgoRandomSeed()) When("running `manifest fetch`", func() { It("should fetch manifest list with digest", func() { - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.Digest)). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.Digest)). MatchContent(multi_arch.Manifest).Exec() }) It("should fetch manifest list with tag", func() { - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.Tag)). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.Tag)). MatchContent(multi_arch.Manifest).Exec() }) It("should fetch manifest list to stdout", func() { - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.Tag), "--output", "-"). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.Tag), "--output", "-"). MatchContent(multi_arch.Manifest).Exec() }) It("should fetch manifest to file and output descriptor to stdout", func() { fetchPath := filepath.Join(GinkgoT().TempDir(), "fetchedImage") - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.Tag), "--output", fetchPath, "--descriptor"). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.Tag), "--output", fetchPath, "--descriptor"). MatchContent(multi_arch.Descriptor).Exec() MatchFile(fetchPath, multi_arch.Manifest, DefaultTimeout) }) It("should fetch manifest via tag with platform selection", func() { - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.Tag), "--platform", "linux/amd64"). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.Tag), "--platform", "linux/amd64"). MatchContent(multi_arch.LinuxAMD64Manifest).Exec() }) It("should fetch manifest via digest with platform selection", func() { - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.Digest), "--platform", "linux/amd64"). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.Digest), "--platform", "linux/amd64"). MatchContent(multi_arch.LinuxAMD64Manifest).Exec() }) It("should fetch manifest with platform validation", func() { - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.LinuxAMD64.Digest.String()), "--platform", "linux/amd64"). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.LinuxAMD64.Digest.String()), "--platform", "linux/amd64"). MatchContent(multi_arch.LinuxAMD64Manifest).Exec() }) It("should fetch descriptor via digest", func() { - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.Digest), "--descriptor"). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.Digest), "--descriptor"). MatchContent(multi_arch.Descriptor).Exec() }) It("should fetch descriptor via digest with platform selection", func() { - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.Digest), "--platform", "linux/amd64", "--descriptor"). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.Digest), "--platform", "linux/amd64", "--descriptor"). MatchContent(multi_arch.LinuxAMD64IndexDesc).Exec() }) It("should fetch descriptor via digest with platform validation", func() { - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.LinuxAMD64.Digest.String()), "--platform", "linux/amd64", "--descriptor"). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.LinuxAMD64.Digest.String()), "--platform", "linux/amd64", "--descriptor"). MatchContent(multi_arch.LinuxAMD64DescStr).Exec() }) It("should fetch descriptor via tag", func() { - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.Tag), "--descriptor"). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.Tag), "--descriptor"). MatchContent(multi_arch.Descriptor).Exec() }) It("should fetch descriptor via tag with platform selection", func() { - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.Tag), "--platform", "linux/amd64", "--descriptor"). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.Tag), "--platform", "linux/amd64", "--descriptor"). MatchContent(multi_arch.LinuxAMD64IndexDesc).Exec() }) It("should fetch index content with media type assertion", func() { - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.Digest), "--media-type", "application/vnd.oci.image.index.v1+json"). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.Digest), "--media-type", "application/vnd.oci.image.index.v1+json"). MatchContent(multi_arch.Manifest).Exec() }) It("should fetch index descriptor with media type assertion", func() { - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.Digest), "--media-type", "application/vnd.oci.image.index.v1+json", "--descriptor"). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.Digest), "--media-type", "application/vnd.oci.image.index.v1+json", "--descriptor"). MatchContent(multi_arch.Descriptor).Exec() }) It("should fetch image content with media type assertion and platform selection", func() { - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.Tag), "--platform", "linux/amd64", "--media-type", "application/vnd.oci.image.index.v1+json,application/vnd.oci.image.manifest.v1+json"). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.Tag), "--platform", "linux/amd64", "--media-type", "application/vnd.oci.image.index.v1+json,application/vnd.oci.image.manifest.v1+json"). MatchContent(multi_arch.LinuxAMD64Manifest).Exec() - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.Digest), "--platform", "linux/amd64", "--media-type", "application/vnd.oci.image.index.v1+json,application/vnd.oci.image.manifest.v1+json", "--descriptor"). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.Digest), "--platform", "linux/amd64", "--media-type", "application/vnd.oci.image.index.v1+json,application/vnd.oci.image.manifest.v1+json", "--descriptor"). MatchContent(multi_arch.LinuxAMD64IndexDesc).Exec() }) It("should fetch image descriptor with media type assertion and platform selection", func() { - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.Tag), "--platform", "linux/amd64", "--media-type", "application/vnd.oci.image.index.v1+json,application/vnd.oci.image.manifest.v1+json", "--descriptor"). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.Tag), "--platform", "linux/amd64", "--media-type", "application/vnd.oci.image.index.v1+json,application/vnd.oci.image.manifest.v1+json", "--descriptor"). MatchContent(multi_arch.LinuxAMD64IndexDesc).Exec() - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.Digest), "--platform", "linux/amd64", "--media-type", "application/vnd.oci.image.index.v1+json,application/vnd.oci.image.manifest.v1+json", "--descriptor"). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.Digest), "--platform", "linux/amd64", "--media-type", "application/vnd.oci.image.index.v1+json,application/vnd.oci.image.manifest.v1+json", "--descriptor"). MatchContent(multi_arch.LinuxAMD64IndexDesc).Exec() }) It("should fetch image content with media type assertion and platform validation", func() { - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.LinuxAMD64.Digest.String()), "--platform", "linux/amd64", "--media-type", "application/vnd.oci.image.manifest.v1+json"). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.LinuxAMD64.Digest.String()), "--platform", "linux/amd64", "--media-type", "application/vnd.oci.image.manifest.v1+json"). MatchContent(multi_arch.LinuxAMD64Manifest).Exec() }) It("should fetch image descriptor with media type assertion and platform validation", func() { - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.LinuxAMD64.Digest.String()), "--platform", "linux/amd64", "--media-type", "application/vnd.oci.image.manifest.v1+json", "--descriptor"). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.LinuxAMD64.Digest.String()), "--platform", "linux/amd64", "--media-type", "application/vnd.oci.image.manifest.v1+json", "--descriptor"). MatchContent(multi_arch.LinuxAMD64DescStr).Exec() }) - It("should fail to fetch image if media type assertion fails", func() { - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, multi_arch.LinuxAMD64.Digest.String()), "--media-type", "this.will.not.be.found"). - ExpectFailure(). - MatchErrKeyWords(multi_arch.LinuxAMD64.Digest.String(), "error: ", "not found").Exec() - }) It("should fail if no manifest tag or digest is provided", func() { - ORAS("manifest", "fetch", RegistryRef(Host, ImageRepo, "")).ExpectFailure().MatchErrKeyWords("Error:", "invalid image reference").Exec() + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, "")).ExpectFailure().MatchErrKeyWords("Error:", "invalid image reference").Exec() }) }) @@ -284,14 +279,14 @@ var _ = Describe("1.1 registry users:", func() { It("should push a manifest from stdin without media type flag", func() { tag := "from-stdin" - ORAS("manifest", "push", RegistryRef(Host, ImageRepo, tag), "-"). - MatchKeyWords("Pushed", RegistryRef(Host, ImageRepo, tag), "Digest:", digest). + ORAS("manifest", "push", RegistryRef(ZOTHost, ImageRepo, tag), "-"). + MatchKeyWords("Pushed", RegistryRef(ZOTHost, ImageRepo, tag), "Digest:", digest). WithInput(strings.NewReader(manifest)).Exec() }) It("should push a manifest and output descriptor", func() { tag := "from-stdin" - ORAS("manifest", "push", RegistryRef(Host, ImageRepo, tag), "-", "--descriptor"). + ORAS("manifest", "push", RegistryRef(ZOTHost, ImageRepo, tag), "-", "--descriptor"). MatchContent(descriptor). WithInput(strings.NewReader(manifest)).Exec() }) @@ -299,8 +294,8 @@ var _ = Describe("1.1 registry users:", func() { It("should push a manifest from file", func() { manifestPath := WriteTempFile("manifest.json", manifest) tag := "from-file" - ORAS("manifest", "push", RegistryRef(Host, ImageRepo, tag), manifestPath, "--media-type", "application/vnd.oci.image.manifest.v1+json"). - MatchKeyWords("Pushed", RegistryRef(Host, ImageRepo, tag), "Digest:", digest). + ORAS("manifest", "push", RegistryRef(ZOTHost, ImageRepo, tag), manifestPath, "--media-type", "application/vnd.oci.image.manifest.v1+json"). + MatchKeyWords("Pushed", RegistryRef(ZOTHost, ImageRepo, tag), "Digest:", digest). WithInput(strings.NewReader(manifest)).Exec() }) @@ -308,11 +303,11 @@ var _ = Describe("1.1 registry users:", func() { manifest := `{"schemaVersion":2,"config":{"mediaType":"application/vnd.oci.image.config.v1+json","digest":"sha256:fe9dbc99451d0517d65e048c309f0b5afb2cc513b7a3d456b6cc29fe641386c5","size":53}}` digest := "sha256:0c2ae2c73c5dde0a42582d328b2e2ea43f36ba20f604fa8706f441ac8b0a3445" tag := "mediatype-flag" - ORAS("manifest", "push", RegistryRef(Host, ImageRepo, tag), "-", "--media-type", "application/vnd.oci.image.manifest.v1+json"). - MatchKeyWords("Pushed", RegistryRef(Host, ImageRepo, tag), "Digest:", digest). + ORAS("manifest", "push", RegistryRef(ZOTHost, ImageRepo, tag), "-", "--media-type", "application/vnd.oci.image.manifest.v1+json"). + MatchKeyWords("Pushed", RegistryRef(ZOTHost, ImageRepo, tag), "Digest:", digest). WithInput(strings.NewReader(manifest)).Exec() - ORAS("manifest", "push", RegistryRef(Host, ImageRepo, ""), "-"). + ORAS("manifest", "push", RegistryRef(ZOTHost, ImageRepo, ""), "-"). WithInput(strings.NewReader(manifest)). ExpectFailure(). WithDescription("fail if no media type flag provided").Exec() @@ -321,36 +316,36 @@ var _ = Describe("1.1 registry users:", func() { When("running `manifest fetch-config`", func() { It("should fetch a config via a tag", func() { - ORAS("manifest", "fetch-config", RegistryRef(Host, ImageRepo, foobar.Tag)). + ORAS("manifest", "fetch-config", RegistryRef(ZOTHost, ImageRepo, foobar.Tag)). MatchContent("{}").Exec() }) It("should fetch a config descriptor via a tag", func() { - ORAS("manifest", "fetch-config", "--descriptor", RegistryRef(Host, ImageRepo, foobar.Tag)). + ORAS("manifest", "fetch-config", "--descriptor", RegistryRef(ZOTHost, ImageRepo, foobar.Tag)). MatchContent(foobar.ImageConfigDesc).Exec() }) It("should fetch a config via digest", func() { - ORAS("manifest", "fetch-config", RegistryRef(Host, ImageRepo, foobar.Tag)). + ORAS("manifest", "fetch-config", RegistryRef(ZOTHost, ImageRepo, foobar.Tag)). MatchContent("{}").Exec() }) It("should fetch a config descriptor via a digest", func() { - ORAS("manifest", "fetch-config", "--descriptor", RegistryRef(Host, ImageRepo, foobar.Digest)). + ORAS("manifest", "fetch-config", "--descriptor", RegistryRef(ZOTHost, ImageRepo, foobar.Digest)). MatchContent(foobar.ImageConfigDesc).Exec() }) It("should fetch a config of a specific platform", func() { - ORAS("manifest", "fetch-config", "--platform", "linux/amd64", RegistryRef(Host, ImageRepo, multi_arch.Tag)). + ORAS("manifest", "fetch-config", "--platform", "linux/amd64", RegistryRef(ZOTHost, ImageRepo, multi_arch.Tag)). MatchContent(multi_arch.LinuxAMD64Config).Exec() }) It("should fetch a config descriptor of a specific platform", func() { - ORAS("manifest", "fetch-config", "--descriptor", "--platform", "linux/amd64", RegistryRef(Host, ImageRepo, multi_arch.Tag)). + ORAS("manifest", "fetch-config", "--descriptor", "--platform", "linux/amd64", RegistryRef(ZOTHost, ImageRepo, multi_arch.Tag)). MatchContent(multi_arch.LinuxAMD64ConfigDesc).Exec() }) It("should fail if no manifest tag or digest is provided", func() { - ORAS("manifest", "fetch-config", RegistryRef(Host, ImageRepo, "")).ExpectFailure().MatchErrKeyWords("Error:", "invalid image reference").Exec() + ORAS("manifest", "fetch-config", RegistryRef(ZOTHost, ImageRepo, "")).ExpectFailure().MatchErrKeyWords("Error:", "invalid image reference").Exec() }) }) @@ -358,30 +353,30 @@ var _ = Describe("1.1 registry users:", func() { tempTag := "to-delete" It("should do confirmed deletion via input", func() { dstRepo := fmt.Sprintf(repoFmt, "delete", "confirm-input") - prepare(RegistryRef(Host, ImageRepo, foobar.Tag), RegistryRef(Host, dstRepo, tempTag)) - ORAS("manifest", "delete", RegistryRef(Host, dstRepo, tempTag)). + prepare(RegistryRef(ZOTHost, ImageRepo, foobar.Tag), RegistryRef(ZOTHost, dstRepo, tempTag)) + ORAS("manifest", "delete", RegistryRef(ZOTHost, dstRepo, tempTag)). WithInput(strings.NewReader("y")).Exec() - validateTag(RegistryRef(Host, dstRepo, ""), tempTag, true) + validateTag(RegistryRef(ZOTHost, dstRepo, ""), tempTag, true) }) It("should do confirmed deletion via flag", func() { dstRepo := fmt.Sprintf(repoFmt, "delete", "confirm-flag") - prepare(RegistryRef(Host, ImageRepo, foobar.Tag), RegistryRef(Host, dstRepo, tempTag)) - ORAS("manifest", "delete", RegistryRef(Host, dstRepo, tempTag), "-f").Exec() - validateTag(RegistryRef(Host, dstRepo, ""), tempTag, true) + prepare(RegistryRef(ZOTHost, ImageRepo, foobar.Tag), RegistryRef(ZOTHost, dstRepo, tempTag)) + ORAS("manifest", "delete", RegistryRef(ZOTHost, dstRepo, tempTag), "-f").Exec() + validateTag(RegistryRef(ZOTHost, dstRepo, ""), tempTag, true) }) It("should do forced deletion and output descriptor", func() { dstRepo := fmt.Sprintf(repoFmt, "delete", "output-descriptor") - prepare(RegistryRef(Host, ImageRepo, foobar.Tag), RegistryRef(Host, dstRepo, tempTag)) - ORAS("manifest", "delete", RegistryRef(Host, dstRepo, tempTag), "-f", "--descriptor"). + prepare(RegistryRef(ZOTHost, ImageRepo, foobar.Tag), RegistryRef(ZOTHost, dstRepo, tempTag)) + ORAS("manifest", "delete", RegistryRef(ZOTHost, dstRepo, tempTag), "-f", "--descriptor"). MatchContent("{\"mediaType\":\"application/vnd.oci.image.manifest.v1+json\",\"digest\":\"sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb\",\"size\":851}"). WithDescription("cancel without confirmation").Exec() - validateTag(RegistryRef(Host, dstRepo, ""), tempTag, true) + validateTag(RegistryRef(ZOTHost, dstRepo, ""), tempTag, true) }) It("should succeed when deleting a non-existent manifest with force flag set", func() { - toDeleteRef := RegistryRef(Host, ImageRepo, invalidDigest) + toDeleteRef := RegistryRef(ZOTHost, ImageRepo, invalidDigest) ORAS("manifest", "delete", toDeleteRef, "--force"). MatchKeyWords("Missing", toDeleteRef). Exec() @@ -391,84 +386,79 @@ var _ = Describe("1.1 registry users:", func() { var _ = Describe("OCI image layout users:", func() { When("running `manifest fetch`", func() { - prepare := func() string { - tmp := GinkgoT().TempDir() - ORAS("cp", RegistryRef(Host, ImageRepo, multi_arch.Digest), Flags.ToLayout, LayoutRef(tmp, multi_arch.Tag)).WithDescription("prepare image from registry to OCI layout").Exec() - return tmp - } It("should fetch manifest list with digest", func() { - root := prepare() + root := PrepareTempOCI(ImageRepo) ORAS("manifest", "fetch", Flags.Layout, LayoutRef(root, multi_arch.Digest)). MatchContent(multi_arch.Manifest).Exec() }) It("should fetch manifest list with tag", func() { - root := prepare() + root := PrepareTempOCI(ImageRepo) ORAS("manifest", "fetch", Flags.Layout, LayoutRef(root, multi_arch.Tag)). MatchContent(multi_arch.Manifest).Exec() }) It("should fetch manifest list to stdout", func() { - root := prepare() + root := PrepareTempOCI(ImageRepo) ORAS("manifest", "fetch", Flags.Layout, LayoutRef(root, multi_arch.Tag), "--output", "-"). MatchContent(multi_arch.Manifest).Exec() }) It("should fetch manifest to file and output descriptor to stdout", func() { - root := prepare() + root := PrepareTempOCI(ImageRepo) fetchPath := filepath.Join(GinkgoT().TempDir(), "fetchedImage") ORAS("manifest", "fetch", Flags.Layout, LayoutRef(root, multi_arch.Digest), "--output", fetchPath, "--descriptor"). MatchContent(multi_arch.Descriptor).Exec() MatchFile(fetchPath, multi_arch.Manifest, DefaultTimeout) }) It("should fetch manifest via tag with platform selection", func() { - root := prepare() + root := PrepareTempOCI(ImageRepo) ORAS("manifest", "fetch", Flags.Layout, LayoutRef(root, multi_arch.Tag), "--platform", "linux/amd64"). MatchContent(multi_arch.LinuxAMD64Manifest).Exec() }) It("should fetch manifest via digest with platform selection", func() { - root := prepare() + root := PrepareTempOCI(ImageRepo) ORAS("manifest", "fetch", Flags.Layout, LayoutRef(root, multi_arch.Digest), "--platform", "linux/amd64"). MatchContent(multi_arch.LinuxAMD64Manifest).Exec() }) It("should fetch manifest with platform validation", func() { - root := prepare() + root := PrepareTempOCI(ImageRepo) ORAS("manifest", "fetch", Flags.Layout, LayoutRef(root, multi_arch.Digest), "--platform", "linux/amd64"). MatchContent(multi_arch.LinuxAMD64Manifest).Exec() }) It("should fetch descriptor via digest", func() { - root := prepare() + root := PrepareTempOCI(ImageRepo) ORAS("manifest", "fetch", Flags.Layout, LayoutRef(root, multi_arch.Digest), "--descriptor"). MatchContent(multi_arch.Descriptor).Exec() }) It("should fetch descriptor via digest with platform selection", func() { - root := prepare() + root := PrepareTempOCI(ImageRepo) ORAS("manifest", "fetch", Flags.Layout, LayoutRef(root, multi_arch.Digest), "--platform", "linux/amd64", "--descriptor"). MatchContent(multi_arch.LinuxAMD64IndexDesc).Exec() }) It("should fetch descriptor via digest with platform validation", func() { - root := prepare() + root := PrepareTempOCI(ImageRepo) ORAS("manifest", "fetch", Flags.Layout, LayoutRef(root, multi_arch.LinuxAMD64.Digest.String()), "--platform", "linux/amd64", "--descriptor"). MatchContent(multi_arch.LinuxAMD64DescStr).Exec() }) It("should fetch descriptor via tag", func() { - root := prepare() + root := PrepareTempOCI(ImageRepo) ORAS("manifest", "fetch", Flags.Layout, LayoutRef(root, multi_arch.Tag), "--descriptor"). MatchContent(multi_arch.AnnotatedDescriptor).Exec() }) It("should fetch descriptor via tag with platform selection", func() { - root := prepare() + root := PrepareTempOCI(ImageRepo) ORAS("manifest", "fetch", Flags.Layout, LayoutRef(root, multi_arch.Tag), "--platform", "linux/amd64", "--descriptor"). MatchContent(multi_arch.LinuxAMD64IndexDesc).Exec() }) It("should fail to fetch image if media type assertion is used", func() { - root := prepare() + root := PrepareTempOCI(ImageRepo) ORAS("manifest", "fetch", Flags.Layout, LayoutRef(root, multi_arch.Digest), "--media-type", "application/vnd.oci.image.manifest.v1+json"). ExpectFailure(). MatchErrKeyWords("Error", "--media-type", "--oci-layout").Exec() }) It("should fail if no manifest tag or digest is provided", func() { - root := prepare() + root := PrepareTempOCI(ImageRepo) ORAS("manifest", "fetch", Flags.Layout, root).ExpectFailure(). MatchErrKeyWords("Error:", "invalid image reference").Exec() }) @@ -478,7 +468,7 @@ var _ = Describe("OCI image layout users:", func() { prepare := func(tag string) string { tmpRoot := GinkgoT().TempDir() cpPath := tmpRoot - from := RegistryRef(Host, ImageRepo, tag) + from := RegistryRef(ZOTHost, ImageRepo, tag) cpPath = fmt.Sprintf("%s:%s", tmpRoot, tag) ORAS("cp", from, Flags.ToLayout, cpPath).WithDescription("prepare image from registry to OCI layout").Exec() return tmpRoot @@ -520,6 +510,15 @@ var _ = Describe("OCI image layout users:", func() { }) }) +var _ = Describe("1.0 registry users:", func() { + When("running `manifest fetch`", func() { + It("should fail to fetch image if media type assertion fails", func() { + ORAS("manifest", "fetch", RegistryRef(FallbackHost, ImageRepo, multi_arch.LinuxAMD64.Digest.String()), "--media-type", "this.will.not.be.found"). + ExpectFailure(). + MatchErrKeyWords(multi_arch.LinuxAMD64.Digest.String(), "error: ", "not found").Exec() + }) + }) +}) var _ = Describe("OCI image layout users:", func() { When("running `manifest push`", func() { scratchSize := 2 From 313073d775dedd6cdeeda2374ab8150e4ceb86a2 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Tue, 29 Aug 2023 07:55:36 +0000 Subject: [PATCH 30/45] move invalid pushing to fallback distribution Signed-off-by: Billy Zha --- test/e2e/suite/command/manifest.go | 34 ++++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/test/e2e/suite/command/manifest.go b/test/e2e/suite/command/manifest.go index 68174b2c3..f2c3e8fc4 100644 --- a/test/e2e/suite/command/manifest.go +++ b/test/e2e/suite/command/manifest.go @@ -298,20 +298,6 @@ var _ = Describe("1.1 registry users:", func() { MatchKeyWords("Pushed", RegistryRef(ZOTHost, ImageRepo, tag), "Digest:", digest). WithInput(strings.NewReader(manifest)).Exec() }) - - It("should push a manifest from stdin with media type flag", func() { - manifest := `{"schemaVersion":2,"config":{"mediaType":"application/vnd.oci.image.config.v1+json","digest":"sha256:fe9dbc99451d0517d65e048c309f0b5afb2cc513b7a3d456b6cc29fe641386c5","size":53}}` - digest := "sha256:0c2ae2c73c5dde0a42582d328b2e2ea43f36ba20f604fa8706f441ac8b0a3445" - tag := "mediatype-flag" - ORAS("manifest", "push", RegistryRef(ZOTHost, ImageRepo, tag), "-", "--media-type", "application/vnd.oci.image.manifest.v1+json"). - MatchKeyWords("Pushed", RegistryRef(ZOTHost, ImageRepo, tag), "Digest:", digest). - WithInput(strings.NewReader(manifest)).Exec() - - ORAS("manifest", "push", RegistryRef(ZOTHost, ImageRepo, ""), "-"). - WithInput(strings.NewReader(manifest)). - ExpectFailure(). - WithDescription("fail if no media type flag provided").Exec() - }) }) When("running `manifest fetch-config`", func() { @@ -518,6 +504,26 @@ var _ = Describe("1.0 registry users:", func() { MatchErrKeyWords(multi_arch.LinuxAMD64.Digest.String(), "error: ", "not found").Exec() }) }) + + When("running `manifest push`", Focus, func() { + repoFmt := fmt.Sprintf("command/manifest/%%s/%d/%%s", GinkgoRandomSeed()) + It("should push a manifest from stdin with media type flag", func() { + dstRepo := fmt.Sprintf(repoFmt, "push", "no-media-type") + manifest := `{"schemaVersion":2,"config":{"mediaType":"application/vnd.oci.image.config.v1+json","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":53}}` + digest := "sha256:ed83217a266b93461f3d98c4184ddeacf5991482752c3bafd2a4170a58028e91" + tag := "mediatype-flag" + // prepare + ORAS("cp", RegistryRef(FallbackHost, ArtifactRepo, foobar.Tag), RegistryRef(FallbackHost, dstRepo, foobar.Tag)).Exec() + ORAS("manifest", "push", RegistryRef(FallbackHost, dstRepo, tag), "-", "--media-type", "application/vnd.oci.image.manifest.v1+json"). + MatchKeyWords("Pushed", RegistryRef(FallbackHost, dstRepo, tag), "Digest:", digest). + WithInput(strings.NewReader(manifest)).Exec() + + ORAS("manifest", "push", RegistryRef(FallbackHost, dstRepo, ""), "-"). + WithInput(strings.NewReader(manifest)). + ExpectFailure(). + WithDescription("fail if no media type flag provided").Exec() + }) + }) }) var _ = Describe("OCI image layout users:", func() { When("running `manifest push`", func() { From 98be084649f037729feeb265af6bc8899bc6323b Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Tue, 29 Aug 2023 07:56:29 +0000 Subject: [PATCH 31/45] remove focus Signed-off-by: Billy Zha --- test/e2e/suite/command/manifest.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/suite/command/manifest.go b/test/e2e/suite/command/manifest.go index f2c3e8fc4..475301712 100644 --- a/test/e2e/suite/command/manifest.go +++ b/test/e2e/suite/command/manifest.go @@ -505,7 +505,7 @@ var _ = Describe("1.0 registry users:", func() { }) }) - When("running `manifest push`", Focus, func() { + When("running `manifest push`", func() { repoFmt := fmt.Sprintf("command/manifest/%%s/%d/%%s", GinkgoRandomSeed()) It("should push a manifest from stdin with media type flag", func() { dstRepo := fmt.Sprintf(repoFmt, "push", "no-media-type") From d657c2fe8f6eb24827e9771449ffcccaaa3e6411 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Wed, 30 Aug 2023 06:28:47 +0000 Subject: [PATCH 32/45] test(e2e): migrate `oras cp` specs to ZOT Signed-off-by: Billy Zha --- test/e2e/internal/testdata/foobar/const.go | 1 + .../e2e/internal/testdata/multi_arch/const.go | 14 +- test/e2e/suite/command/cp.go | 138 +++++++++--------- ...1815e2881f1eec22958d604301904c5353041794c1 | 4 + ...b5cc8fc5cc1fb637dfaedb3a9afc89bf16db9277e1 | Bin 0 -> 10240 bytes ...772dc6ab72130d9ac1906aed2fc7589a5cd145433c | 1 + ...007a025c594ce12aa7e6da27d21c7b14b50112e255 | 1 + ...8ed157ba7d1edfe7f9b8766728b8a1f25c0d9c14c1 | 1 + ...10591f0203bb6e07f11e2fb0ce1b8508e9aac4ebe2 | 5 + ...7dd543d4cc158946117943700b8f520f72ddca031f | 1 + ...102075d56b970fbf910be5c6bca07fdbb000dfa383 | 1 + ...a28c6bc5806b7fa581c9ad7883be955a64e3cc034f | 1 + ...8c309f0b5afb2cc513b7a3d456b6cc29fe641386c5 | 4 + .../testdata/zot/command/artifacts/index.json | 33 +++++ 14 files changed, 126 insertions(+), 79 deletions(-) create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/1fd9a5fc54b634130102861815e2881f1eec22958d604301904c5353041794c1 create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/2ef548696ac7dd66ef38aab5cc8fc5cc1fb637dfaedb3a9afc89bf16db9277e1 create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/4f93460061882467e6fb3b772dc6ab72130d9ac1906aed2fc7589a5cd145433c create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/58efe73e78fe043ca31b89007a025c594ce12aa7e6da27d21c7b14b50112e255 create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/9d84a5716c66a1d1b9c13f8ed157ba7d1edfe7f9b8766728b8a1f25c0d9c14c1 create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/a5dfce5d28768e985f91f610591f0203bb6e07f11e2fb0ce1b8508e9aac4ebe2 create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/c5e00045954a70e3fd28307dd543d4cc158946117943700b8f520f72ddca031f create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/d37baf66300b9006b0f4c7102075d56b970fbf910be5c6bca07fdbb000dfa383 create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/e2bfc9cc6a84ec2d7365b5a28c6bc5806b7fa581c9ad7883be955a64e3cc034f create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/fe9dbc99451d0517d65e048c309f0b5afb2cc513b7a3d456b6cc29fe641386c5 diff --git a/test/e2e/internal/testdata/foobar/const.go b/test/e2e/internal/testdata/foobar/const.go index 0ea5471f0..80d0ea16d 100644 --- a/test/e2e/internal/testdata/foobar/const.go +++ b/test/e2e/internal/testdata/foobar/const.go @@ -121,6 +121,7 @@ var ( {Digest: "8d7a27ff2662", Name: "application/vnd.oci.artifact.manifest.v1+json"}, {Digest: "2dbea575a349", Name: "application/vnd.oci.artifact.manifest.v1+json"}, } + ImageReferrersStateKeys = []match.StateKey{ {Digest: "0e007dcb9ded", Name: "application/vnd.oci.image.manifest.v1+json"}, {Digest: "32b78bd00723", Name: "application/vnd.oci.image.manifest.v1+json"}, diff --git a/test/e2e/internal/testdata/multi_arch/const.go b/test/e2e/internal/testdata/multi_arch/const.go index a90e8e2e3..6501ee110 100644 --- a/test/e2e/internal/testdata/multi_arch/const.go +++ b/test/e2e/internal/testdata/multi_arch/const.go @@ -27,14 +27,16 @@ var ( Manifest = `{"mediaType":"application/vnd.oci.image.index.v1+json","schemaVersion":2,"manifests":[{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:9d84a5716c66a1d1b9c13f8ed157ba7d1edfe7f9b8766728b8a1f25c0d9c14c1","size":458,"platform":{"architecture":"amd64","os":"linux"}},{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:4f93460061882467e6fb3b772dc6ab72130d9ac1906aed2fc7589a5cd145433c","size":458,"platform":{"architecture":"arm64","os":"linux"}},{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:58efe73e78fe043ca31b89007a025c594ce12aa7e6da27d21c7b14b50112e255","size":458,"platform":{"architecture":"arm","os":"linux","variant":"v7"}}]}` Descriptor = `{"mediaType":"application/vnd.oci.image.index.v1+json","digest":"sha256:e2bfc9cc6a84ec2d7365b5a28c6bc5806b7fa581c9ad7883be955a64e3cc034f","size":706}` AnnotatedDescriptor = `{"mediaType":"application/vnd.oci.image.index.v1+json","digest":"sha256:e2bfc9cc6a84ec2d7365b5a28c6bc5806b7fa581c9ad7883be955a64e3cc034f","size":706,"annotations":{"org.opencontainers.image.ref.name":"multi"}}` - IndexReferrerDigest = "sha256:d3cf790759b006e1a2aeee52f9b1ee250bb848fce7e873b992b86bf9408f12d0" + IndexReferrerDigest = "sha256:d37baf66300b9006b0f4c7102075d56b970fbf910be5c6bca07fdbb000dfa383" IndexReferrerStateKey = match.StateKey{Digest: "d3cf790759b0", Name: "application/vnd.oci.image.manifest.v1+json"} - IndexReferrerConfigStateKey = match.StateKey{Digest: "44136fa355b3", Name: "referrer.index"} + IndexReferrerConfigStateKey = match.StateKey{Digest: "44136fa355b3", Name: "referrer/index"} IndexStateKeys = []match.StateKey{ {Digest: "2ef548696ac7", Name: "hello.tar"}, {Digest: "fe9dbc99451d", Name: "application/vnd.oci.image.config.v1+json"}, {Digest: "9d84a5716c66", Name: "application/vnd.oci.image.manifest.v1+json"}, } + // below are newly baked artifacts for ZOT + IndexZOTReferrerStateKey = match.StateKey{Digest: "d37baf66300b", Name: "application/vnd.oci.image.manifest.v1+json"} ) // child images @@ -51,17 +53,17 @@ var ( LinuxAMD64ConfigDesc = `{"mediaType":"application/vnd.oci.image.config.v1+json","digest":"sha256:fe9dbc99451d0517d65e048c309f0b5afb2cc513b7a3d456b6cc29fe641386c5","size":53}` LinuxAMD64Referrer = ocispec.Descriptor{ MediaType: "application/vnd.oci.image.manifest.v1+json", - Digest: digest.Digest("sha256:57e6462826c85be15f22f824666f6b467d488fa7bc7e2975f43a2fae27a24ef0"), + Digest: digest.Digest("sha256:c5e00045954a70e3fd28307dd543d4cc158946117943700b8f520f72ddca031f"), Annotations: map[string]string{ "org.opencontainers.image.created": "2023-02-15T07:56:34Z", "subject": "linux/amd64", }, - ArtifactType: "referrer.image", + ArtifactType: "referrer/image", Size: 481, } LayerName = "hello.tar" - LinuxAMD64ReferrerStateKey = match.StateKey{Digest: "57e6462826c8", Name: "application/vnd.oci.image.manifest.v1+json"} - LinuxAMD64ReferrerConfigStateKey = match.StateKey{Digest: "44136fa355b3", Name: "referrer.image"} + LinuxAMD64ReferrerStateKey = match.StateKey{Digest: "c5e00045954a", Name: "application/vnd.oci.image.manifest.v1+json"} + LinuxAMD64ReferrerConfigStateKey = match.StateKey{Digest: "44136fa355b3", Name: "referrer/image"} LinuxAMD64StateKeys = []match.StateKey{ {Digest: "9d84a5716c66", Name: "application/vnd.oci.image.manifest.v1+json"}, {Digest: "fe9dbc99451d", Name: "application/vnd.oci.image.config.v1+json"}, diff --git a/test/e2e/suite/command/cp.go b/test/e2e/suite/command/cp.go index 3d06cf1e4..2cb3a813e 100644 --- a/test/e2e/suite/command/cp.go +++ b/test/e2e/suite/command/cp.go @@ -51,11 +51,11 @@ var _ = Describe("ORAS beginners:", func() { }) It("should fail when no destination reference provided", func() { - ORAS("cp", RegistryRef(Host, ImageRepo, foobar.Tag)).ExpectFailure().MatchErrKeyWords("Error:").Exec() + ORAS("cp", RegistryRef(ZOTHost, ImageRepo, foobar.Tag)).ExpectFailure().MatchErrKeyWords("Error:").Exec() }) It("should fail when source doesn't exist", func() { - ORAS("cp", RegistryRef(Host, ImageRepo, "i-dont-think-this-tag-exists"), RegistryRef(Host, cpTestRepo("nonexistent-source"), "")).ExpectFailure().MatchErrKeyWords("Error:").Exec() + ORAS("cp", RegistryRef(ZOTHost, ImageRepo, "i-dont-think-this-tag-exists"), RegistryRef(ZOTHost, cpTestRepo("nonexistent-source"), "")).ExpectFailure().MatchErrKeyWords("Error:").Exec() }) }) }) @@ -71,45 +71,37 @@ func CompareRef(src, dst string) { var _ = Describe("1.1 registry users:", func() { When("running `cp`", func() { It("should copy an image to a new repository via tag", func() { - src := RegistryRef(Host, ImageRepo, foobar.Tag) - dst := RegistryRef(Host, cpTestRepo("tag"), "copiedTag") + src := RegistryRef(ZOTHost, ImageRepo, foobar.Tag) + dst := RegistryRef(ZOTHost, cpTestRepo("tag"), "copiedTag") ORAS("cp", src, dst, "-v").MatchStatus(foobarStates, true, len(foobarStates)).Exec() CompareRef(src, dst) }) It("should copy an image to a new repository via digest", func() { - src := RegistryRef(Host, ImageRepo, foobar.Digest) - dst := RegistryRef(Host, cpTestRepo("digest"), "copiedTag") + src := RegistryRef(ZOTHost, ImageRepo, foobar.Digest) + dst := RegistryRef(ZOTHost, cpTestRepo("digest"), "copiedTag") ORAS("cp", src, dst, "-v").MatchStatus(foobarStates, true, len(foobarStates)).Exec() CompareRef(src, dst) }) It("should copy an image to a new repository via tag without tagging", func() { - src := RegistryRef(Host, ImageRepo, foobar.Tag) - dst := RegistryRef(Host, cpTestRepo("no-tagging"), foobar.Digest) + src := RegistryRef(ZOTHost, ImageRepo, foobar.Tag) + dst := RegistryRef(ZOTHost, cpTestRepo("no-tagging"), foobar.Digest) ORAS("cp", src, dst, "-v").MatchStatus(foobarStates, true, len(foobarStates)).Exec() CompareRef(src, dst) }) - It("should copy an image and its referrers to a new repository", func() { - stateKeys := append(append(foobarStates, foobar.ArtifactReferrerStateKeys...), foobar.ImageReferrerConfigStateKeys...) - src := RegistryRef(Host, ArtifactRepo, foobar.Tag) - dst := RegistryRef(Host, cpTestRepo("referrers"), foobar.Digest) - ORAS("cp", "-r", src, dst, "-v").MatchStatus(stateKeys, true, len(stateKeys)).Exec() - CompareRef(src, dst) - }) - It("should copy a multi-arch image and its referrers to a new repository via tag", func() { - stateKeys := append(ma.IndexStateKeys, ma.IndexReferrerStateKey, ma.IndexReferrerConfigStateKey) - src := RegistryRef(Host, ArtifactRepo, ma.Tag) + stateKeys := append(ma.IndexStateKeys, ma.IndexZOTReferrerStateKey, ma.IndexReferrerConfigStateKey) + src := RegistryRef(ZOTHost, ArtifactRepo, ma.Tag) dstRepo := cpTestRepo("index-referrers") - dst := RegistryRef(Host, dstRepo, "copiedTag") + dst := RegistryRef(ZOTHost, dstRepo, "copiedTag") ORAS("cp", src, dst, "-r", "-v"). MatchStatus(stateKeys, true, len(stateKeys)). MatchKeyWords("Digest: " + ma.Digest). Exec() // validate - CompareRef(RegistryRef(Host, ImageRepo, ma.Digest), dst) + CompareRef(RegistryRef(ZOTHost, ImageRepo, ma.Digest), dst) var index ocispec.Index bytes := ORAS("discover", dst, "-o", "json"). MatchKeyWords(ma.IndexReferrerDigest). @@ -118,23 +110,23 @@ var _ = Describe("1.1 registry users:", func() { Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred()) Expect(len(index.Manifests)).To(Equal(1)) Expect(index.Manifests[0].Digest.String()).To(Equal(ma.IndexReferrerDigest)) - ORAS("manifest", "fetch", RegistryRef(Host, dstRepo, ma.LinuxAMD64Referrer.Digest.String())). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, dstRepo, ma.LinuxAMD64Referrer.Digest.String())). WithDescription("not copy referrer of successor"). ExpectFailure(). Exec() }) It("should copy a multi-arch image and its referrers to a new repository via digest", func() { - stateKeys := append(ma.IndexStateKeys, ma.IndexReferrerStateKey, ma.IndexReferrerConfigStateKey) - src := RegistryRef(Host, ArtifactRepo, ma.Tag) + stateKeys := append(ma.IndexStateKeys, ma.IndexZOTReferrerStateKey, ma.IndexReferrerConfigStateKey) + src := RegistryRef(ZOTHost, ArtifactRepo, ma.Tag) dstRepo := cpTestRepo("index-referrers-digest") - dst := RegistryRef(Host, dstRepo, ma.Digest) + dst := RegistryRef(ZOTHost, dstRepo, ma.Digest) ORAS("cp", src, dst, "-r", "-v"). MatchStatus(stateKeys, true, len(stateKeys)). MatchKeyWords("Digest: " + ma.Digest). Exec() // validate - CompareRef(RegistryRef(Host, ImageRepo, ma.Digest), dst) + CompareRef(RegistryRef(ZOTHost, ImageRepo, ma.Digest), dst) var index ocispec.Index bytes := ORAS("discover", dst, "-o", "json"). MatchKeyWords(ma.IndexReferrerDigest). @@ -143,45 +135,45 @@ var _ = Describe("1.1 registry users:", func() { Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred()) Expect(len(index.Manifests)).To(Equal(1)) Expect(index.Manifests[0].Digest.String()).To(Equal(ma.IndexReferrerDigest)) - ORAS("manifest", "fetch", RegistryRef(Host, dstRepo, ma.LinuxAMD64Referrer.Digest.String())). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, dstRepo, ma.LinuxAMD64Referrer.Digest.String())). WithDescription("not copy referrer of successor"). ExpectFailure(). Exec() }) It("should copy a certain platform of image to a new repository via tag", func() { - src := RegistryRef(Host, ImageRepo, ma.Tag) - dst := RegistryRef(Host, cpTestRepo("platform-tag"), "copiedTag") + src := RegistryRef(ZOTHost, ImageRepo, ma.Tag) + dst := RegistryRef(ZOTHost, cpTestRepo("platform-tag"), "copiedTag") ORAS("cp", src, dst, "--platform", "linux/amd64", "-v"). MatchStatus(ma.LinuxAMD64StateKeys, true, len(ma.LinuxAMD64StateKeys)). MatchKeyWords("Digest: " + ma.LinuxAMD64.Digest.String()). Exec() - CompareRef(RegistryRef(Host, ImageRepo, ma.LinuxAMD64.Digest.String()), dst) + CompareRef(RegistryRef(ZOTHost, ImageRepo, ma.LinuxAMD64.Digest.String()), dst) }) It("should copy a certain platform of image to a new repository via digest", func() { - src := RegistryRef(Host, ImageRepo, ma.Digest) + src := RegistryRef(ZOTHost, ImageRepo, ma.Digest) dstRepo := cpTestRepo("platform-digest") - dst := RegistryRef(Host, dstRepo, "") + dst := RegistryRef(ZOTHost, dstRepo, "") ORAS("cp", src, dst, "--platform", "linux/amd64", "-v"). MatchStatus(ma.LinuxAMD64StateKeys, true, len(ma.LinuxAMD64StateKeys)). MatchKeyWords("Digest: " + ma.LinuxAMD64.Digest.String()). Exec() - CompareRef(RegistryRef(Host, ImageRepo, ma.LinuxAMD64.Digest.String()), RegistryRef(Host, dstRepo, ma.LinuxAMD64.Digest.String())) + CompareRef(RegistryRef(ZOTHost, ImageRepo, ma.LinuxAMD64.Digest.String()), RegistryRef(ZOTHost, dstRepo, ma.LinuxAMD64.Digest.String())) }) It("should copy a certain platform of image and its referrers to a new repository with tag", func() { stateKeys := append(ma.LinuxAMD64StateKeys, ma.LinuxAMD64ReferrerStateKey, ma.LinuxAMD64ReferrerConfigStateKey) - src := RegistryRef(Host, ArtifactRepo, ma.Tag) + src := RegistryRef(ZOTHost, ArtifactRepo, ma.Tag) dstRepo := cpTestRepo("platform-referrers") - dst := RegistryRef(Host, dstRepo, "copiedTag") + dst := RegistryRef(ZOTHost, dstRepo, "copiedTag") ORAS("cp", src, dst, "-r", "--platform", "linux/amd64", "-v"). MatchStatus(stateKeys, true, len(stateKeys)). MatchKeyWords("Digest: " + ma.LinuxAMD64.Digest.String()). Exec() // validate - CompareRef(RegistryRef(Host, ImageRepo, ma.LinuxAMD64.Digest.String()), dst) + CompareRef(RegistryRef(ZOTHost, ImageRepo, ma.LinuxAMD64.Digest.String()), dst) var index ocispec.Index bytes := ORAS("discover", dst, "-o", "json", "--platform", "linux/amd64"). MatchKeyWords(ma.LinuxAMD64Referrer.Digest.String()). @@ -190,11 +182,11 @@ var _ = Describe("1.1 registry users:", func() { Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred()) Expect(len(index.Manifests)).To(Equal(1)) Expect(index.Manifests[0].Digest.String()).To(Equal(ma.LinuxAMD64Referrer.Digest.String())) - ORAS("manifest", "fetch", RegistryRef(Host, dstRepo, ma.Digest)). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, dstRepo, ma.Digest)). WithDescription("not copy index"). ExpectFailure(). Exec() - ORAS("manifest", "fetch", RegistryRef(Host, dstRepo, ma.IndexReferrerDigest)). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, dstRepo, ma.IndexReferrerDigest)). WithDescription("not copy index referrer"). ExpectFailure(). Exec() @@ -202,15 +194,15 @@ var _ = Describe("1.1 registry users:", func() { It("should copy a certain platform of image and its referrers to a new repository without tagging", func() { stateKeys := append(ma.LinuxAMD64StateKeys, ma.LinuxAMD64ReferrerStateKey, ma.LinuxAMD64ReferrerConfigStateKey) - src := RegistryRef(Host, ArtifactRepo, ma.Tag) + src := RegistryRef(ZOTHost, ArtifactRepo, ma.Tag) dstRepo := cpTestRepo("platform-referrers-no-tag") - ORAS("cp", src, RegistryRef(Host, dstRepo, ""), "-r", "--platform", "linux/amd64", "-v"). + ORAS("cp", src, RegistryRef(ZOTHost, dstRepo, ""), "-r", "--platform", "linux/amd64", "-v"). MatchStatus(stateKeys, true, len(stateKeys)). MatchKeyWords("Digest: " + ma.LinuxAMD64.Digest.String()). Exec() // validate - dstRef := RegistryRef(Host, dstRepo, ma.LinuxAMD64.Digest.String()) - CompareRef(RegistryRef(Host, ImageRepo, ma.LinuxAMD64.Digest.String()), dstRef) + dstRef := RegistryRef(ZOTHost, dstRepo, ma.LinuxAMD64.Digest.String()) + CompareRef(RegistryRef(ZOTHost, ImageRepo, ma.LinuxAMD64.Digest.String()), dstRef) var index ocispec.Index bytes := ORAS("discover", dstRef, "-o", "json", "--platform", "linux/amd64"). MatchKeyWords(ma.LinuxAMD64Referrer.Digest.String()). @@ -219,24 +211,24 @@ var _ = Describe("1.1 registry users:", func() { Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred()) Expect(len(index.Manifests)).To(Equal(1)) Expect(index.Manifests[0].Digest.String()).To(Equal(ma.LinuxAMD64Referrer.Digest.String())) - ORAS("manifest", "fetch", RegistryRef(Host, dstRepo, ma.Digest)). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, dstRepo, ma.Digest)). WithDescription("not copy index"). ExpectFailure(). Exec() - ORAS("manifest", "fetch", RegistryRef(Host, dstRepo, ma.IndexReferrerDigest)). + ORAS("manifest", "fetch", RegistryRef(ZOTHost, dstRepo, ma.IndexReferrerDigest)). WithDescription("not copy index referrer"). ExpectFailure(). Exec() }) It("should copy an image to a new repository with multiple tagging", func() { - src := RegistryRef(Host, ImageRepo, foobar.Digest) + src := RegistryRef(ZOTHost, ImageRepo, foobar.Digest) tags := []string{"tag1", "tag2", "tag3"} dstRepo := cpTestRepo("multi-tagging") - dst := RegistryRef(Host, dstRepo, "") + dst := RegistryRef(ZOTHost, dstRepo, "") ORAS("cp", src, dst+":"+strings.Join(tags, ","), "-v").MatchStatus(foobarStates, true, len(foobarStates)).Exec() for _, tag := range tags { - dst := RegistryRef(Host, dstRepo, tag) + dst := RegistryRef(ZOTHost, dstRepo, tag) CompareRef(src, dst) } }) @@ -248,7 +240,7 @@ var _ = Describe("OCI spec 1.0 registry users:", func() { It("should copy an image artifact and its referrers from a registry to a fallback registry", func() { repo := cpTestRepo("to-fallback") stateKeys := append(append(foobarStates, foobar.ImageReferrersStateKeys...), foobar.ImageReferrerConfigStateKeys...) - src := RegistryRef(Host, ArtifactRepo, foobar.SignatureImageReferrer.Digest.String()) + src := RegistryRef(ZOTHost, ArtifactRepo, foobar.SignatureImageReferrer.Digest.String()) dst := RegistryRef(FallbackHost, repo, "") ORAS("cp", "-r", src, dst, "-v").MatchStatus(stateKeys, true, len(stateKeys)).Exec() CompareRef(src, RegistryRef(FallbackHost, repo, foobar.SignatureImageReferrer.Digest.String())) @@ -259,10 +251,10 @@ var _ = Describe("OCI spec 1.0 registry users:", func() { repo := cpTestRepo("from-fallback") stateKeys := append(append(foobarStates, foobar.FallbackImageReferrersStateKeys...), foobar.ImageReferrerConfigStateKeys...) src := RegistryRef(FallbackHost, ArtifactRepo, foobar.FallbackSBOMImageReferrer.Digest.String()) - dst := RegistryRef(Host, repo, "") + dst := RegistryRef(ZOTHost, repo, "") ORAS("cp", "-r", src, dst, "-v").MatchStatus(stateKeys, true, len(stateKeys)).Exec() - CompareRef(src, RegistryRef(Host, repo, foobar.FallbackSBOMImageReferrer.Digest.String())) - ORAS("discover", "-o", "tree", RegistryRef(Host, repo, foobar.Digest)). + CompareRef(src, RegistryRef(ZOTHost, repo, foobar.FallbackSBOMImageReferrer.Digest.String())) + ORAS("discover", "-o", "tree", RegistryRef(ZOTHost, repo, foobar.Digest)). WithDescription("discover referrer via subject").MatchKeyWords(foobar.FallbackSignatureImageReferrer.Digest.String(), foobar.FallbackSBOMImageReferrer.Digest.String()).Exec() }) @@ -297,8 +289,8 @@ var _ = Describe("OCI spec 1.0 registry users:", func() { dstRepo := cpTestRepo("platform-referrer-from-layout") dst := RegistryRef(FallbackHost, dstRepo, "copied") // prepare - ORAS("cp", RegistryRef(Host, ArtifactRepo, ma.Tag), src, Flags.ToLayout, "-r").Exec() - ORAS("cp", RegistryRef(Host, ArtifactRepo, ma.Tag), src, Flags.ToLayout, "-r", "--platform", "linux/amd64").Exec() + ORAS("cp", RegistryRef(ZOTHost, ArtifactRepo, ma.Tag), src, Flags.ToLayout, "-r").Exec() + ORAS("cp", RegistryRef(ZOTHost, ArtifactRepo, ma.Tag), src, Flags.ToLayout, "-r", "--platform", "linux/amd64").Exec() // test ORAS("cp", src, Flags.FromLayout, dst, "-r", "-v", "--platform", "linux/amd64"). MatchStatus(stateKeys, true, len(stateKeys)). @@ -325,7 +317,7 @@ var _ = Describe("OCI layout users:", func() { When("running `cp`", func() { It("should copy an image from a registry to an OCI image layout via tag", func() { dst := LayoutRef(GinkgoT().TempDir(), "copied") - src := RegistryRef(Host, ImageRepo, foobar.Tag) + src := RegistryRef(ZOTHost, ImageRepo, foobar.Tag) ORAS("cp", src, dst, "-v", Flags.ToLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate srcManifest := ORAS("manifest", "fetch", src).WithDescription("fetch from source to validate").Exec().Out.Contents() @@ -336,9 +328,9 @@ var _ = Describe("OCI layout users:", func() { It("should copy an image from an OCI image layout to a registry via tag", func() { layoutDir := GinkgoT().TempDir() src := LayoutRef(layoutDir, "copied") - dst := RegistryRef(Host, cpTestRepo("from-layout-tag"), foobar.Tag) + dst := RegistryRef(ZOTHost, cpTestRepo("from-layout-tag"), foobar.Tag) // prepare - ORAS("cp", RegistryRef(Host, ImageRepo, foobar.Tag), src, Flags.ToLayout).Exec() + ORAS("cp", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), src, Flags.ToLayout).Exec() // test ORAS("cp", src, dst, "-v", Flags.FromLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate @@ -353,7 +345,7 @@ var _ = Describe("OCI layout users:", func() { src := LayoutRef(srcDir, "from") dst := LayoutRef(toDir, "to") // prepare - ORAS("cp", RegistryRef(Host, ImageRepo, foobar.Tag), src, Flags.ToLayout).Exec() + ORAS("cp", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), src, Flags.ToLayout).Exec() // test ORAS("cp", src, dst, "-v", Flags.FromLayout, Flags.ToLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate @@ -364,7 +356,7 @@ var _ = Describe("OCI layout users:", func() { It("should copy an image from a registry to an OCI image layout via digest", func() { dstDir := GinkgoT().TempDir() - src := RegistryRef(Host, ImageRepo, foobar.Tag) + src := RegistryRef(ZOTHost, ImageRepo, foobar.Tag) ORAS("cp", src, dstDir, "-v", Flags.ToLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate srcManifest := ORAS("manifest", "fetch", src).WithDescription("fetch from source to validate").Exec().Out.Contents() @@ -375,9 +367,9 @@ var _ = Describe("OCI layout users:", func() { It("should copy an image from an OCI image layout to a registry via digest", func() { layoutDir := GinkgoT().TempDir() src := LayoutRef(layoutDir, foobar.Digest) - dst := RegistryRef(Host, cpTestRepo("from-layout-digest"), "copied") + dst := RegistryRef(ZOTHost, cpTestRepo("from-layout-digest"), "copied") // prepare - ORAS("cp", RegistryRef(Host, ImageRepo, foobar.Tag), layoutDir, Flags.ToLayout).Exec() + ORAS("cp", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), layoutDir, Flags.ToLayout).Exec() // test ORAS("cp", src, dst, "-v", Flags.FromLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate @@ -392,7 +384,7 @@ var _ = Describe("OCI layout users:", func() { src := LayoutRef(srcDir, foobar.Digest) dst := LayoutRef(toDir, foobar.Digest) // prepare - ORAS("cp", RegistryRef(Host, ImageRepo, foobar.Tag), srcDir, Flags.ToLayout).Exec() + ORAS("cp", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), srcDir, Flags.ToLayout).Exec() // test ORAS("cp", src, toDir, "-v", Flags.FromLayout, Flags.ToLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() // validate @@ -403,7 +395,7 @@ var _ = Describe("OCI layout users:", func() { It("should copy an image from a registry to an OCI image layout with multiple tagging", func() { dstDir := GinkgoT().TempDir() - src := RegistryRef(Host, ImageRepo, foobar.Tag) + src := RegistryRef(ZOTHost, ImageRepo, foobar.Tag) tags := []string{"tag1", "tag2", "tag3"} // test ORAS("cp", src, dstDir+":"+strings.Join(tags, ","), "-v", Flags.ToLayout).MatchStatus(foobarStates, true, len(foobarStates)).Exec() @@ -418,7 +410,7 @@ var _ = Describe("OCI layout users:", func() { It("should copy a tagged image and its referrers from a registry to an OCI image layout", func() { stateKeys := append(append(foobarStates, foobar.ArtifactReferrerStateKeys...), foobar.ImageReferrerConfigStateKeys...) dst := LayoutRef(GinkgoT().TempDir(), "copied") - src := RegistryRef(Host, ArtifactRepo, foobar.Tag) + src := RegistryRef(ZOTHost, ArtifactRepo, foobar.Tag) // test ORAS("cp", "-r", src, dst, "-v", Flags.ToLayout).MatchStatus(stateKeys, true, len(stateKeys)).Exec() // validate @@ -430,7 +422,7 @@ var _ = Describe("OCI layout users:", func() { It("should copy a image and its referrers from a registry to an OCI image layout via digest", func() { stateKeys := append(append(foobarStates, foobar.ArtifactReferrerStateKeys...), foobar.ImageReferrerConfigStateKeys...) toDir := GinkgoT().TempDir() - src := RegistryRef(Host, ArtifactRepo, foobar.Digest) + src := RegistryRef(ZOTHost, ArtifactRepo, foobar.Digest) // test ORAS("cp", "-r", src, toDir, "-v", Flags.ToLayout).MatchStatus(stateKeys, true, len(stateKeys)).Exec() // validate @@ -440,8 +432,8 @@ var _ = Describe("OCI layout users:", func() { }) It("should copy a multi-arch image and its referrers from a registry to an OCI image layout a via tag", func() { - stateKeys := append(ma.IndexStateKeys, ma.IndexReferrerStateKey, ma.IndexReferrerConfigStateKey) - src := RegistryRef(Host, ArtifactRepo, ma.Tag) + stateKeys := append(ma.IndexStateKeys, ma.IndexZOTReferrerStateKey, ma.IndexReferrerConfigStateKey) + src := RegistryRef(ZOTHost, ArtifactRepo, ma.Tag) toDir := GinkgoT().TempDir() dst := LayoutRef(toDir, "copied") // test @@ -468,12 +460,12 @@ var _ = Describe("OCI layout users:", func() { }) It("should copy a multi-arch image and its referrers from an OCI image layout to a registry via digest", func() { - stateKeys := append(ma.IndexStateKeys, ma.IndexReferrerStateKey, ma.IndexReferrerConfigStateKey) + stateKeys := append(ma.IndexStateKeys, ma.IndexZOTReferrerStateKey, ma.IndexReferrerConfigStateKey) fromDir := GinkgoT().TempDir() src := LayoutRef(fromDir, ma.Tag) - dst := RegistryRef(Host, cpTestRepo("recursive-from-layout"), "copied") + dst := RegistryRef(ZOTHost, cpTestRepo("recursive-from-layout"), "copied") // prepare - ORAS("cp", RegistryRef(Host, ArtifactRepo, ma.Tag), src, Flags.ToLayout, "-r").Exec() + ORAS("cp", RegistryRef(ZOTHost, ArtifactRepo, ma.Tag), src, Flags.ToLayout, "-r").Exec() // test ORAS("cp", src, Flags.FromLayout, dst, "-r", "-v"). MatchStatus(stateKeys, true, len(stateKeys)). @@ -502,10 +494,10 @@ var _ = Describe("OCI layout users:", func() { fromDir := GinkgoT().TempDir() src := LayoutRef(fromDir, ma.Tag) dstRepo := cpTestRepo("platform-referrer-from-layout") - dst := RegistryRef(Host, dstRepo, "copied") + dst := RegistryRef(ZOTHost, dstRepo, "copied") // prepare - ORAS("cp", RegistryRef(Host, ArtifactRepo, ma.Tag), src, Flags.ToLayout, "-r").Exec() - ORAS("cp", RegistryRef(Host, ArtifactRepo, ma.Tag), src, Flags.ToLayout, "-r", "--platform", "linux/amd64").Exec() + ORAS("cp", RegistryRef(ZOTHost, ArtifactRepo, ma.Tag), src, Flags.ToLayout, "-r").Exec() + ORAS("cp", RegistryRef(ZOTHost, ArtifactRepo, ma.Tag), src, Flags.ToLayout, "-r", "--platform", "linux/amd64").Exec() // test ORAS("cp", src, Flags.FromLayout, dst, "-r", "-v", "--platform", "linux/amd64"). MatchStatus(stateKeys, true, len(stateKeys)). @@ -515,7 +507,7 @@ var _ = Describe("OCI layout users:", func() { srcManifest := ORAS("manifest", "fetch", src, Flags.Layout, "--platform", "linux/amd64").WithDescription("fetch from source to validate").Exec().Out.Contents() dstManifest := ORAS("manifest", "fetch", dst).WithDescription("fetch from destination to validate").Exec().Out.Contents() Expect(srcManifest).To(Equal(dstManifest)) - ORAS("manifest", "fetch", RegistryRef(Host, dstRepo, ma.Digest)).WithDescription("not copy index").ExpectFailure().Exec() + ORAS("manifest", "fetch", RegistryRef(ZOTHost, dstRepo, ma.Digest)).WithDescription("not copy index").ExpectFailure().Exec() var index ocispec.Index bytes := ORAS("discover", dst, "-o", "json"). MatchKeyWords(ma.LinuxAMD64Referrer.Digest.String()). @@ -528,7 +520,7 @@ var _ = Describe("OCI layout users:", func() { It("should copy a certain platform of image and its referrers from a registry to an OCI image layout", func() { stateKeys := append(ma.LinuxAMD64StateKeys, ma.LinuxAMD64ReferrerStateKey, ma.LinuxAMD64ReferrerConfigStateKey) - src := RegistryRef(Host, ArtifactRepo, ma.Tag) + src := RegistryRef(ZOTHost, ArtifactRepo, ma.Tag) toDir := GinkgoT().TempDir() dst := LayoutRef(toDir, "copied") // test diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/1fd9a5fc54b634130102861815e2881f1eec22958d604301904c5353041794c1 b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/1fd9a5fc54b634130102861815e2881f1eec22958d604301904c5353041794c1 new file mode 100644 index 000000000..42968ffca --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/1fd9a5fc54b634130102861815e2881f1eec22958d604301904c5353041794c1 @@ -0,0 +1,4 @@ +{ + "architecture": "arm64", + "os": "linux" +} \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/2ef548696ac7dd66ef38aab5cc8fc5cc1fb637dfaedb3a9afc89bf16db9277e1 b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/2ef548696ac7dd66ef38aab5cc8fc5cc1fb637dfaedb3a9afc89bf16db9277e1 new file mode 100644 index 0000000000000000000000000000000000000000..428f90aab2bd378850dcefe70f7d46eb6e3ddb44 GIT binary patch literal 10240 zcmeIvK?=e!5QX76O1wasX`*uluTfB_5?ZJc#nYRvD&4s1qVUgVl1vDXFa0&=u_^B& z+m+UGcd5<%sK0$4)zc)FVykwFQBBm^q%J|Xi?qD_e3WhqLGHKV(|5KER;z#W)%Cq> z&-4F>*Er?NVK14 Date: Wed, 30 Aug 2023 12:13:24 +0000 Subject: [PATCH 33/45] rebake test data for distribution Signed-off-by: Billy Zha --- test/e2e/internal/testdata/foobar/const.go | 18 +++++++++--------- .../distribution/mount/artifacts.tar.gz | Bin 2294 -> 3149 bytes .../mount/artifacts_fallback.tar.gz | Bin 1449 -> 0 bytes .../mount_fallback/artifacts.tar.gz | Bin 4378 -> 3134 bytes 4 files changed, 9 insertions(+), 9 deletions(-) delete mode 100644 test/e2e/testdata/distribution/mount/artifacts_fallback.tar.gz diff --git a/test/e2e/internal/testdata/foobar/const.go b/test/e2e/internal/testdata/foobar/const.go index 0ea5471f0..62fe8124b 100644 --- a/test/e2e/internal/testdata/foobar/const.go +++ b/test/e2e/internal/testdata/foobar/const.go @@ -91,16 +91,16 @@ func ImageConfigStateKey(configName string) match.StateKey { var ( SBOMImageReferrer = ocispec.Descriptor{ MediaType: "application/vnd.oci.image.manifest.v1+json", - Digest: digest.Digest("sha256:32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47"), + Digest: digest.Digest("sha256:7cdd0383e3db8adcca166e59b431981b4407f9d30b17014ad42873107af6fbc4"), Size: 660, Annotations: map[string]string{ "org.opencontainers.image.created": "2023-01-18T08:37:42Z", }, - ArtifactType: "test.sbom.file", + ArtifactType: "test/sbom/file", } SignatureImageReferrer = ocispec.Descriptor{ MediaType: "application/vnd.oci.image.manifest.v1+json", - Digest: digest.Digest("sha256:0e007dcb9ded7f49c4dc8e3eed4a446712eb6fdf08a665a4f2352d6d2f8bdf17"), + Digest: digest.Digest("sha256:b6d28d84b6ad3f8d9d437db28248ab26270597fe55cde0aa29813341cd5430af"), Size: 670, } SBOMArtifactReferrer = ocispec.Descriptor{ @@ -122,12 +122,12 @@ var ( {Digest: "2dbea575a349", Name: "application/vnd.oci.artifact.manifest.v1+json"}, } ImageReferrersStateKeys = []match.StateKey{ - {Digest: "0e007dcb9ded", Name: "application/vnd.oci.image.manifest.v1+json"}, - {Digest: "32b78bd00723", Name: "application/vnd.oci.image.manifest.v1+json"}, + {Digest: "b6d28d84b6ad", Name: "application/vnd.oci.image.manifest.v1+json"}, + {Digest: "7cdd0383e3db", Name: "application/vnd.oci.image.manifest.v1+json"}, } ImageReferrerConfigStateKeys = []match.StateKey{ - {Digest: "44136fa355b3", Name: "test.signature.file"}, - {Digest: "44136fa355b3", Name: "test.sbom.file"}, + {Digest: "44136fa355b3", Name: "test/signature.file"}, + {Digest: "44136fa355b3", Name: "test/sbom/file"}, } FallbackImageReferrersStateKeys = []match.StateKey{ {Digest: "316405db72cc", Name: "application/vnd.oci.image.manifest.v1+json"}, @@ -139,13 +139,13 @@ var ( var ( FallbackSignatureImageReferrer = ocispec.Descriptor{ MediaType: "application/vnd.oci.image.manifest.v1+json", - Digest: digest.Digest("sha256:8b3f7e000c4a6d32cd6bfcabfe874ed470d470501a09adc65afaf1c342f988ff"), + Digest: digest.Digest("sha256:b6d28d84b6ad3f8d9d437db28248ab26270597fe55cde0aa29813341cd5430af"), Size: 670, } FallbackSBOMImageReferrer = ocispec.Descriptor{ MediaType: "application/vnd.oci.image.manifest.v1+json", - Digest: digest.Digest("sha256:316405db72cc8f0212c19db23b498f9af8a456c9cd288f9e33acd1ba9e7cd534"), + Digest: digest.Digest("sha256:7cdd0383e3db8adcca166e59b431981b4407f9d30b17014ad42873107af6fbc4"), Size: 660, Annotations: map[string]string{ "org.opencontainers.image.created": "2023-01-29T02:32:18Z", diff --git a/test/e2e/testdata/distribution/mount/artifacts.tar.gz b/test/e2e/testdata/distribution/mount/artifacts.tar.gz index aee352e7e6557be856c08c343674f4875b3d1cc2..d46482e544424d1042e93c2660556d2f30debe45 100644 GIT binary patch literal 3149 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 D1iBV< diff --git a/test/e2e/testdata/distribution/mount_fallback/artifacts.tar.gz b/test/e2e/testdata/distribution/mount_fallback/artifacts.tar.gz index e0ca94ab56c12a5c57b333dfa28b8bded5e4fb4c..4ba468fe1b5314994be18df2157847e9f7d8ae36 100644 GIT binary patch literal 3134 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 literal 4378 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 From 67d055676c89d5af268209bf430447437c20c46d Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Wed, 30 Aug 2023 12:25:14 +0000 Subject: [PATCH 34/45] add foobar referrers to ZOT Signed-off-by: Billy Zha --- ...3e3db8adcca166e59b431981b4407f9d30b17014ad42873107af6fbc4} | 2 +- ...4b6ad3f8d9d437db28248ab26270597fe55cde0aa29813341cd5430af} | 2 +- test/e2e/testdata/zot/command/artifacts/index.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename test/e2e/testdata/zot/command/artifacts/blobs/sha256/{32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47 => 7cdd0383e3db8adcca166e59b431981b4407f9d30b17014ad42873107af6fbc4} (90%) rename test/e2e/testdata/zot/command/artifacts/blobs/sha256/{0e007dcb9ded7f49c4dc8e3eed4a446712eb6fdf08a665a4f2352d6d2f8bdf17 => b6d28d84b6ad3f8d9d437db28248ab26270597fe55cde0aa29813341cd5430af} (71%) diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47 b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/7cdd0383e3db8adcca166e59b431981b4407f9d30b17014ad42873107af6fbc4 similarity index 90% rename from test/e2e/testdata/zot/command/artifacts/blobs/sha256/32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47 rename to test/e2e/testdata/zot/command/artifacts/blobs/sha256/7cdd0383e3db8adcca166e59b431981b4407f9d30b17014ad42873107af6fbc4 index 73ffd55d3..f12f1e452 100644 --- a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47 +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/7cdd0383e3db8adcca166e59b431981b4407f9d30b17014ad42873107af6fbc4 @@ -1 +1 @@ -{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"test.sbom.file","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:f5d51c0823fc419652bb6beb40e8175760dbb8615d2f815a6ca5239c901c6b38","size":11,"annotations":{"org.opencontainers.image.title":"sbom"}}],"subject":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb","size":851},"annotations":{"org.opencontainers.image.created":"2023-01-18T08:37:42Z"}} \ No newline at end of file +{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"test/sbom/file","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:f5d51c0823fc419652bb6beb40e8175760dbb8615d2f815a6ca5239c901c6b38","size":11,"annotations":{"org.opencontainers.image.title":"sbom"}}],"subject":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb","size":851},"annotations":{"org.opencontainers.image.created":"2023-01-18T08:37:42Z"}} \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/0e007dcb9ded7f49c4dc8e3eed4a446712eb6fdf08a665a4f2352d6d2f8bdf17 b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/b6d28d84b6ad3f8d9d437db28248ab26270597fe55cde0aa29813341cd5430af similarity index 71% rename from test/e2e/testdata/zot/command/artifacts/blobs/sha256/0e007dcb9ded7f49c4dc8e3eed4a446712eb6fdf08a665a4f2352d6d2f8bdf17 rename to test/e2e/testdata/zot/command/artifacts/blobs/sha256/b6d28d84b6ad3f8d9d437db28248ab26270597fe55cde0aa29813341cd5430af index a51f76dac..318021658 100644 --- a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/0e007dcb9ded7f49c4dc8e3eed4a446712eb6fdf08a665a4f2352d6d2f8bdf17 +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/b6d28d84b6ad3f8d9d437db28248ab26270597fe55cde0aa29813341cd5430af @@ -1 +1 @@ -{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"test.signature.file","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:ae2d56717c9334fdc5fdb1888b9351d80f6f5458dca9d3abef6560e7be255a3d","size":16,"annotations":{"org.opencontainers.image.title":"signature"}}],"subject":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47","size":660},"annotations":{"org.opencontainers.image.created":"2023-01-18T08:37:57Z"}} \ No newline at end of file +{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"test/signature.file","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:ae2d56717c9334fdc5fdb1888b9351d80f6f5458dca9d3abef6560e7be255a3d","size":16,"annotations":{"org.opencontainers.image.title":"signature"}}],"subject":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:7cdd0383e3db8adcca166e59b431981b4407f9d30b17014ad42873107af6fbc4","size":660},"annotations":{"org.opencontainers.image.created":"2023-01-18T08:37:57Z"}} \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/index.json b/test/e2e/testdata/zot/command/artifacts/index.json index e1a345312..e8e12599e 100644 --- a/test/e2e/testdata/zot/command/artifacts/index.json +++ b/test/e2e/testdata/zot/command/artifacts/index.json @@ -11,12 +11,12 @@ }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", - "digest": "sha256:32b78bd00723cd7d5251d4586f84d252530b7b5fe1c4104532767e6da4e04e47", + "digest": "sha256:7cdd0383e3db8adcca166e59b431981b4407f9d30b17014ad42873107af6fbc4", "size": 660 }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", - "digest": "sha256:0e007dcb9ded7f49c4dc8e3eed4a446712eb6fdf08a665a4f2352d6d2f8bdf17", + "digest": "sha256:b6d28d84b6ad3f8d9d437db28248ab26270597fe55cde0aa29813341cd5430af", "size": 670 } ] From b6e10c53e91a0ca23a3e82085fcf083241fdaacc Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Wed, 30 Aug 2023 12:35:38 +0000 Subject: [PATCH 35/45] update testdata constants Signed-off-by: Billy Zha --- test/e2e/internal/testdata/foobar/const.go | 8 ++++---- test/e2e/suite/command/discover.go | 6 ++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/test/e2e/internal/testdata/foobar/const.go b/test/e2e/internal/testdata/foobar/const.go index 62fe8124b..eb4517c59 100644 --- a/test/e2e/internal/testdata/foobar/const.go +++ b/test/e2e/internal/testdata/foobar/const.go @@ -130,8 +130,8 @@ var ( {Digest: "44136fa355b3", Name: "test/sbom/file"}, } FallbackImageReferrersStateKeys = []match.StateKey{ - {Digest: "316405db72cc", Name: "application/vnd.oci.image.manifest.v1+json"}, - {Digest: "8b3f7e000c4a", Name: "application/vnd.oci.image.manifest.v1+json"}, + {Digest: "b6d28d84b6ad", Name: "application/vnd.oci.image.manifest.v1+json"}, + {Digest: "7cdd0383e3db", Name: "application/vnd.oci.image.manifest.v1+json"}, } ) @@ -148,8 +148,8 @@ var ( Digest: digest.Digest("sha256:7cdd0383e3db8adcca166e59b431981b4407f9d30b17014ad42873107af6fbc4"), Size: 660, Annotations: map[string]string{ - "org.opencontainers.image.created": "2023-01-29T02:32:18Z", + "org.opencontainers.image.created": "2023-01-18T08:37:42Z", }, - ArtifactType: "test.sbom.file", + ArtifactType: "test/sbom/file", } ) diff --git a/test/e2e/suite/command/discover.go b/test/e2e/suite/command/discover.go index 5690f535c..60cb7fef5 100644 --- a/test/e2e/suite/command/discover.go +++ b/test/e2e/suite/command/discover.go @@ -83,8 +83,7 @@ var _ = Describe("1.1 registry users:", func() { bytes := ORAS("discover", subjectRef, "-o", format, "--artifact-type", foobar.SBOMArtifactReferrer.ArtifactType).Exec().Out.Contents() var index ocispec.Index Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred()) - Expect(index.Manifests).To(HaveLen(2)) - Expect(index.Manifests).Should(ContainElement(foobar.SBOMImageReferrer)) + Expect(index.Manifests).To(HaveLen(1)) Expect(index.Manifests).Should(ContainElement(foobar.SBOMArtifactReferrer)) }) @@ -220,8 +219,7 @@ var _ = Describe("OCI image layout users:", func() { bytes := ORAS("discover", subjectRef, "-o", format, "--artifact-type", foobar.SBOMArtifactReferrer.ArtifactType, Flags.Layout).Exec().Out.Contents() var index ocispec.Index Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred()) - Expect(index.Manifests).To(HaveLen(2)) - Expect(index.Manifests).Should(ContainElement(foobar.SBOMImageReferrer)) + Expect(index.Manifests).To(HaveLen(1)) Expect(index.Manifests).Should(ContainElement(foobar.SBOMArtifactReferrer)) }) From ba8de9a9009b4ea0544874a12fb9ef7198016943 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Thu, 31 Aug 2023 00:44:16 +0000 Subject: [PATCH 36/45] update doc Signed-off-by: Billy Zha --- test/e2e/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/e2e/README.md b/test/e2e/README.md index 716361a61..8ab639028 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -112,8 +112,6 @@ graph TD; direction TB E1["test.sbom.file(artifact)"] -- subject --> C1 E2["test.signature.file(artifact)"] -- subject --> E1 - end - subgraph "file: artifacts_fallback.tar.gz" direction TB D1["test.sbom.file(image)"] -- subject --> C1 D2["test.signature.file(image)"] -- subject --> D1 From a75205c37708f8c1e6f7265ed2234da86412c63b Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Thu, 31 Aug 2023 02:39:40 +0000 Subject: [PATCH 37/45] fix e2e Signed-off-by: Billy Zha --- test/e2e/suite/command/cp.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/suite/command/cp.go b/test/e2e/suite/command/cp.go index 2cb3a813e..cf8994055 100644 --- a/test/e2e/suite/command/cp.go +++ b/test/e2e/suite/command/cp.go @@ -408,7 +408,7 @@ var _ = Describe("OCI layout users:", func() { }) It("should copy a tagged image and its referrers from a registry to an OCI image layout", func() { - stateKeys := append(append(foobarStates, foobar.ArtifactReferrerStateKeys...), foobar.ImageReferrerConfigStateKeys...) + stateKeys := append(append(foobarStates, foobar.ImageReferrersStateKeys...), foobar.ImageReferrerConfigStateKeys...) dst := LayoutRef(GinkgoT().TempDir(), "copied") src := RegistryRef(ZOTHost, ArtifactRepo, foobar.Tag) // test @@ -420,7 +420,7 @@ var _ = Describe("OCI layout users:", func() { }) It("should copy a image and its referrers from a registry to an OCI image layout via digest", func() { - stateKeys := append(append(foobarStates, foobar.ArtifactReferrerStateKeys...), foobar.ImageReferrerConfigStateKeys...) + stateKeys := append(append(foobarStates, foobar.ImageReferrersStateKeys...), foobar.ImageReferrerConfigStateKeys...) toDir := GinkgoT().TempDir() src := RegistryRef(ZOTHost, ArtifactRepo, foobar.Digest) // test From eded767fcf449ce75174cbe5aeece22e4c03f1e0 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Thu, 31 Aug 2023 03:16:36 +0000 Subject: [PATCH 38/45] add test data Signed-off-by: Billy Zha --- .gitignore | 6 ++-- ...1815e2881f1eec22958d604301904c5353041794c1 | 4 +++ ...b5cc8fc5cc1fb637dfaedb3a9afc89bf16db9277e1 | Bin 0 -> 10240 bytes ...772dc6ab72130d9ac1906aed2fc7589a5cd145433c | 1 + ...007a025c594ce12aa7e6da27d21c7b14b50112e255 | 1 + ...8ed157ba7d1edfe7f9b8766728b8a1f25c0d9c14c1 | 1 + ...10591f0203bb6e07f11e2fb0ce1b8508e9aac4ebe2 | 5 +++ ...102075d56b970fbf910be5c6bca07fdbb000dfa383 | 1 + ...a28c6bc5806b7fa581c9ad7883be955a64e3cc034f | 1 + ...8c309f0b5afb2cc513b7a3d456b6cc29fe641386c5 | 4 +++ .../testdata/zot/command/artifacts/index.json | 33 ++++++++++++++++++ 11 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/1fd9a5fc54b634130102861815e2881f1eec22958d604301904c5353041794c1 create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/2ef548696ac7dd66ef38aab5cc8fc5cc1fb637dfaedb3a9afc89bf16db9277e1 create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/4f93460061882467e6fb3b772dc6ab72130d9ac1906aed2fc7589a5cd145433c create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/58efe73e78fe043ca31b89007a025c594ce12aa7e6da27d21c7b14b50112e255 create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/9d84a5716c66a1d1b9c13f8ed157ba7d1edfe7f9b8766728b8a1f25c0d9c14c1 create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/a5dfce5d28768e985f91f610591f0203bb6e07f11e2fb0ce1b8508e9aac4ebe2 create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/d37baf66300b9006b0f4c7102075d56b970fbf910be5c6bca07fdbb000dfa383 create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/e2bfc9cc6a84ec2d7365b5a28c6bc5806b7fa581c9ad7883be955a64e3cc034f create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/fe9dbc99451d0517d65e048c309f0b5afb2cc513b7a3d456b6cc29fe641386c5 diff --git a/.gitignore b/.gitignore index f925d1241..aef145af6 100644 --- a/.gitignore +++ b/.gitignore @@ -53,8 +53,8 @@ test/e2e/testdata/distribution/mount_fallback/docker/ # OCI Layout Files ZOT storage files for local E2E testing test/e2e/testdata/zot/ -!test/e2e/testdata/zot/command/images/ -!test/e2e/testdata/zot/command/artifacts/ -!test/e2e/testdata/zot/command/blobs/ +!test/e2e/testdata/zot/command/images/**/* +!test/e2e/testdata/zot/command/artifacts/**/* +!test/e2e/testdata/zot/command/blobs/**/* !test/e2e/testdata/zot/config.json !test/e2e/testdata/zot/passwd_bcrypt \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/1fd9a5fc54b634130102861815e2881f1eec22958d604301904c5353041794c1 b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/1fd9a5fc54b634130102861815e2881f1eec22958d604301904c5353041794c1 new file mode 100644 index 000000000..42968ffca --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/1fd9a5fc54b634130102861815e2881f1eec22958d604301904c5353041794c1 @@ -0,0 +1,4 @@ +{ + "architecture": "arm64", + "os": "linux" +} \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/2ef548696ac7dd66ef38aab5cc8fc5cc1fb637dfaedb3a9afc89bf16db9277e1 b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/2ef548696ac7dd66ef38aab5cc8fc5cc1fb637dfaedb3a9afc89bf16db9277e1 new file mode 100644 index 0000000000000000000000000000000000000000..428f90aab2bd378850dcefe70f7d46eb6e3ddb44 GIT binary patch literal 10240 zcmeIvK?=e!5QX76O1wasX`*uluTfB_5?ZJc#nYRvD&4s1qVUgVl1vDXFa0&=u_^B& z+m+UGcd5<%sK0$4)zc)FVykwFQBBm^q%J|Xi?qD_e3WhqLGHKV(|5KER;z#W)%Cq> z&-4F>*Er?NVK14 Date: Thu, 31 Aug 2023 03:25:11 +0000 Subject: [PATCH 39/45] add linux amd64 referrers data Signed-off-by: Billy Zha --- ...5954a70e3fd28307dd543d4cc158946117943700b8f520f72ddca031f | 1 + test/e2e/testdata/zot/command/artifacts/index.json | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 test/e2e/testdata/zot/command/artifacts/blobs/sha256/c5e00045954a70e3fd28307dd543d4cc158946117943700b8f520f72ddca031f diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/c5e00045954a70e3fd28307dd543d4cc158946117943700b8f520f72ddca031f b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/c5e00045954a70e3fd28307dd543d4cc158946117943700b8f520f72ddca031f new file mode 100644 index 000000000..0400125c6 --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/c5e00045954a70e3fd28307dd543d4cc158946117943700b8f520f72ddca031f @@ -0,0 +1 @@ +{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"referrer/image","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2},"layers":[],"subject":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:9d84a5716c66a1d1b9c13f8ed157ba7d1edfe7f9b8766728b8a1f25c0d9c14c1","size":458},"annotations":{"org.opencontainers.image.created":"2023-02-15T07:56:34Z","subject":"linux/amd64"}} diff --git a/test/e2e/testdata/zot/command/artifacts/index.json b/test/e2e/testdata/zot/command/artifacts/index.json index 8e46dab1d..cbbfa0772 100644 --- a/test/e2e/testdata/zot/command/artifacts/index.json +++ b/test/e2e/testdata/zot/command/artifacts/index.json @@ -51,6 +51,11 @@ "annotations": { "org.opencontainers.image.ref.name": "multi" } + }, + { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "digest": "sha256:c5e00045954a70e3fd28307dd543d4cc158946117943700b8f520f72ddca031f", + "size": 482 } ] } \ No newline at end of file From 67d31de772628f891ec45eedd5cdcc450641b2a6 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Thu, 31 Aug 2023 03:31:14 +0000 Subject: [PATCH 40/45] test(e2e): migrate `oras discover` specs to ZOT Signed-off-by: Billy Zha --- .../e2e/internal/testdata/multi_arch/const.go | 4 +- test/e2e/suite/command/discover.go | 77 +++++++++---------- 2 files changed, 38 insertions(+), 43 deletions(-) diff --git a/test/e2e/internal/testdata/multi_arch/const.go b/test/e2e/internal/testdata/multi_arch/const.go index a90e8e2e3..57545668e 100644 --- a/test/e2e/internal/testdata/multi_arch/const.go +++ b/test/e2e/internal/testdata/multi_arch/const.go @@ -51,12 +51,12 @@ var ( LinuxAMD64ConfigDesc = `{"mediaType":"application/vnd.oci.image.config.v1+json","digest":"sha256:fe9dbc99451d0517d65e048c309f0b5afb2cc513b7a3d456b6cc29fe641386c5","size":53}` LinuxAMD64Referrer = ocispec.Descriptor{ MediaType: "application/vnd.oci.image.manifest.v1+json", - Digest: digest.Digest("sha256:57e6462826c85be15f22f824666f6b467d488fa7bc7e2975f43a2fae27a24ef0"), + Digest: digest.Digest("sha256:c5e00045954a70e3fd28307dd543d4cc158946117943700b8f520f72ddca031f"), Annotations: map[string]string{ "org.opencontainers.image.created": "2023-02-15T07:56:34Z", "subject": "linux/amd64", }, - ArtifactType: "referrer.image", + ArtifactType: "referrer/image", Size: 481, } LayerName = "hello.tar" diff --git a/test/e2e/suite/command/discover.go b/test/e2e/suite/command/discover.go index 60cb7fef5..475cf2001 100644 --- a/test/e2e/suite/command/discover.go +++ b/test/e2e/suite/command/discover.go @@ -61,30 +61,29 @@ var _ = Describe("ORAS beginners:", func() { }) It("should fail when no tag or digest found in provided subject reference", func() { - ORAS("discover", RegistryRef(Host, ImageRepo, "")).ExpectFailure().MatchErrKeyWords("Error:", "invalid image reference").Exec() + ORAS("discover", RegistryRef(ZOTHost, ImageRepo, "")).ExpectFailure().MatchErrKeyWords("Error:", "invalid image reference").Exec() }) }) }) var _ = Describe("1.1 registry users:", func() { - subjectRef := RegistryRef(Host, ArtifactRepo, foobar.Tag) + subjectRef := RegistryRef(ZOTHost, ArtifactRepo, foobar.Tag) When("running discover command with json output", func() { format := "json" It("should discover direct referrers of a subject", func() { bytes := ORAS("discover", subjectRef, "-o", format).Exec().Out.Contents() var index ocispec.Index Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred()) - Expect(index.Manifests).To(HaveLen(2)) + Expect(index.Manifests).To(HaveLen(1)) Expect(index.Manifests).Should(ContainElement(foobar.SBOMImageReferrer)) - Expect(index.Manifests).Should(ContainElement(foobar.SBOMArtifactReferrer)) }) It("should discover matched referrer when filtering", func() { - bytes := ORAS("discover", subjectRef, "-o", format, "--artifact-type", foobar.SBOMArtifactReferrer.ArtifactType).Exec().Out.Contents() + bytes := ORAS("discover", subjectRef, "-o", format, "--artifact-type", foobar.SBOMImageReferrer.ArtifactType).Exec().Out.Contents() var index ocispec.Index Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred()) Expect(index.Manifests).To(HaveLen(1)) - Expect(index.Manifests).Should(ContainElement(foobar.SBOMArtifactReferrer)) + Expect(index.Manifests).Should(ContainElement(foobar.SBOMImageReferrer)) }) It("should discover matched no referrer", func() { @@ -95,7 +94,7 @@ var _ = Describe("1.1 registry users:", func() { }) It("should discover one referrer with matched platform", func() { - bytes := ORAS("discover", RegistryRef(Host, ArtifactRepo, multi_arch.Tag), "-o", format, "--platform", "linux/amd64").Exec().Out.Contents() + bytes := ORAS("discover", RegistryRef(ZOTHost, ArtifactRepo, multi_arch.Tag), "-o", format, "--platform", "linux/amd64").Exec().Out.Contents() var index ocispec.Index Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred()) Expect(index.Manifests).To(HaveLen(1)) @@ -105,22 +104,22 @@ var _ = Describe("1.1 registry users:", func() { When("running discover command with tree output", func() { format := "tree" - referrers := []ocispec.Descriptor{foobar.SBOMImageReferrer, foobar.SBOMArtifactReferrer, foobar.SignatureImageReferrer, foobar.SignatureArtifactReferrer} + referrers := []ocispec.Descriptor{foobar.SBOMImageReferrer, foobar.SBOMImageReferrer, foobar.SignatureImageReferrer, foobar.SignatureImageReferrer} It("should discover all referrers of a subject", func() { ORAS("discover", subjectRef, "-o", format). - MatchKeyWords(append(discoverKeyWords(false, referrers...), RegistryRef(Host, ArtifactRepo, foobar.Digest))...). + MatchKeyWords(append(discoverKeyWords(false, referrers...), RegistryRef(ZOTHost, ArtifactRepo, foobar.Digest))...). Exec() }) It("should discover all referrers of a subject via referrers API", func() { ORAS("discover", subjectRef, "-o", format, "--distribution-spec", "v1.1-referrers-api"). - MatchKeyWords(append(discoverKeyWords(false, referrers...), RegistryRef(Host, ArtifactRepo, foobar.Digest))...). + MatchKeyWords(append(discoverKeyWords(false, referrers...), RegistryRef(ZOTHost, ArtifactRepo, foobar.Digest))...). Exec() }) It("should discover all referrers of a subject with annotations", func() { ORAS("discover", subjectRef, "-o", format, "-v"). - MatchKeyWords(append(discoverKeyWords(true, referrers...), RegistryRef(Host, ArtifactRepo, foobar.Digest))...). + MatchKeyWords(append(discoverKeyWords(true, referrers...), RegistryRef(ZOTHost, ArtifactRepo, foobar.Digest))...). Exec() }) @@ -128,7 +127,7 @@ var _ = Describe("1.1 registry users:", func() { When("running discover command with table output", func() { format := "table" It("should all referrers of a subject", func() { - referrers := []ocispec.Descriptor{foobar.SBOMImageReferrer, foobar.SBOMArtifactReferrer} + referrers := []ocispec.Descriptor{foobar.SBOMImageReferrer, foobar.SBOMImageReferrer} ORAS("discover", subjectRef, "-o", format). MatchKeyWords(append(discoverKeyWords(false, referrers...), foobar.Digest)...). Exec() @@ -193,40 +192,37 @@ var _ = Describe("1.0 registry users:", func() { }) var _ = Describe("OCI image layout users:", func() { - prepare := func(subjectRef string) { - ORAS("cp", RegistryRef(Host, ArtifactRepo, foobar.Tag), subjectRef, Flags.ToLayout, "-r"). - WithDescription("prepare in OCI layout"). - Exec() - } When("running discover command with json output", func() { format := "json" It("should discover direct referrers of a subject", func() { // prepare - subjectRef := LayoutRef(GinkgoT().TempDir(), foobar.Tag) - prepare(subjectRef) + root := PrepareTempOCI(ArtifactRepo) + subjectRef := LayoutRef(root, foobar.Tag) + // test bytes := ORAS("discover", subjectRef, "-o", format, Flags.Layout).Exec().Out.Contents() var index ocispec.Index Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred()) - Expect(index.Manifests).To(HaveLen(2)) + Expect(index.Manifests).To(HaveLen(1)) Expect(index.Manifests).Should(ContainElement(foobar.SBOMImageReferrer)) - Expect(index.Manifests).Should(ContainElement(foobar.SBOMArtifactReferrer)) }) It("should discover matched referrer when filtering", func() { // prepare - subjectRef := LayoutRef(GinkgoT().TempDir(), foobar.Tag) - prepare(subjectRef) - bytes := ORAS("discover", subjectRef, "-o", format, "--artifact-type", foobar.SBOMArtifactReferrer.ArtifactType, Flags.Layout).Exec().Out.Contents() + root := PrepareTempOCI(ArtifactRepo) + subjectRef := LayoutRef(root, foobar.Tag) + // test + bytes := ORAS("discover", subjectRef, "-o", format, "--artifact-type", foobar.SBOMImageReferrer.ArtifactType, Flags.Layout).Exec().Out.Contents() var index ocispec.Index Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred()) Expect(index.Manifests).To(HaveLen(1)) - Expect(index.Manifests).Should(ContainElement(foobar.SBOMArtifactReferrer)) + Expect(index.Manifests).Should(ContainElement(foobar.SBOMImageReferrer)) }) It("should discover no matched referrer", func() { // prepare - subjectRef := LayoutRef(GinkgoT().TempDir(), foobar.Tag) - prepare(subjectRef) + root := PrepareTempOCI(ArtifactRepo) + subjectRef := LayoutRef(root, foobar.Tag) + // test bytes := ORAS("discover", subjectRef, "-o", format, "--artifact-type", "???", Flags.Layout).Exec().Out.Contents() var index ocispec.Index Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred()) @@ -236,24 +232,23 @@ var _ = Describe("OCI image layout users:", func() { When("running discover command with tree output", func() { format := "tree" - referrers := []ocispec.Descriptor{foobar.SBOMImageReferrer, foobar.SBOMArtifactReferrer, foobar.SignatureImageReferrer, foobar.SignatureArtifactReferrer} + referrers := []ocispec.Descriptor{foobar.SBOMImageReferrer, foobar.SignatureImageReferrer} It("should discover all referrers of a subject", func() { // prepare - rootDir := GinkgoT().TempDir() - subjectRef := LayoutRef(rootDir, foobar.Tag) - prepare(subjectRef) + root := PrepareTempOCI(ArtifactRepo) + subjectRef := LayoutRef(root, foobar.Tag) + // test ORAS("discover", subjectRef, "-o", format, Flags.Layout). - MatchKeyWords(append(discoverKeyWords(false, referrers...), LayoutRef(rootDir, foobar.Digest))...). + MatchKeyWords(append(discoverKeyWords(false, referrers...), LayoutRef(root, foobar.Digest))...). Exec() }) It("should discover all referrers of a subject with annotations", func() { // prepare - rootDir := GinkgoT().TempDir() - subjectRef := LayoutRef(rootDir, foobar.Tag) - prepare(subjectRef) + root := PrepareTempOCI(ArtifactRepo) + subjectRef := LayoutRef(root, foobar.Tag) ORAS("discover", subjectRef, "-o", format, "-v", Flags.Layout). - MatchKeyWords(append(discoverKeyWords(true, referrers...), LayoutRef(rootDir, foobar.Digest))...). + MatchKeyWords(append(discoverKeyWords(true, referrers...), LayoutRef(root, foobar.Digest))...). Exec() }) }) @@ -261,10 +256,10 @@ var _ = Describe("OCI image layout users:", func() { When("running discover command with table output", func() { format := "table" It("should get direct referrers of a subject", func() { - referrers := []ocispec.Descriptor{foobar.SBOMImageReferrer, foobar.SBOMArtifactReferrer} + referrers := []ocispec.Descriptor{foobar.SBOMImageReferrer} // prepare - subjectRef := LayoutRef(GinkgoT().TempDir(), foobar.Tag) - prepare(subjectRef) + root := PrepareTempOCI(ArtifactRepo) + subjectRef := LayoutRef(root, foobar.Tag) ORAS("discover", subjectRef, "-o", format, Flags.Layout). MatchKeyWords(append(discoverKeyWords(false, referrers...), foobar.Digest)...). Exec() @@ -272,8 +267,8 @@ var _ = Describe("OCI image layout users:", func() { It("should discover no matched referrer", func() { // prepare - subjectRef := LayoutRef(GinkgoT().TempDir(), foobar.Tag) - prepare(subjectRef) + root := PrepareTempOCI(ArtifactRepo) + subjectRef := LayoutRef(root, foobar.Tag) out := ORAS("discover", subjectRef, "-o", format, "--artifact-type", "???", Flags.Layout).Exec().Out Expect(out).NotTo(gbytes.Say(foobar.SBOMImageReferrer.Digest.String())) }) From 88e64fb0bef4e2f6311d35dc75cd1ba0ec9f4c90 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Thu, 31 Aug 2023 03:36:16 +0000 Subject: [PATCH 41/45] fix e2e Signed-off-by: Billy Zha --- test/e2e/internal/testdata/multi_arch/const.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/internal/testdata/multi_arch/const.go b/test/e2e/internal/testdata/multi_arch/const.go index 57545668e..28424021c 100644 --- a/test/e2e/internal/testdata/multi_arch/const.go +++ b/test/e2e/internal/testdata/multi_arch/const.go @@ -57,7 +57,7 @@ var ( "subject": "linux/amd64", }, ArtifactType: "referrer/image", - Size: 481, + Size: 482, } LayerName = "hello.tar" LinuxAMD64ReferrerStateKey = match.StateKey{Digest: "57e6462826c8", Name: "application/vnd.oci.image.manifest.v1+json"} From 0a981d8af0442571e698b6ac0de58ae654722d8d Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Thu, 31 Aug 2023 07:46:04 +0000 Subject: [PATCH 42/45] add cp spec back Signed-off-by: Billy Zha --- test/e2e/suite/command/cp.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/e2e/suite/command/cp.go b/test/e2e/suite/command/cp.go index cf8994055..c1aa26618 100644 --- a/test/e2e/suite/command/cp.go +++ b/test/e2e/suite/command/cp.go @@ -91,6 +91,14 @@ var _ = Describe("1.1 registry users:", func() { CompareRef(src, dst) }) + It("should copy an image and its referrers to a new repository", func() { + stateKeys := append(append(foobarStates, foobar.ImageReferrersStateKeys...), foobar.ImageReferrerConfigStateKeys...) + src := RegistryRef(ZOTHost, ArtifactRepo, foobar.Tag) + dst := RegistryRef(ZOTHost, cpTestRepo("referrers"), foobar.Digest) + ORAS("cp", "-r", src, dst, "-v").MatchStatus(stateKeys, true, len(stateKeys)).Exec() + CompareRef(src, dst) + }) + It("should copy a multi-arch image and its referrers to a new repository via tag", func() { stateKeys := append(ma.IndexStateKeys, ma.IndexZOTReferrerStateKey, ma.IndexReferrerConfigStateKey) src := RegistryRef(ZOTHost, ArtifactRepo, ma.Tag) From a49f6e95c6c1b8e9217449eee63050280ebea21d Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Thu, 31 Aug 2023 07:56:16 +0000 Subject: [PATCH 43/45] add old artifact consumption test Signed-off-by: Billy Zha --- test/e2e/suite/command/cp.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/e2e/suite/command/cp.go b/test/e2e/suite/command/cp.go index c1aa26618..39d9567b3 100644 --- a/test/e2e/suite/command/cp.go +++ b/test/e2e/suite/command/cp.go @@ -552,3 +552,14 @@ var _ = Describe("OCI layout users:", func() { }) }) }) + +var _ = Describe("OCI image spec v1.1.0-rc2 artifact users:", func() { + It("should copy an image and its referrers to a new repository", func() { + stateKeys := append(foobarStates, foobar.ArtifactReferrerStateKeys...) + digest := foobar.SBOMArtifactReferrer.Digest.String() + src := RegistryRef(Host, ArtifactRepo, digest) + dst := RegistryRef(Host, cpTestRepo("referrers"), digest) + ORAS("cp", "-r", src, dst, "-v").MatchStatus(stateKeys, true, len(stateKeys)).Exec() + CompareRef(src, dst) + }) +}) From 4b84e5448f0eb8d4528cf63507cd409f4c12e5ed Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Thu, 31 Aug 2023 16:52:29 +0000 Subject: [PATCH 44/45] rebake test data Signed-off-by: Billy Zha --- test/e2e/internal/testdata/foobar/const.go | 10 +++++----- .../distribution/mount/artifacts.tar.gz | Bin 3149 -> 3289 bytes .../mount_fallback/artifacts.tar.gz | Bin 3134 -> 3145 bytes ...141091b9239218e3125a35e17e8bcd05fa3a5e714} | 2 +- ...592718c73c41e809fb9818de232a635904a74d48d} | 2 +- .../testdata/zot/command/artifacts/index.json | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) rename test/e2e/testdata/zot/command/artifacts/blobs/sha256/{b6d28d84b6ad3f8d9d437db28248ab26270597fe55cde0aa29813341cd5430af => 0cb8c4da7e9ff2e7eefca33141091b9239218e3125a35e17e8bcd05fa3a5e714} (80%) rename test/e2e/testdata/zot/command/artifacts/blobs/sha256/{7cdd0383e3db8adcca166e59b431981b4407f9d30b17014ad42873107af6fbc4 => e2c6633a79985906f1ed55c592718c73c41e809fb9818de232a635904a74d48d} (90%) diff --git a/test/e2e/internal/testdata/foobar/const.go b/test/e2e/internal/testdata/foobar/const.go index eb4517c59..982ab3183 100644 --- a/test/e2e/internal/testdata/foobar/const.go +++ b/test/e2e/internal/testdata/foobar/const.go @@ -91,12 +91,12 @@ func ImageConfigStateKey(configName string) match.StateKey { var ( SBOMImageReferrer = ocispec.Descriptor{ MediaType: "application/vnd.oci.image.manifest.v1+json", - Digest: digest.Digest("sha256:7cdd0383e3db8adcca166e59b431981b4407f9d30b17014ad42873107af6fbc4"), + Digest: digest.Digest("sha256:e2c6633a79985906f1ed55c592718c73c41e809fb9818de232a635904a74d48d"), Size: 660, Annotations: map[string]string{ "org.opencontainers.image.created": "2023-01-18T08:37:42Z", }, - ArtifactType: "test/sbom/file", + ArtifactType: "test/sbom.file", } SignatureImageReferrer = ocispec.Descriptor{ MediaType: "application/vnd.oci.image.manifest.v1+json", @@ -123,7 +123,7 @@ var ( } ImageReferrersStateKeys = []match.StateKey{ {Digest: "b6d28d84b6ad", Name: "application/vnd.oci.image.manifest.v1+json"}, - {Digest: "7cdd0383e3db", Name: "application/vnd.oci.image.manifest.v1+json"}, + {Digest: "e2c6633a7998", Name: "application/vnd.oci.image.manifest.v1+json"}, } ImageReferrerConfigStateKeys = []match.StateKey{ {Digest: "44136fa355b3", Name: "test/signature.file"}, @@ -131,7 +131,7 @@ var ( } FallbackImageReferrersStateKeys = []match.StateKey{ {Digest: "b6d28d84b6ad", Name: "application/vnd.oci.image.manifest.v1+json"}, - {Digest: "7cdd0383e3db", Name: "application/vnd.oci.image.manifest.v1+json"}, + {Digest: "e2c6633a7998", Name: "application/vnd.oci.image.manifest.v1+json"}, } ) @@ -145,7 +145,7 @@ var ( FallbackSBOMImageReferrer = ocispec.Descriptor{ MediaType: "application/vnd.oci.image.manifest.v1+json", - Digest: digest.Digest("sha256:7cdd0383e3db8adcca166e59b431981b4407f9d30b17014ad42873107af6fbc4"), + Digest: digest.Digest("sha256:e2c6633a79985906f1ed55c592718c73c41e809fb9818de232a635904a74d48d"), Size: 660, Annotations: map[string]string{ "org.opencontainers.image.created": "2023-01-18T08:37:42Z", diff --git a/test/e2e/testdata/distribution/mount/artifacts.tar.gz b/test/e2e/testdata/distribution/mount/artifacts.tar.gz index d46482e544424d1042e93c2660556d2f30debe45..03e66cca76fc41d34a3afed9037f60645e6abf7c 100644 GIT binary patch literal 3289 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 literal 3149 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 literal 3134 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 diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/b6d28d84b6ad3f8d9d437db28248ab26270597fe55cde0aa29813341cd5430af b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/0cb8c4da7e9ff2e7eefca33141091b9239218e3125a35e17e8bcd05fa3a5e714 similarity index 80% rename from test/e2e/testdata/zot/command/artifacts/blobs/sha256/b6d28d84b6ad3f8d9d437db28248ab26270597fe55cde0aa29813341cd5430af rename to test/e2e/testdata/zot/command/artifacts/blobs/sha256/0cb8c4da7e9ff2e7eefca33141091b9239218e3125a35e17e8bcd05fa3a5e714 index 318021658..5c3dfc745 100644 --- a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/b6d28d84b6ad3f8d9d437db28248ab26270597fe55cde0aa29813341cd5430af +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/0cb8c4da7e9ff2e7eefca33141091b9239218e3125a35e17e8bcd05fa3a5e714 @@ -1 +1 @@ -{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"test/signature.file","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:ae2d56717c9334fdc5fdb1888b9351d80f6f5458dca9d3abef6560e7be255a3d","size":16,"annotations":{"org.opencontainers.image.title":"signature"}}],"subject":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:7cdd0383e3db8adcca166e59b431981b4407f9d30b17014ad42873107af6fbc4","size":660},"annotations":{"org.opencontainers.image.created":"2023-01-18T08:37:57Z"}} \ No newline at end of file +{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"test/signature.file","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:ae2d56717c9334fdc5fdb1888b9351d80f6f5458dca9d3abef6560e7be255a3d","size":16,"annotations":{"org.opencontainers.image.title":"signature"}}],"subject":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:e2c6633a79985906f1ed55c592718c73c41e809fb9818de232a635904a74d48d","size":660},"annotations":{"org.opencontainers.image.created":"2023-01-18T08:37:57Z"}} \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/7cdd0383e3db8adcca166e59b431981b4407f9d30b17014ad42873107af6fbc4 b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/e2c6633a79985906f1ed55c592718c73c41e809fb9818de232a635904a74d48d similarity index 90% rename from test/e2e/testdata/zot/command/artifacts/blobs/sha256/7cdd0383e3db8adcca166e59b431981b4407f9d30b17014ad42873107af6fbc4 rename to test/e2e/testdata/zot/command/artifacts/blobs/sha256/e2c6633a79985906f1ed55c592718c73c41e809fb9818de232a635904a74d48d index f12f1e452..c691b4fc6 100644 --- a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/7cdd0383e3db8adcca166e59b431981b4407f9d30b17014ad42873107af6fbc4 +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/e2c6633a79985906f1ed55c592718c73c41e809fb9818de232a635904a74d48d @@ -1 +1 @@ -{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"test/sbom/file","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:f5d51c0823fc419652bb6beb40e8175760dbb8615d2f815a6ca5239c901c6b38","size":11,"annotations":{"org.opencontainers.image.title":"sbom"}}],"subject":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb","size":851},"annotations":{"org.opencontainers.image.created":"2023-01-18T08:37:42Z"}} \ No newline at end of file +{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"test/sbom.file","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:f5d51c0823fc419652bb6beb40e8175760dbb8615d2f815a6ca5239c901c6b38","size":11,"annotations":{"org.opencontainers.image.title":"sbom"}}],"subject":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb","size":851},"annotations":{"org.opencontainers.image.created":"2023-01-18T08:37:42Z"}} \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/index.json b/test/e2e/testdata/zot/command/artifacts/index.json index e8e12599e..434d3f3d2 100644 --- a/test/e2e/testdata/zot/command/artifacts/index.json +++ b/test/e2e/testdata/zot/command/artifacts/index.json @@ -11,12 +11,12 @@ }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", - "digest": "sha256:7cdd0383e3db8adcca166e59b431981b4407f9d30b17014ad42873107af6fbc4", + "digest": "sha256:e2c6633a79985906f1ed55c592718c73c41e809fb9818de232a635904a74d48d", "size": 660 }, { "mediaType": "application/vnd.oci.image.manifest.v1+json", - "digest": "sha256:b6d28d84b6ad3f8d9d437db28248ab26270597fe55cde0aa29813341cd5430af", + "digest": "sha256:0cb8c4da7e9ff2e7eefca33141091b9239218e3125a35e17e8bcd05fa3a5e714", "size": 670 } ] From a90495d6e65cd450cb44b5192fa1856c832316d5 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Thu, 31 Aug 2023 17:12:57 +0000 Subject: [PATCH 45/45] rebake test data Signed-off-by: Billy Zha --- test/e2e/internal/testdata/foobar/const.go | 29 +++------------------- test/e2e/suite/command/cp.go | 8 +++--- test/e2e/suite/command/discover.go | 14 +++++------ 3 files changed, 14 insertions(+), 37 deletions(-) diff --git a/test/e2e/internal/testdata/foobar/const.go b/test/e2e/internal/testdata/foobar/const.go index 982ab3183..6a280118e 100644 --- a/test/e2e/internal/testdata/foobar/const.go +++ b/test/e2e/internal/testdata/foobar/const.go @@ -100,7 +100,7 @@ var ( } SignatureImageReferrer = ocispec.Descriptor{ MediaType: "application/vnd.oci.image.manifest.v1+json", - Digest: digest.Digest("sha256:b6d28d84b6ad3f8d9d437db28248ab26270597fe55cde0aa29813341cd5430af"), + Digest: digest.Digest("sha256:0cb8c4da7e9ff2e7eefca33141091b9239218e3125a35e17e8bcd05fa3a5e714"), Size: 670, } SBOMArtifactReferrer = ocispec.Descriptor{ @@ -122,34 +122,11 @@ var ( {Digest: "2dbea575a349", Name: "application/vnd.oci.artifact.manifest.v1+json"}, } ImageReferrersStateKeys = []match.StateKey{ - {Digest: "b6d28d84b6ad", Name: "application/vnd.oci.image.manifest.v1+json"}, + {Digest: "0cb8c4da7e9f", Name: "application/vnd.oci.image.manifest.v1+json"}, {Digest: "e2c6633a7998", Name: "application/vnd.oci.image.manifest.v1+json"}, } ImageReferrerConfigStateKeys = []match.StateKey{ {Digest: "44136fa355b3", Name: "test/signature.file"}, - {Digest: "44136fa355b3", Name: "test/sbom/file"}, - } - FallbackImageReferrersStateKeys = []match.StateKey{ - {Digest: "b6d28d84b6ad", Name: "application/vnd.oci.image.manifest.v1+json"}, - {Digest: "e2c6633a7998", Name: "application/vnd.oci.image.manifest.v1+json"}, - } -) - -// fallback referrers -var ( - FallbackSignatureImageReferrer = ocispec.Descriptor{ - MediaType: "application/vnd.oci.image.manifest.v1+json", - Digest: digest.Digest("sha256:b6d28d84b6ad3f8d9d437db28248ab26270597fe55cde0aa29813341cd5430af"), - Size: 670, - } - - FallbackSBOMImageReferrer = ocispec.Descriptor{ - MediaType: "application/vnd.oci.image.manifest.v1+json", - Digest: digest.Digest("sha256:e2c6633a79985906f1ed55c592718c73c41e809fb9818de232a635904a74d48d"), - Size: 660, - Annotations: map[string]string{ - "org.opencontainers.image.created": "2023-01-18T08:37:42Z", - }, - ArtifactType: "test/sbom/file", + {Digest: "44136fa355b3", Name: "test/sbom.file"}, } ) diff --git a/test/e2e/suite/command/cp.go b/test/e2e/suite/command/cp.go index 3d06cf1e4..cdcab5c8f 100644 --- a/test/e2e/suite/command/cp.go +++ b/test/e2e/suite/command/cp.go @@ -257,13 +257,13 @@ var _ = Describe("OCI spec 1.0 registry users:", func() { }) It("should copy an image artifact and its referrers from a fallback registry to a registry", func() { repo := cpTestRepo("from-fallback") - stateKeys := append(append(foobarStates, foobar.FallbackImageReferrersStateKeys...), foobar.ImageReferrerConfigStateKeys...) - src := RegistryRef(FallbackHost, ArtifactRepo, foobar.FallbackSBOMImageReferrer.Digest.String()) + stateKeys := append(append(foobarStates, foobar.ImageReferrersStateKeys...), foobar.ImageReferrerConfigStateKeys...) + src := RegistryRef(FallbackHost, ArtifactRepo, foobar.SBOMImageReferrer.Digest.String()) dst := RegistryRef(Host, repo, "") ORAS("cp", "-r", src, dst, "-v").MatchStatus(stateKeys, true, len(stateKeys)).Exec() - CompareRef(src, RegistryRef(Host, repo, foobar.FallbackSBOMImageReferrer.Digest.String())) + CompareRef(src, RegistryRef(Host, repo, foobar.SBOMImageReferrer.Digest.String())) ORAS("discover", "-o", "tree", RegistryRef(Host, repo, foobar.Digest)). - WithDescription("discover referrer via subject").MatchKeyWords(foobar.FallbackSignatureImageReferrer.Digest.String(), foobar.FallbackSBOMImageReferrer.Digest.String()).Exec() + WithDescription("discover referrer via subject").MatchKeyWords(foobar.SignatureImageReferrer.Digest.String(), foobar.SBOMImageReferrer.Digest.String()).Exec() }) It("should copy an image from a fallback registry to an OCI image layout via digest", func() { diff --git a/test/e2e/suite/command/discover.go b/test/e2e/suite/command/discover.go index 60cb7fef5..04ac3c377 100644 --- a/test/e2e/suite/command/discover.go +++ b/test/e2e/suite/command/discover.go @@ -144,15 +144,15 @@ var _ = Describe("1.0 registry users:", func() { var index ocispec.Index Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred()) Expect(index.Manifests).To(HaveLen(1)) - Expect(index.Manifests).Should(ContainElement(foobar.FallbackSBOMImageReferrer)) + Expect(index.Manifests).Should(ContainElement(foobar.SBOMImageReferrer)) }) It("should discover matched referrer when filtering via json output", func() { - bytes := ORAS("discover", subjectRef, "-o", "json", "--artifact-type", foobar.FallbackSBOMImageReferrer.ArtifactType).Exec().Out.Contents() + bytes := ORAS("discover", subjectRef, "-o", "json", "--artifact-type", foobar.SBOMImageReferrer.ArtifactType).Exec().Out.Contents() var index ocispec.Index Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred()) Expect(index.Manifests).To(HaveLen(1)) - Expect(index.Manifests).Should(ContainElement(foobar.FallbackSBOMImageReferrer)) + Expect(index.Manifests).Should(ContainElement(foobar.SBOMImageReferrer)) }) It("should discover no referrer when not matching via json output", func() { @@ -163,28 +163,28 @@ var _ = Describe("1.0 registry users:", func() { }) It("should discover all referrers of a subject via tree output", func() { - referrers := []ocispec.Descriptor{foobar.FallbackSBOMImageReferrer, foobar.FallbackSignatureImageReferrer} + referrers := []ocispec.Descriptor{foobar.SBOMImageReferrer, foobar.SignatureImageReferrer} ORAS("discover", subjectRef, "-o", "tree"). MatchKeyWords(append(discoverKeyWords(false, referrers...), RegistryRef(FallbackHost, ArtifactRepo, foobar.Digest))...). Exec() }) It("should discover all referrers with annotation via tree output", func() { - referrers := []ocispec.Descriptor{foobar.FallbackSBOMImageReferrer, foobar.FallbackSignatureImageReferrer} + referrers := []ocispec.Descriptor{foobar.SBOMImageReferrer, foobar.SignatureImageReferrer} ORAS("discover", subjectRef, "-o", "tree", "-v"). MatchKeyWords(append(discoverKeyWords(true, referrers...), RegistryRef(FallbackHost, ArtifactRepo, foobar.Digest))...). Exec() }) It("should discover direct referrers of a subject via table output", func() { - referrers := []ocispec.Descriptor{foobar.FallbackSBOMImageReferrer} + referrers := []ocispec.Descriptor{foobar.SBOMImageReferrer} ORAS("discover", subjectRef, "-o", "table"). MatchKeyWords(append(discoverKeyWords(false, referrers...), foobar.Digest)...). Exec() }) It("should discover direct referrers explicitly via tag scheme", func() { - referrers := []ocispec.Descriptor{foobar.FallbackSBOMImageReferrer} + referrers := []ocispec.Descriptor{foobar.SBOMImageReferrer} ORAS("discover", subjectRef, "-o", "table", "--distribution-spec", "v1.1-referrers-tag"). MatchKeyWords(append(discoverKeyWords(false, referrers...), foobar.Digest)...). Exec()