Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add e2e tests for manifest fetch-config under oci-layout #889

Merged
merged 3 commits into from
Mar 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 55 additions & 9 deletions test/e2e/suite/command/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,12 @@ var _ = Describe("Common registry users:", func() {
})

var _ = Describe("OCI image layout users:", 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
}

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()
ORAS("manifest", "fetch", Flags.Layout, LayoutRef(root, multi_arch.Digest)).
Expand Down Expand Up @@ -462,7 +461,6 @@ var _ = Describe("OCI image layout users:", func() {
"--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() {
root := prepare()
ORAS("manifest", "fetch", Flags.Layout, LayoutRef(root, multi_arch.Tag),
Expand All @@ -472,19 +470,67 @@ var _ = Describe("OCI image layout users:", func() {
"--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() {
root := prepare()
ORAS("manifest", "fetch", Flags.Layout, LayoutRef(root, 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() {
root := prepare()
ORAS("manifest", "fetch", Flags.Layout, LayoutRef(root, 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 fetching manifest without reference provided", func() {
root := prepare()
ORAS("manifest", "fetch", Flags.Layout, root).ExpectFailure().
MatchErrKeyWords("Error:").Exec()
})
})

When("running `manifest fetch-config`", func() {
prepare := func(tag string) string {
tmpRoot := GinkgoT().TempDir()
cpPath := tmpRoot
from := RegistryRef(Host, 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
}
It("should fetch a config via a tag", func() {
root := prepare(foobar.Tag)
ORAS("manifest", "fetch-config", Flags.Layout, LayoutRef(root, foobar.Tag)).
MatchContent("{}").Exec()
})
It("should fetch a config descriptor via a tag", func() {
root := prepare(foobar.Tag)
ORAS("manifest", "fetch-config", "--descriptor", Flags.Layout, LayoutRef(root, foobar.Tag)).
MatchContent(foobar.ImageConfigDesc).Exec()
})
It("should fetch a config via digest", func() {
root := prepare(foobar.Tag)
ORAS("manifest", "fetch-config", Flags.Layout, LayoutRef(root, foobar.Digest)).
MatchContent("{}").Exec()
})
It("should fetch a config descriptor via a digest", func() {
root := prepare(foobar.Tag)
ORAS("manifest", "fetch-config", "--descriptor", Flags.Layout, LayoutRef(root, foobar.Digest)).
MatchContent(foobar.ImageConfigDesc).Exec()
})
It("should fetch a config of a specific platform", func() {
root := prepare(multi_arch.Tag)
ORAS("manifest", "fetch-config", "--platform", "linux/amd64", Flags.Layout, LayoutRef(root, multi_arch.Tag)).
MatchContent(multi_arch.LinuxAMD64Config).Exec()
})
It("should fetch a config descriptor of a specific platform", func() {
root := prepare(multi_arch.Tag)
ORAS("manifest", "fetch-config", "--descriptor", "--platform", "linux/amd64", Flags.Layout, LayoutRef(root, multi_arch.Tag)).
MatchContent(multi_arch.LinuxAMD64ConfigDesc).Exec()
})
It("should fail if no manifest reference provided", func() {
root := prepare(foobar.Tag)
ORAS("manifest", "fetch-config", Flags.Layout, root).ExpectFailure().Exec()
})
})
})