diff --git a/test/e2e/README.md b/test/e2e/README.md index 2bd607f2c..2306b256c 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -189,6 +189,9 @@ graph TD; G1["referrer.index(image)"] -- subject --> F1 G2["referrer.image(image)"] -- subject --> F2 G3["index"] -- subject --> F1 + + H0>tag: unnamed]-..->H1["artifact contains unnamed layer"] + I0>tag: empty]-..->I1["artifact contains only one empty layer"] end ``` diff --git a/test/e2e/internal/testdata/artifact/empty/const.go b/test/e2e/internal/testdata/artifact/empty/const.go new file mode 100644 index 000000000..7b5170ef5 --- /dev/null +++ b/test/e2e/internal/testdata/artifact/empty/const.go @@ -0,0 +1,22 @@ +/* +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. +*/ + +package empty + +const ( + Tag = "empty" + Digest = "sha256:7156dd4030da2375969c4da97e051d907f54ff8e9d28cc82c57289bbd22e3f9f" + ArtifactType = "test/empty.artifact" +) diff --git a/test/e2e/internal/testdata/artifact/unnamed/const.go b/test/e2e/internal/testdata/artifact/unnamed/const.go new file mode 100644 index 000000000..ffe21730f --- /dev/null +++ b/test/e2e/internal/testdata/artifact/unnamed/const.go @@ -0,0 +1,22 @@ +/* +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. +*/ + +package unnamed + +const ( + Tag = "unnamed" + Digest = "sha256:977c6cf8e8aeaa35a5b5d6127e5008775d66d65985ac77634f79e1d7501bba83" + ArtifactType = "application/vnd.unknown.config.v1+json" +) diff --git a/test/e2e/suite/command/pull.go b/test/e2e/suite/command/pull.go index e12ee232c..06accb879 100644 --- a/test/e2e/suite/command/pull.go +++ b/test/e2e/suite/command/pull.go @@ -27,6 +27,8 @@ import ( "github.com/onsi/gomega/gbytes" "oras.land/oras/test/e2e/internal/testdata/artifact/blob" "oras.land/oras/test/e2e/internal/testdata/artifact/config" + "oras.land/oras/test/e2e/internal/testdata/artifact/empty" + "oras.land/oras/test/e2e/internal/testdata/artifact/unnamed" "oras.land/oras/test/e2e/internal/testdata/feature" "oras.land/oras/test/e2e/internal/testdata/foobar" "oras.land/oras/test/e2e/internal/testdata/multi_arch" @@ -39,6 +41,31 @@ var _ = Describe("ORAS beginners:", func() { out := ORAS("pull", "--help").MatchKeyWords(ExampleDesc).Exec().Out gomega.Expect(out).Should(gbytes.Say("--include-subject\\s+%s", regexp.QuoteMeta(feature.Preview.Mark))) }) + + hintMsg := func(reference string) string { + return fmt.Sprintf("Skipped pulling layers without file name in \"org.opencontainers.image.title\"\nUse 'oras copy %s --to-oci-layout ' to pull all layers.\n", reference) + } + It("should show hint for unnamed layer", func() { + tempDir := PrepareTempFiles() + ref := RegistryRef(ZOTHost, ArtifactRepo, unnamed.Tag) + ORAS("pull", ref). + WithWorkDir(tempDir). + MatchContent(hintMsg(ref)).Exec() + }) + + It("should not show hint for unnamed config blob", func() { + tempDir := PrepareTempFiles() + ref := RegistryRef(ZOTHost, ImageRepo, foobar.Tag) + out := ORAS("pull", ref).WithWorkDir(tempDir).Exec().Out + gomega.Expect(out).ShouldNot(gbytes.Say(hintMsg(ref))) + }) + + It("should not show hint for empty layer", func() { + tempDir := PrepareTempFiles() + ref := RegistryRef(ZOTHost, ArtifactRepo, empty.Tag) + out := ORAS("pull", ref).WithWorkDir(tempDir).Exec().Out + gomega.Expect(out).ShouldNot(gbytes.Say(hintMsg(ref))) + }) }) }) diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/7156dd4030da2375969c4da97e051d907f54ff8e9d28cc82c57289bbd22e3f9f b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/7156dd4030da2375969c4da97e051d907f54ff8e9d28cc82c57289bbd22e3f9f new file mode 100644 index 000000000..feab712f9 --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/7156dd4030da2375969c4da97e051d907f54ff8e9d28cc82c57289bbd22e3f9f @@ -0,0 +1 @@ +{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","artifactType":"test/empty.artifact","config":{"mediaType":"application/vnd.oci.empty.v1+json","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2,"data":"e30="},"layers":[{"mediaType":"application/vnd.oci.empty.v1+json","digest":"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a","size":2,"data":"e30="}],"annotations":{"org.opencontainers.image.created":"2023-11-06T08:07:54Z"}} \ No newline at end of file diff --git a/test/e2e/testdata/zot/command/artifacts/blobs/sha256/977c6cf8e8aeaa35a5b5d6127e5008775d66d65985ac77634f79e1d7501bba83 b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/977c6cf8e8aeaa35a5b5d6127e5008775d66d65985ac77634f79e1d7501bba83 new file mode 100644 index 000000000..9822b4869 --- /dev/null +++ b/test/e2e/testdata/zot/command/artifacts/blobs/sha256/977c6cf8e8aeaa35a5b5d6127e5008775d66d65985ac77634f79e1d7501bba83 @@ -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}]} \ 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 58f824e70..83bff2e72 100644 --- a/test/e2e/testdata/zot/command/artifacts/index.json +++ b/test/e2e/testdata/zot/command/artifacts/index.json @@ -77,6 +77,22 @@ "mediaType": "application/vnd.oci.image.index.v1+json", "digest": "sha256:7679bc22c33b87aa345c6950a993db98a6df7a6cc77a35c388908a3a50be6bad", "size": 867 + }, + { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "digest": "sha256:7156dd4030da2375969c4da97e051d907f54ff8e9d28cc82c57289bbd22e3f9f", + "size": 519, + "annotations": { + "org.opencontainers.image.ref.name": "empty" + } + }, + { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "digest": "sha256:977c6cf8e8aeaa35a5b5d6127e5008775d66d65985ac77634f79e1d7501bba83", + "size": 390, + "annotations": { + "org.opencontainers.image.ref.name": "unnamed" + } } ] } \ No newline at end of file