diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-10-03 14:50:23 +0300 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-10-04 15:12:35 +0300 |
commit | 5c1e296eb7e90e54541613fefac4f242f055bf37 (patch) | |
tree | cb904eb88b19b373a0df57d0c59a25b641bbf146 /internal/helper/repo_test.go | |
parent | fa3e2a029b7f758a099e64c407c08588c41c3196 (diff) |
Rename gitaly proto import to gitalypb
This change the result of a grep + sed, to move away from pb, and use
gitalypb instead. The gitalypb points to a vendorred directory that has
the same name. This would fix the use of goimports.
See also: https://gitlab.com/gitlab-org/gitaly-proto/merge_requests/213
Diffstat (limited to 'internal/helper/repo_test.go')
-rw-r--r-- | internal/helper/repo_test.go | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/internal/helper/repo_test.go b/internal/helper/repo_test.go index 53188000e..037831f23 100644 --- a/internal/helper/repo_test.go +++ b/internal/helper/repo_test.go @@ -5,11 +5,10 @@ import ( "path" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/assert" "google.golang.org/grpc/codes" ) @@ -34,19 +33,19 @@ func TestGetRepoPath(t *testing.T) { testCases := []struct { desc string storages []config.Storage - repo *pb.Repository + repo *gitalypb.Repository path string err codes.Code }{ { desc: "storages configured", storages: exampleStorages, - repo: &pb.Repository{StorageName: "default", RelativePath: testhelper.TestRelativePath}, + repo: &gitalypb.Repository{StorageName: "default", RelativePath: testhelper.TestRelativePath}, path: repoPath, }, { desc: "no storage config, storage name provided", - repo: &pb.Repository{StorageName: "does not exist", RelativePath: testhelper.TestRelativePath}, + repo: &gitalypb.Repository{StorageName: "does not exist", RelativePath: testhelper.TestRelativePath}, err: codes.InvalidArgument, }, { @@ -56,66 +55,66 @@ func TestGetRepoPath(t *testing.T) { { desc: "storage config provided, empty repo", storages: exampleStorages, - repo: &pb.Repository{}, + repo: &gitalypb.Repository{}, err: codes.InvalidArgument, }, { desc: "no storage config, empty repo", - repo: &pb.Repository{}, + repo: &gitalypb.Repository{}, err: codes.InvalidArgument, }, { desc: "non existing repo", storages: exampleStorages, - repo: &pb.Repository{StorageName: "default", RelativePath: "made/up/path.git"}, + repo: &gitalypb.Repository{StorageName: "default", RelativePath: "made/up/path.git"}, err: codes.NotFound, }, { desc: "non existing storage", storages: exampleStorages, - repo: &pb.Repository{StorageName: "does not exists", RelativePath: testhelper.TestRelativePath}, + repo: &gitalypb.Repository{StorageName: "does not exists", RelativePath: testhelper.TestRelativePath}, err: codes.InvalidArgument, }, { desc: "storage defined but storage dir does not exist", storages: []config.Storage{{Name: "default", Path: "/does/not/exist"}}, - repo: &pb.Repository{StorageName: "default", RelativePath: "foobar.git"}, + repo: &gitalypb.Repository{StorageName: "default", RelativePath: "foobar.git"}, err: codes.Internal, }, { desc: "relative path with directory traversal", storages: exampleStorages, - repo: &pb.Repository{StorageName: "default", RelativePath: "../bazqux.git"}, + repo: &gitalypb.Repository{StorageName: "default", RelativePath: "../bazqux.git"}, err: codes.InvalidArgument, }, { desc: "valid path with ..", storages: exampleStorages, - repo: &pb.Repository{StorageName: "default", RelativePath: "foo../bazqux.git"}, + repo: &gitalypb.Repository{StorageName: "default", RelativePath: "foo../bazqux.git"}, err: codes.NotFound, // Because the directory doesn't exist }, { desc: "relative path with sneaky directory traversal", storages: exampleStorages, - repo: &pb.Repository{StorageName: "default", RelativePath: "/../bazqux.git"}, + repo: &gitalypb.Repository{StorageName: "default", RelativePath: "/../bazqux.git"}, err: codes.InvalidArgument, }, { desc: "relative path with one level traversal at the end", storages: exampleStorages, - repo: &pb.Repository{StorageName: "default", RelativePath: testhelper.TestRelativePath + "/.."}, + repo: &gitalypb.Repository{StorageName: "default", RelativePath: testhelper.TestRelativePath + "/.."}, err: codes.InvalidArgument, }, { desc: "relative path with one level dashed traversal at the end", storages: exampleStorages, - repo: &pb.Repository{StorageName: "default", RelativePath: testhelper.TestRelativePath + "/../"}, + repo: &gitalypb.Repository{StorageName: "default", RelativePath: testhelper.TestRelativePath + "/../"}, err: codes.InvalidArgument, }, { desc: "relative path with deep traversal at the end", storages: exampleStorages, - repo: &pb.Repository{StorageName: "default", RelativePath: "bazqux.git/../.."}, + repo: &gitalypb.Repository{StorageName: "default", RelativePath: "bazqux.git/../.."}, err: codes.InvalidArgument, }, } @@ -140,7 +139,7 @@ func TestGetRepoPath(t *testing.T) { } } -func assertInvalidRepoWithoutFile(t *testing.T, repo *pb.Repository, repoPath, file string) { +func assertInvalidRepoWithoutFile(t *testing.T, repo *gitalypb.Repository, repoPath, file string) { oldRoute := path.Join(repoPath, file) renamedRoute := path.Join(repoPath, file+"moved") os.Rename(oldRoute, renamedRoute) |