diff options
author | Alessio Caiazza <376774-nolith@users.noreply.gitlab.com> | 2021-10-01 09:54:41 +0300 |
---|---|---|
committer | Alessio Caiazza <376774-nolith@users.noreply.gitlab.com> | 2021-10-01 09:54:41 +0300 |
commit | 81e6fdba4fa75b3e882cde818c25a2a76f531de7 (patch) | |
tree | 630098af5c75e5645a1eea93910de5c4fb104e97 /internal/httpfs/http_fs_test.go | |
parent | dee99f0074625c3b1dfe07aa477e159344f89ac2 (diff) | |
parent | aa333ba6e7c58fccb090318d4a2591a3cba645c6 (diff) |
Merge branch 'remove/chrootpath' into 'master'
refactor: clean up chrootPath from the httpfs package
Closes #598
See merge request gitlab-org/gitlab-pages!559
Diffstat (limited to 'internal/httpfs/http_fs_test.go')
-rw-r--r-- | internal/httpfs/http_fs_test.go | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/internal/httpfs/http_fs_test.go b/internal/httpfs/http_fs_test.go index cbdbc0e1..ce404a11 100644 --- a/internal/httpfs/http_fs_test.go +++ b/internal/httpfs/http_fs_test.go @@ -19,7 +19,6 @@ func TestFSOpen(t *testing.T) { tests := map[string]struct { allowedPaths []string - chrootPath string fileName string expectedContent string expectedErrMsg string @@ -59,23 +58,11 @@ func TestFSOpen(t *testing.T) { fileName: wd + "/../httpfs/testdata/file1.txt", expectedErrMsg: os.ErrPermission.Error(), }, - "chroot_path_not_found_when_not_in_real_chroot": { - allowedPaths: []string{wd + "/testdata"}, - fileName: wd + "/testdata/file1.txt", - expectedErrMsg: "no such file or directory", - chrootPath: wd + "/testdata", - }, - "chroot_path_empty_finds_file": { - allowedPaths: []string{wd + "/testdata"}, - fileName: wd + "/testdata/file1.txt", - expectedContent: "file1.txt\n", - chrootPath: "", - }, } for name, test := range tests { t.Run(name, func(t *testing.T) { - p, err := NewFileSystemPath(test.allowedPaths, test.chrootPath) + p, err := NewFileSystemPath(test.allowedPaths) require.NoError(t, err) got, err := p.Open(test.fileName) @@ -101,7 +88,6 @@ func TestFileSystemPathCanServeHTTP(t *testing.T) { tests := map[string]struct { path string - chrootPath string fileName string escapeURL bool expectedStatusCode int @@ -150,26 +136,12 @@ func TestFileSystemPathCanServeHTTP(t *testing.T) { expectedStatusCode: http.StatusForbidden, expectedContent: "403 Forbidden\n", }, - "chroot_path_fails_in_unit_test_not_found_when_not_in_real_chroot": { - path: wd + "/testdata", - fileName: "file1.txt", - chrootPath: wd + "/testdata", - expectedStatusCode: http.StatusNotFound, - expectedContent: "404 page not found\n", - }, - "chroot_path_empty_in_unit_test_file_found": { - path: wd + "/testdata", - fileName: "file1.txt", - chrootPath: "", - expectedStatusCode: http.StatusOK, - expectedContent: "file1.txt\n", - }, } for name, test := range tests { t.Run(name, func(t *testing.T) { transport := httptransport.NewTransport() - fs, err := NewFileSystemPath([]string{test.path}, test.chrootPath) + fs, err := NewFileSystemPath([]string{test.path}) require.NoError(t, err) transport.RegisterProtocol("file", http.NewFileTransport(fs)) |