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