You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

http_test.go 711B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2021 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package repo
  4. import (
  5. "testing"
  6. "github.com/stretchr/testify/assert"
  7. )
  8. func TestContainsParentDirectorySeparator(t *testing.T) {
  9. tests := []struct {
  10. v string
  11. b bool
  12. }{
  13. {
  14. v: `user2/repo1/info/refs`,
  15. b: false,
  16. },
  17. {
  18. v: `user2/repo1/HEAD`,
  19. b: false,
  20. },
  21. {
  22. v: `user2/repo1/some.../strange_file...mp3`,
  23. b: false,
  24. },
  25. {
  26. v: `user2/repo1/../../custom/conf/app.ini`,
  27. b: true,
  28. },
  29. {
  30. v: `user2/repo1/objects/info/..\..\..\..\custom\conf\app.ini`,
  31. b: true,
  32. },
  33. }
  34. for i := range tests {
  35. assert.EqualValues(t, tests[i].b, containsParentDirectorySeparator(tests[i].v))
  36. }
  37. }