From ba53cc4c51e6e0d963c36ca8a3eb78018227bd98 Mon Sep 17 00:00:00 2001 From: HD Moore Date: Sun, 25 Aug 2019 20:23:06 -0500 Subject: [PATCH] Improve test cases for file resolution (#233) --- v2/box_test.go | 8 ++++---- v2/file/resolver/disk.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/v2/box_test.go b/v2/box_test.go index 41477f5..75fc8c4 100644 --- a/v2/box_test.go +++ b/v2/box_test.go @@ -227,27 +227,27 @@ func Test_Box_HasDir(t *testing.T) { func Test_Box_Traversal_Standard(t *testing.T) { r := require.New(t) box := New("Test_Box_Traversal_Standard", "") - _, err := box.FindString("../go.mod") + _, err := box.FindString("../fixtures/hello.txt") r.Error(err) } func Test_Box_Traversal_Standard_Depth2(t *testing.T) { r := require.New(t) box := New("Test_Box_Traversal_Standard_Depth2", "") - _, err := box.FindString("../../packr/go.mod") + _, err := box.FindString("../../packr/fixtures/hello.txt") r.Error(err) } func Test_Box_Traversal_Backslash(t *testing.T) { r := require.New(t) box := New("Test_Box_Traversal_Backslash", "") - _, err := box.FindString("..\\go.mod") + _, err := box.FindString("..\\fixtures\\hello.txt") r.Error(err) } func Test_Box_Traversal_Backslash_Depth2(t *testing.T) { r := require.New(t) box := New("Test_Box_Traversal_Backslash_Depth2", "") - _, err := box.FindString("..\\..packr2\\go.mod") + _, err := box.FindString("..\\..\\packr2\\fixtures\\hello.txt") r.Error(err) } diff --git a/v2/file/resolver/disk.go b/v2/file/resolver/disk.go index 10b07c4..4367c8a 100644 --- a/v2/file/resolver/disk.go +++ b/v2/file/resolver/disk.go @@ -45,8 +45,8 @@ func (d *Disk) Resolve(box string, name string) (file.File, error) { return nil, os.ErrNotExist } -// resolvePathInBase returns a path that is guaranteed to be inside of the base directory or an error -func ResolvePathInBase(base string, path string) (string, error) { +// ResolvePathInBase returns a path that is guaranteed to be inside of the base directory or an error +func ResolvePathInBase(base, path string) (string, error) { // Determine the absolute file path of the base directory d, err := filepath.Abs(base) if err != nil {