Skip to content

Commit

Permalink
add cp test
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah committed Sep 1, 2023
1 parent 7f5158e commit 0bb8f66
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
26 changes: 26 additions & 0 deletions test/e2e/internal/testdata/artifact/index/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
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 index

import "oras.land/oras/test/e2e/internal/utils/match"

var (
ManifestDigest = "sha256:7679bc22c33b87aa345c6950a993db98a6df7a6cc77a35c388908a3a50be6bad"
ManifestStatusKey = match.StateKey{
Digest: "7679bc22c33b",
Name: "application/vnd.oci.image.index.v1+json",
}
)
1 change: 1 addition & 0 deletions test/e2e/internal/testdata/multi_arch/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var (
{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"},
{Digest: "e2bfc9cc6a84", Name: "application/vnd.oci.image.index.v1+json"},
}
// below are newly baked artifacts for ZOT
IndexZOTReferrerStateKey = match.StateKey{Digest: "d37baf66300b", Name: "application/vnd.oci.image.manifest.v1+json"}
Expand Down
18 changes: 13 additions & 5 deletions test/e2e/suite/command/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"oras.land/oras-go/v2"
"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/index"
"oras.land/oras/test/e2e/internal/testdata/feature"
"oras.land/oras/test/e2e/internal/testdata/foobar"
ma "oras.land/oras/test/e2e/internal/testdata/multi_arch"
Expand Down Expand Up @@ -85,6 +86,13 @@ var _ = Describe("1.1 registry users:", func() {
ORAS("cp", src, dst, "-v").MatchStatus(config.StateKeys, true, len(config.StateKeys)).Exec()
})

It("should copy index and its subject", func() {
stateKeys := append(ma.IndexStateKeys, index.ManifestStatusKey)
src := RegistryRef(ZOTHost, ArtifactRepo, index.ManifestDigest)
dst := RegistryRef(ZOTHost, cpTestRepo("index-with-subject"), "")
ORAS("cp", src, dst, "-v").MatchStatus(stateKeys, true, len(stateKeys)).Exec()
})

It("should copy an image to a new repository via tag", func() {
src := RegistryRef(ZOTHost, ImageRepo, foobar.Tag)
dst := RegistryRef(ZOTHost, cpTestRepo("tag"), "copied")
Expand Down Expand Up @@ -126,7 +134,7 @@ var _ = Describe("1.1 registry users:", func() {
// validate
CompareRef(RegistryRef(ZOTHost, ImageRepo, ma.Digest), dst)
var index ocispec.Index
bytes := ORAS("discover", dst, "-o", "json").
bytes := ORAS("discover", dst, "-o", "json", "--artifact-type", ma.IndexReferrerConfigStateKey.Name).
MatchKeyWords(ma.IndexReferrerDigest).
WithDescription("copy image referrer").
Exec().Out.Contents()
Expand All @@ -151,7 +159,7 @@ var _ = Describe("1.1 registry users:", func() {
// validate
CompareRef(RegistryRef(ZOTHost, ImageRepo, ma.Digest), dst)
var index ocispec.Index
bytes := ORAS("discover", dst, "-o", "json").
bytes := ORAS("discover", dst, "-o", "json", "--artifact-type", ma.IndexReferrerConfigStateKey.Name).
MatchKeyWords(ma.IndexReferrerDigest).
WithDescription("copy image referrer").
Exec().Out.Contents()
Expand Down Expand Up @@ -469,8 +477,8 @@ var _ = Describe("OCI layout users:", func() {
dstManifest := ORAS("manifest", "fetch", dst, Flags.Layout).WithDescription("fetch from destination to validate").Exec().Out.Contents()
Expect(srcManifest).To(Equal(dstManifest))
var index ocispec.Index
bytes := ORAS("discover", dst, "-o", "json", Flags.Layout).
MatchKeyWords(ma.IndexReferrerDigest).
bytes := ORAS("discover", dst, "-o", "json", Flags.Layout, "--artifact-type", ma.IndexReferrerConfigStateKey.Name).
// MatchKeyWords(ma.IndexReferrerDigest).
WithDescription("copy image referrer").
Exec().Out.Contents()
Expect(json.Unmarshal(bytes, &index)).ShouldNot(HaveOccurred())
Expand Down Expand Up @@ -499,7 +507,7 @@ var _ = Describe("OCI layout users:", func() {
dstManifest := ORAS("manifest", "fetch", dst).WithDescription("fetch from destination to validate").Exec().Out.Contents()
Expect(srcManifest).To(Equal(dstManifest))
var index ocispec.Index
bytes := ORAS("discover", dst, "-o", "json").
bytes := ORAS("discover", dst, "-o", "json", "--artifact-type", ma.IndexReferrerConfigStateKey.Name).
MatchKeyWords(ma.IndexReferrerDigest).
WithDescription("copy image referrer").
Exec().Out.Contents()
Expand Down

0 comments on commit 0bb8f66

Please sign in to comment.