Re-enable disabled tests

This commit is contained in:
Dane Everitt 2020-11-08 15:17:47 -08:00
parent 68bdcb3cbc
commit de0c67d066
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53

View File

@ -2,6 +2,7 @@ package filesystem
import ( import (
"bytes" "bytes"
"emperror.dev/errors"
. "github.com/franela/goblin" . "github.com/franela/goblin"
"os" "os"
"path/filepath" "path/filepath"
@ -144,85 +145,84 @@ func TestFilesystem_Blocks_Symlinks(t *testing.T) {
g.Assert(IsBadPathResolutionError(err)).IsTrue() g.Assert(IsBadPathResolutionError(err)).IsTrue()
}) })
}) })
//
// g.Describe("CreateDirectory", func() { g.Describe("CreateDirectory", func() {
// g.It("cannot create a directory outside the root", func() { g.It("cannot create a directory outside the root", func() {
// err := fs.CreateDirectory("my_dir", "external_dir") err := fs.CreateDirectory("my_dir", "external_dir")
// g.Assert(err).IsNotNil() g.Assert(err).IsNotNil()
// g.Assert(IsBadPathResolutionError(err)).IsTrue() g.Assert(IsBadPathResolutionError(err)).IsTrue()
// }) })
//
// g.It("cannot create a nested directory outside the root", func() { g.It("cannot create a nested directory outside the root", func() {
// err := fs.CreateDirectory("my/nested/dir", "external_dir/foo/bar") err := fs.CreateDirectory("my/nested/dir", "external_dir/foo/bar")
// g.Assert(err).IsNotNil() g.Assert(err).IsNotNil()
// g.Assert(IsBadPathResolutionError(err)).IsTrue() g.Assert(IsBadPathResolutionError(err)).IsTrue()
// }) })
//
// g.It("cannot create a nested directory outside the root", func() { g.It("cannot create a nested directory outside the root", func() {
// err := fs.CreateDirectory("my/nested/dir", "external_dir/server") err := fs.CreateDirectory("my/nested/dir", "external_dir/server")
// g.Assert(err).IsNotNil() g.Assert(err).IsNotNil()
// g.Assert(IsBadPathResolutionError(err)).IsTrue() g.Assert(IsBadPathResolutionError(err)).IsTrue()
// }) })
// }) })
//
// g.Describe("Rename", func() { g.Describe("Rename", func() {
// g.It("cannot rename a file symlinked outside the directory root", func() { g.It("cannot rename a file symlinked outside the directory root", func() {
// err := fs.Rename("symlinked.txt", "foo.txt") err := fs.Rename("symlinked.txt", "foo.txt")
// g.Assert(err).IsNotNil() g.Assert(err).IsNotNil()
// g.Assert(IsBadPathResolutionError(err)).IsTrue() g.Assert(IsBadPathResolutionError(err)).IsTrue()
// }) })
//
// g.It("cannot rename a symlinked directory outside the root", func() { g.It("cannot rename a symlinked directory outside the root", func() {
// err := fs.Rename("external_dir", "foo") err := fs.Rename("external_dir", "foo")
// g.Assert(err).IsNotNil() g.Assert(err).IsNotNil()
// g.Assert(IsBadPathResolutionError(err)).IsTrue() g.Assert(IsBadPathResolutionError(err)).IsTrue()
// }) })
//
// g.It("cannot rename a file to a location outside the directory root", func() { g.It("cannot rename a file to a location outside the directory root", func() {
// rfs.CreateServerFile("my_file.txt", "internal content") rfs.CreateServerFile("my_file.txt", "internal content")
//
// err := fs.Rename("my_file.txt", "external_dir/my_file.txt") err := fs.Rename("my_file.txt", "external_dir/my_file.txt")
// g.Assert(err).IsNotNil() g.Assert(err).IsNotNil()
// g.Assert(IsBadPathResolutionError(err)).IsTrue() g.Assert(IsBadPathResolutionError(err)).IsTrue()
// }) })
// }) })
//
// g.Describe("Chown", func() { g.Describe("Chown", func() {
// g.It("cannot chown a file symlinked outside the directory root", func() { g.It("cannot chown a file symlinked outside the directory root", func() {
// err := fs.Chown("symlinked.txt") err := fs.Chown("symlinked.txt")
// g.Assert(err).IsNotNil() g.Assert(err).IsNotNil()
// g.Assert(IsBadPathResolutionError(err)).IsTrue() g.Assert(IsBadPathResolutionError(err)).IsTrue()
// }) })
//
// g.It("cannot chown a directory symlinked outside the directory root", func() { g.It("cannot chown a directory symlinked outside the directory root", func() {
// err := fs.Chown("external_dir") err := fs.Chown("external_dir")
// g.Assert(err).IsNotNil() g.Assert(err).IsNotNil()
// g.Assert(IsBadPathResolutionError(err)).IsTrue() g.Assert(IsBadPathResolutionError(err)).IsTrue()
// }) })
// }) })
//
// g.Describe("Copy", func() { g.Describe("Copy", func() {
// g.It("cannot copy a file symlinked outside the directory root", func() { g.It("cannot copy a file symlinked outside the directory root", func() {
// err := fs.Copy("symlinked.txt") err := fs.Copy("symlinked.txt")
// g.Assert(err).IsNotNil() g.Assert(err).IsNotNil()
// fmt.Printf("err: %+v\n", err) g.Assert(IsBadPathResolutionError(err)).IsTrue()
// g.Assert(IsBadPathResolutionError(err)).IsTrue() })
// }) })
// })
// g.Describe("Delete", func() {
// g.Describe("Delete", func() { g.It("deletes the symlinked file but leaves the source", func() {
// g.It("deletes the symlinked file but leaves the source", func() { err := fs.Delete("symlinked.txt")
// err := fs.Delete("symlinked.txt") g.Assert(err).IsNil()
// g.Assert(err).IsNil()
// _, err = os.Stat(filepath.Join(rfs.root, "malicious.txt"))
// _, err = os.Stat(filepath.Join(rfs.root, "malicious.txt")) g.Assert(err).IsNil()
// g.Assert(err).IsNil()
// _, err = rfs.StatServerFile("symlinked.txt")
// _, err = rfs.StatServerFile("symlinked.txt") g.Assert(err).IsNotNil()
// g.Assert(err).IsNotNil() g.Assert(errors.Is(err, os.ErrNotExist)).IsTrue()
// g.Assert(errors.Is(err, os.ErrNotExist)).IsTrue() })
// }) })
// })
rfs.reset() rfs.reset()
} }