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(e2e): add test for pushing via absolute path #991

Merged
merged 31 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1ebb328
Add changes for fixing the absolute path behaviour in oras push and a…
suganyas Jun 26, 2023
a68ed83
Update cmd/oras/internal/option/packer.go
suganyas Jun 27, 2023
3337a5e
Update cmd/oras/internal/option/packer.go
suganyas Jun 27, 2023
f62a8b4
Update cmd/oras/root/pull.go
suganyas Jun 27, 2023
10901c0
Address review comments from Billy and tested code
suganyas Jun 27, 2023
08c4593
Update cmd/oras/internal/option/packer.go
suganyas Jun 27, 2023
4392939
Update cmd/oras/internal/option/packer.go
suganyas Jun 27, 2023
a8d7abf
Update cmd/oras/internal/option/packer.go
suganyas Jun 27, 2023
74ef557
Update cmd/oras/root/pull.go
suganyas Jun 27, 2023
e417954
Update cmd/oras/internal/option/packer.go
suganyas Jun 27, 2023
ea6600c
Update cmd/oras/internal/option/packer.go
suganyas Jun 27, 2023
e0d769f
Fix the build for compilation error
suganyas Jun 27, 2023
a548ad4
test(e2e): add test for pushing via absolute path
qweeah Jun 27, 2023
755a83c
Add changes for fixing the absolute path behaviour in oras push and a…
suganyas Jun 26, 2023
caec5ff
Update cmd/oras/internal/option/packer.go
suganyas Jun 27, 2023
007b2d9
Update cmd/oras/internal/option/packer.go
suganyas Jun 27, 2023
8f447bd
Update cmd/oras/root/pull.go
suganyas Jun 27, 2023
de4bdb7
Address review comments from Billy and tested code
suganyas Jun 27, 2023
351a110
Update cmd/oras/internal/option/packer.go
suganyas Jun 27, 2023
e03dec7
Update cmd/oras/internal/option/packer.go
suganyas Jun 27, 2023
8f03f50
Update cmd/oras/internal/option/packer.go
suganyas Jun 27, 2023
af7c0ea
Update cmd/oras/root/pull.go
suganyas Jun 27, 2023
2609e2f
Update cmd/oras/internal/option/packer.go
suganyas Jun 27, 2023
d1dd526
Update cmd/oras/internal/option/packer.go
suganyas Jun 27, 2023
0c656ee
Fix the build for compilation error
suganyas Jun 27, 2023
8420368
Update cmd/oras/internal/option/packer.go
suganyas Jun 28, 2023
f3549cd
Update cmd/oras/root/pull.go
suganyas Jun 28, 2023
ae964ec
Update cmd/oras/internal/option/packer.go
suganyas Jun 28, 2023
0c37583
Merge remote-tracking branch 'suganyas/main' into e2e-path
qweeah Jun 28, 2023
c124a28
Merge branch 'main' into e2e-path
qweeah Jun 28, 2023
d2624c8
Merge branch 'main' into e2e-path
qweeah Jun 29, 2023
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
28 changes: 28 additions & 0 deletions test/e2e/suite/command/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ var _ = Describe("Common registry users:", func() {
fetched := ORAS("manifest", "fetch", RegistryRef(Host, testRepo, index.Manifests[0].Digest.String())).Exec().Out.Contents()
MatchFile(filepath.Join(tempDir, exportName), string(fetched), DefaultTimeout)
})

It("should attach a file via a OCI Image", func() {
testRepo := attachTestRepo("image")
tempDir := PrepareTempFiles()
Expand All @@ -121,6 +122,33 @@ var _ = Describe("Common registry users:", func() {
Expect(len(index.Manifests)).To(Equal(1))
Expect(index.Manifests[0].MediaType).To(Equal(ocispec.MediaTypeImageManifest))
})

It("should attach file with path validation disabled", func() {
testRepo := attachTestRepo("simple")
absAttachFileName := filepath.Join(PrepareTempFiles(), foobar.AttachFileName)

subjectRef := RegistryRef(Host, testRepo, foobar.Tag)
prepare(RegistryRef(Host, ImageRepo, foobar.Tag), subjectRef)
statusKey := foobar.AttachFileStateKey
statusKey.Name = absAttachFileName
ORAS("attach", "--artifact-type", "test.attach", subjectRef, fmt.Sprintf("%s:%s", absAttachFileName, foobar.AttachFileMedia), "--disable-path-validation").
MatchStatus([]match.StateKey{statusKey}, false, 1).
Exec()
})

It("should fail path validation when attaching file with absolute path", func() {
testRepo := attachTestRepo("simple")
absAttachFileName := filepath.Join(PrepareTempFiles(), foobar.AttachFileName)

subjectRef := RegistryRef(Host, testRepo, foobar.Tag)
prepare(RegistryRef(Host, ImageRepo, foobar.Tag), subjectRef)
statusKey := foobar.AttachFileStateKey
statusKey.Name = absAttachFileName
ORAS("attach", "--artifact-type", "test.attach", subjectRef, fmt.Sprintf("%s:%s", absAttachFileName, foobar.AttachFileMedia)).
ExpectFailure().
Exec()
})

It("should attach a file via a OCI Artifact", func() {
testRepo := attachTestRepo("artifact")
tempDir := PrepareTempFiles()
Expand Down
34 changes: 34 additions & 0 deletions test/e2e/suite/command/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/onsi/gomega"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"oras.land/oras/test/e2e/internal/testdata/feature"
"oras.land/oras/test/e2e/internal/testdata/foobar"
Expand Down Expand Up @@ -65,6 +66,39 @@ var _ = Describe("Remote registry users:", func() {
Expect(manifest.Layers).Should(ContainElements(foobar.BlobBarDescriptor("application/vnd.oci.image.layer.v1.tar")))
})

It("should push files with path validation disabled", func() {
repo := fmt.Sprintf("%s/%s", repoPrefix, "disable-path-validation")
ref := RegistryRef(Host, repo, tag)
absBarName := filepath.Join(PrepareTempFiles(), foobar.FileBarName)

ORAS("push", ref, absBarName, "-v", "--disable-path-validation").
Exec()

// validate
fetched := ORAS("manifest", "fetch", ref).Exec().Out.Contents()
var manifest ocispec.Manifest
Expect(json.Unmarshal(fetched, &manifest)).ShouldNot(HaveOccurred())
Expect(manifest.Layers).Should(ContainElements(ocispec.Descriptor{
MediaType: "application/vnd.oci.image.layer.v1.tar",
Digest: digest.Digest(foobar.BarBlobDigest),
Size: 3,
Annotations: map[string]string{
"org.opencontainers.image.title": absBarName,
},
}))
})

It("should fail path validation when pushing file with absolute path", func() {
repo := fmt.Sprintf("%s/%s", repoPrefix, "path-validation")
ref := RegistryRef(Host, repo, tag)
absBarName := filepath.Join(PrepareTempFiles(), foobar.FileBarName)
// test
ORAS("push", ref, absBarName, "-v").
MatchErrKeyWords("--disable-path-validation").
ExpectFailure().
Exec()
})

It("should push files and tag", func() {
repo := fmt.Sprintf("%s/%s", repoPrefix, "multi-tag")
tempDir := PrepareTempFiles()
Expand Down