diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /workhorse/internal/upload/uploads_test.go | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'workhorse/internal/upload/uploads_test.go')
-rw-r--r-- | workhorse/internal/upload/uploads_test.go | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/workhorse/internal/upload/uploads_test.go b/workhorse/internal/upload/uploads_test.go index 0885f31d5a4..d77d73b5f48 100644 --- a/workhorse/internal/upload/uploads_test.go +++ b/workhorse/internal/upload/uploads_test.go @@ -325,14 +325,20 @@ func TestInvalidFileNames(t *testing.T) { defer os.RemoveAll(tempPath) for _, testCase := range []struct { - filename string - code int + filename string + code int + FeatureFlagExtractBase bool + expectedPrefix string }{ - {"foobar", 200}, // sanity check for test setup below - {"foo/bar", 500}, - {"/../../foobar", 500}, - {".", 500}, - {"..", 500}, + {"foobar", 200, false, "foobar"}, // sanity check for test setup below + {"foo/bar", 500, false, ""}, + {"foo/bar", 200, true, "bar"}, + {"foo/bar/baz", 200, true, "baz"}, + {"/../../foobar", 500, false, ""}, + {"/../../foobar", 200, true, "foobar"}, + {".", 500, false, ""}, + {"..", 500, false, ""}, + {"./", 500, false, ""}, } { buffer := &bytes.Buffer{} @@ -350,10 +356,12 @@ func TestInvalidFileNames(t *testing.T) { apiResponse := &api.Response{TempPath: tempPath} preparer := &DefaultPreparer{} opts, _, err := preparer.Prepare(apiResponse) + opts.FeatureFlagExtractBase = testCase.FeatureFlagExtractBase require.NoError(t, err) HandleFileUploads(response, httpRequest, nilHandler, apiResponse, &SavedFileTracker{Request: httpRequest}, opts) require.Equal(t, testCase.code, response.Code) + require.Equal(t, testCase.expectedPrefix, opts.TempFilePrefix) } } |