Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-11-09 19:11:02 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-11-14 11:07:31 +0300
commitdfddef3962b8d0b24cfe9591158c37f654cab925 (patch)
tree00d5cc5de371123c58d54365b8fa97512443c3cc
parentefe4cb58115169a628fb777b3d9581d3f64c9c71 (diff)
praefect: Refactor auth tests to use `grpc_testing` gRPC service
The tests for our Praefect authentication use a custom gRPC service definition to assert its behaviour. This is not necessary though as we can simply use a mock repository service. Refactor the test to remove one more dependency on the mock service.
-rw-r--r--internal/praefect/auth_test.go14
1 files changed, 5 insertions, 9 deletions
diff --git a/internal/praefect/auth_test.go b/internal/praefect/auth_test.go
index 72edb9862..ceecf6713 100644
--- a/internal/praefect/auth_test.go
+++ b/internal/praefect/auth_test.go
@@ -13,7 +13,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config/auth"
"gitlab.com/gitlab-org/gitaly/v15/internal/praefect/config"
"gitlab.com/gitlab-org/gitaly/v15/internal/praefect/datastore"
- "gitlab.com/gitlab-org/gitaly/v15/internal/praefect/mock"
"gitlab.com/gitlab-org/gitaly/v15/internal/praefect/nodes"
"gitlab.com/gitlab-org/gitaly/v15/internal/praefect/protoregistry"
"gitlab.com/gitlab-org/gitaly/v15/internal/praefect/transactions"
@@ -61,9 +60,9 @@ func TestAuthFailures(t *testing.T) {
require.NoError(t, err, tc.desc)
defer conn.Close()
- cli := mock.NewSimpleServiceClient(conn)
+ cli := gitalypb.NewRepositoryServiceClient(conn)
- _, err = cli.RepoAccessorUnary(ctx, &mock.RepoRequest{})
+ _, err = cli.RepositoryExists(ctx, &gitalypb.RepositoryExistsRequest{})
testhelper.RequireGrpcCode(t, err, tc.code)
})
}
@@ -133,7 +132,7 @@ func dial(serverSocketPath string, opts []grpc.DialOption) (*grpc.ClientConn, er
func runServer(t *testing.T, token string, required bool) (*grpc.Server, string, func()) {
backendToken := "abcxyz"
backend, cleanup := newMockDownstream(t, backendToken, func(srv *grpc.Server) {
- mock.RegisterSimpleServiceServer(srv, &mockSvc{})
+ gitalypb.RegisterRepositoryServiceServer(srv, &gitalypb.UnimplementedRepositoryServiceServer{})
})
conf := config.Config{
@@ -160,12 +159,9 @@ func runServer(t *testing.T, token string, required bool) (*grpc.Server, string,
txMgr := transactions.NewManager(conf)
- registry, err := protoregistry.NewFromPaths("praefect/mock/mock.proto")
- require.NoError(t, err)
-
- coordinator := NewCoordinator(queue, nil, NewNodeManagerRouter(nodeMgr, nil), txMgr, conf, registry)
+ coordinator := NewCoordinator(queue, nil, NewNodeManagerRouter(nodeMgr, nil), txMgr, conf, protoregistry.GitalyProtoPreregistered)
- srv := NewGRPCServer(conf, logEntry, registry, coordinator.StreamDirector, txMgr, nil, nil, nil, nil, nil, nil)
+ srv := NewGRPCServer(conf, logEntry, protoregistry.GitalyProtoPreregistered, coordinator.StreamDirector, txMgr, nil, nil, nil, nil, nil, nil)
serverSocketPath := testhelper.GetTemporaryGitalySocketFileName(t)