Skip to content

Commit

Permalink
test: add E2E specs for manifest fetch-config
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
  • Loading branch information
qweeah committed Dec 5, 2022
1 parent b89736e commit 7db15b4
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 2 deletions.
3 changes: 2 additions & 1 deletion test/e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ go 1.19
require (
github.com/onsi/ginkgo/v2 v2.1.6
github.com/onsi/gomega v1.20.2
github.com/opencontainers/image-spec v1.1.0-rc2
oras.land/oras-go/v2 v2.0.0-rc.4
)

require (
github.com/google/go-cmp v0.5.8 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7X
github.com/opencontainers/image-spec v1.1.0-rc2/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
Expand Down
1 change: 1 addition & 0 deletions test/e2e/suite/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var _ = Describe("Common registry user", Ordered, func() {
RunWithoutLogin("push", "-a", "key=value", Host+"/repo:tag")
RunWithoutLogin("pull", Host+"/repo:tag")
RunWithoutLogin("manifest", "fetch", Host+"/repo:tag")
RunWithoutLogin("manifest", "fetch-config", Host+"/repo:tag")
})
})

Expand Down
58 changes: 57 additions & 1 deletion test/e2e/suite/command/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ const (
preview_desc = "** This command is in preview and under development. **"
example_desc = "\nExample - "
repo = "command/images"
foobarTag = "foobar"
foobarConfigDescriptor = "{\"mediaType\":\"application/vnd.unknown.config.v1+json\",\"digest\":\"sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a\",\"size\":2}"
multiImage = "multi"
digest_multi = "sha256:e2bfc9cc6a84ec2d7365b5a28c6bc5806b7fa581c9ad7883be955a64e3cc034f"
foobarDigest = "sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb"
manifest_multi = `{"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_multi = `{"mediaType":"application/vnd.oci.image.index.v1+json","digest":"sha256:e2bfc9cc6a84ec2d7365b5a28c6bc5806b7fa581c9ad7883be955a64e3cc034f","size":706}`
descriptor_linuxAMD64 = `{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:9d84a5716c66a1d1b9c13f8ed157ba7d1edfe7f9b8766728b8a1f25c0d9c14c1","size":458}`
descriptor_linuxAMD64_fromIndex = `{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:9d84a5716c66a1d1b9c13f8ed157ba7d1edfe7f9b8766728b8a1f25c0d9c14c1","size":458,"platform":{"architecture":"amd64","os":"linux"}}`
digest_linuxAMD64 = "sha256:9d84a5716c66a1d1b9c13f8ed157ba7d1edfe7f9b8766728b8a1f25c0d9c14c1"
manifest_linuxAMD64 = `{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"application/vnd.oci.image.config.v1+json","digest":"sha256:fe9dbc99451d0517d65e048c309f0b5afb2cc513b7a3d456b6cc29fe641386c5","size":53},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:2ef548696ac7dd66ef38aab5cc8fc5cc1fb637dfaedb3a9afc89bf16db9277e1","size":10240,"annotations":{"org.opencontainers.image.title":"hello.tar"}}]}`
linuxAMD64Config = "{\r\n \"architecture\": \"amd64\",\r\n \"os\": \"linux\"\r\n}"
linuxAMD64ConfigDescriptor = `{"mediaType":"application/vnd.oci.image.config.v1+json","digest":"sha256:fe9dbc99451d0517d65e048c309f0b5afb2cc513b7a3d456b6cc29fe641386c5","size":53}`

manifest_linuxAMD64 = `{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"application/vnd.oci.image.config.v1+json","digest":"sha256:fe9dbc99451d0517d65e048c309f0b5afb2cc513b7a3d456b6cc29fe641386c5","size":53},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar","digest":"sha256:2ef548696ac7dd66ef38aab5cc8fc5cc1fb637dfaedb3a9afc89bf16db9277e1","size":10240,"annotations":{"org.opencontainers.image.title":"hello.tar"}}]}`
)

var _ = Describe("ORAS beginners:", func() {
Expand All @@ -52,6 +58,24 @@ var _ = Describe("ORAS beginners:", func() {
MatchErrKeyWords("Error:").
Exec()
})

When("running `manifest fetch-config`", func() {
It("should show preview hint in the doc", func() {
ORAS("manifest", "fetch-config", "--help").
MatchKeyWords(preview_desc, example_desc, "[Preview]", "\nUsage:").Exec()
})

It("should fail if no manifest reference provided", func() {
ORAS("manifest", "fetch-config").WithFailureCheck().Exec()
})

It("should fail if provided reference does not exist", func() {
ORAS("manifest", "fetch-config", Reference(Host, repo, "this-tag-should-not-exist")).WithFailureCheck().Exec()
})
It("should fail fetching a config of non-image manifest type", func() {
ORAS("manifest", "fetch-config", Reference(Host, repo, multiImage)).WithFailureCheck().Exec()
})
})
})
})

Expand Down Expand Up @@ -169,4 +193,36 @@ var _ = Describe("Common registry users:", func() {
MatchErrKeyWords(digest_linuxAMD64, "error: ", "not found").Exec()
})
})

When("running `manifest fetch-config`", func() {
It("should fetch a config via a tag", func() {
ORAS("manifest", "fetch-config", Reference(Host, repo, foobarTag)).
MatchContent("{}").Exec()
})

It("should fetch a config descriptor via a tag", func() {
ORAS("manifest", "fetch-config", "--descriptor", Reference(Host, repo, foobarTag)).
MatchContent(foobarConfigDescriptor).Exec()
})

It("should fetch a config via digest", func() {
ORAS("manifest", "fetch-config", Reference(Host, repo, foobarTag)).
MatchContent("{}").Exec()
})

It("should fetch a config descriptor via a digest", func() {
ORAS("manifest", "fetch-config", "--descriptor", Reference(Host, repo, foobarDigest)).
MatchContent(foobarConfigDescriptor).Exec()
})

It("should fetch a config of a specific platform", func() {
ORAS("manifest", "fetch-config", "--platform", "linux/amd64", Reference(Host, repo, multiImage)).
MatchContent(linuxAMD64Config).Exec()
})

It("should fetch a config descriptor of a specific platform", func() {
ORAS("manifest", "fetch-config", "--descriptor", "--platform", "linux/amd64", Reference(Host, repo, multiImage)).
MatchContent(linuxAMD64ConfigDescriptor).Exec()
})
})
})

0 comments on commit 7db15b4

Please sign in to comment.