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:
Diffstat (limited to 'internal/gitaly/service/smarthttp/inforefs_test.go')
-rw-r--r--internal/gitaly/service/smarthttp/inforefs_test.go123
1 files changed, 92 insertions, 31 deletions
diff --git a/internal/gitaly/service/smarthttp/inforefs_test.go b/internal/gitaly/service/smarthttp/inforefs_test.go
index 9b371bf7f..f722cc14b 100644
--- a/internal/gitaly/service/smarthttp/inforefs_test.go
+++ b/internal/gitaly/service/smarthttp/inforefs_test.go
@@ -37,10 +37,14 @@ import (
func TestInfoRefsUploadPack_successful(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.UploadPackHideRefs).Run(t, testInfoRefsUploadPackSuccessful)
+}
+
+func testInfoRefsUploadPackSuccessful(t *testing.T, ctx context.Context) {
+ t.Parallel()
cfg := testcfg.Build(t)
cfg.SocketPath = runSmartHTTPServer(t, cfg)
- ctx := testhelper.Context(t)
repo, repoPath := gittest.CreateRepository(ctx, t, cfg)
@@ -62,10 +66,14 @@ func TestInfoRefsUploadPack_successful(t *testing.T) {
func TestInfoRefsUploadPack_internalRefs(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.UploadPackHideRefs).Run(t, testInfoRefsUploadPackInternalRefs)
+}
+
+func testInfoRefsUploadPackInternalRefs(t *testing.T, ctx context.Context) {
+ t.Parallel()
cfg := testcfg.Build(t)
cfg.SocketPath = runSmartHTTPServer(t, cfg)
- ctx := testhelper.Context(t)
for _, tc := range []struct {
ref string
@@ -97,17 +105,37 @@ func TestInfoRefsUploadPack_internalRefs(t *testing.T) {
},
{
ref: "refs/tmp/1",
- expectedAdvertisements: []string{
- "HEAD",
- "refs/heads/main\n",
- },
+ expectedAdvertisements: func() []string {
+ if featureflag.UploadPackHideRefs.IsDisabled(ctx) {
+ return []string{
+ "HEAD",
+ "refs/heads/main\n",
+ "refs/tmp/1\n",
+ }
+ }
+
+ return []string{
+ "HEAD",
+ "refs/heads/main\n",
+ }
+ }(),
},
{
ref: "refs/keep-around/1",
- expectedAdvertisements: []string{
- "HEAD",
- "refs/heads/main\n",
- },
+ expectedAdvertisements: func() []string {
+ if featureflag.UploadPackHideRefs.IsDisabled(ctx) {
+ return []string{
+ "HEAD",
+ "refs/heads/main\n",
+ "refs/keep-around/1\n",
+ }
+ }
+
+ return []string{
+ "HEAD",
+ "refs/heads/main\n",
+ }
+ }(),
},
} {
t.Run(tc.ref, func(t *testing.T) {
@@ -130,18 +158,21 @@ func TestInfoRefsUploadPack_internalRefs(t *testing.T) {
}
}
-func TestInfoRefsUploadPack_repositoryDoesntExist(t *testing.T) {
+func TestInfoRefsUploadPackRepositoryDoesntExist(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.UploadPackHideRefs).Run(t, testInfoRefsUploadPackRepositoryDoesntExist)
+}
- cfg := testcfg.Build(t)
+func testInfoRefsUploadPackRepositoryDoesntExist(t *testing.T, ctx context.Context) {
+ t.Parallel()
+ cfg := testcfg.Build(t)
serverSocketPath := runSmartHTTPServer(t, cfg)
rpcRequest := &gitalypb.InfoRefsRequest{Repository: &gitalypb.Repository{
StorageName: cfg.Storages[0].Name,
RelativePath: "doesnt/exist",
}}
- ctx := testhelper.Context(t)
_, err := makeInfoRefsUploadPackRequest(ctx, t, serverSocketPath, cfg.Auth.Token, rpcRequest)
@@ -153,13 +184,16 @@ func TestInfoRefsUploadPack_repositoryDoesntExist(t *testing.T) {
testhelper.RequireGrpcError(t, expectedErr, err)
}
-func TestInfoRefsUploadPack_partialClone(t *testing.T) {
+func TestInfoRefsUploadPackPartialClone(t *testing.T) {
t.Parallel()
+ testhelper.NewFeatureSets(featureflag.UploadPackHideRefs).Run(t, testInfoRefsUploadPackPartialClone)
+}
- cfg := testcfg.Build(t)
+func testInfoRefsUploadPackPartialClone(t *testing.T, ctx context.Context) {
+ t.Parallel()
+ cfg := testcfg.Build(t)
cfg.SocketPath = runSmartHTTPServer(t, cfg)
- ctx := testhelper.Context(t)
repo, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
Seed: gittest.SeedGitLabTest,
@@ -180,13 +214,17 @@ func TestInfoRefsUploadPack_partialClone(t *testing.T) {
}
}
-func TestInfoRefsUploadPack_gitConfigOptions(t *testing.T) {
+func TestInfoRefsUploadPackGitConfigOptions(t *testing.T) {
+ t.Parallel()
+ testhelper.NewFeatureSets(featureflag.UploadPackHideRefs).Run(t, testInfoRefsUploadPackGitConfigOptions)
+}
+
+func testInfoRefsUploadPackGitConfigOptions(t *testing.T, ctx context.Context) {
t.Parallel()
cfg := testcfg.Build(t)
cfg.SocketPath = runSmartHTTPServer(t, cfg)
- ctx := testhelper.Context(t)
repo, repoPath := gittest.CreateRepository(ctx, t, cfg)
commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"), gittest.WithParents())
@@ -204,11 +242,15 @@ func TestInfoRefsUploadPack_gitConfigOptions(t *testing.T) {
})
}
-func TestInfoRefsUploadPack_gitProtocol(t *testing.T) {
+func TestInfoRefsUploadPackGitProtocol(t *testing.T) {
+ t.Parallel()
+ testhelper.NewFeatureSets(featureflag.UploadPackHideRefs).Run(t, testInfoRefsUploadPackGitProtocol)
+}
+
+func testInfoRefsUploadPackGitProtocol(t *testing.T, ctx context.Context) {
t.Parallel()
cfg := testcfg.Build(t)
- ctx := testhelper.Context(t)
protocolDetectingFactory := gittest.NewProtocolDetectingCommandFactory(ctx, t, cfg)
@@ -262,12 +304,16 @@ func makeInfoRefsUploadPackRequest(ctx context.Context, t *testing.T, serverSock
return response, err
}
-func TestInfoRefsReceivePack_successful(t *testing.T) {
+func TestInfoRefsReceivePackSuccessful(t *testing.T) {
+ t.Parallel()
+ testhelper.NewFeatureSets(featureflag.UploadPackHideRefs).Run(t, testInfoRefsReceivePackSuccessful)
+}
+
+func testInfoRefsReceivePackSuccessful(t *testing.T, ctx context.Context) {
t.Parallel()
cfg := testcfg.Build(t)
cfg.SocketPath = runSmartHTTPServer(t, cfg)
- ctx := testhelper.Context(t)
repo, repoPath := gittest.CreateRepository(ctx, t, cfg)
@@ -287,7 +333,12 @@ func TestInfoRefsReceivePack_successful(t *testing.T) {
})
}
-func TestInfoRefsReceivePack_hiddenRefs(t *testing.T) {
+func TestInfoRefsReceivePackHiddenRefs(t *testing.T) {
+ t.Parallel()
+ testhelper.NewFeatureSets(featureflag.UploadPackHideRefs).Run(t, testInfoRefsReceivePackHiddenRefs)
+}
+
+func testInfoRefsReceivePackHiddenRefs(t *testing.T, ctx context.Context) {
t.Parallel()
cfg := testcfg.Build(t)
@@ -295,7 +346,6 @@ func TestInfoRefsReceivePack_hiddenRefs(t *testing.T) {
testcfg.BuildGitalyHooks(t, cfg)
cfg.SocketPath = runSmartHTTPServer(t, cfg)
- ctx := testhelper.Context(t)
repoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
Seed: gittest.SeedGitLabTest,
@@ -330,7 +380,12 @@ func TestInfoRefsReceivePack_hiddenRefs(t *testing.T) {
require.NotContains(t, string(response), commitID+" .have")
}
-func TestInfoRefsReceivePack_repoNotFound(t *testing.T) {
+func TestInfoRefsReceivePackRepoNotFound(t *testing.T) {
+ t.Parallel()
+ testhelper.NewFeatureSets(featureflag.UploadPackHideRefs).Run(t, testInfoRefsReceivePackRepoNotFound)
+}
+
+func testInfoRefsReceivePackRepoNotFound(t *testing.T, ctx context.Context) {
t.Parallel()
cfg := testcfg.Build(t)
@@ -339,7 +394,6 @@ func TestInfoRefsReceivePack_repoNotFound(t *testing.T) {
repo := &gitalypb.Repository{StorageName: cfg.Storages[0].Name, RelativePath: "testdata/scratch/another_repo"}
rpcRequest := &gitalypb.InfoRefsRequest{Repository: repo}
- ctx := testhelper.Context(t)
_, err := makeInfoRefsReceivePackRequest(ctx, t, serverSocketPath, cfg.Auth.Token, rpcRequest)
expectedErr := helper.ErrNotFoundf(`GetRepoPath: not a git repository: "` + cfg.Storages[0].Path + "/" + repo.RelativePath + `"`)
@@ -350,7 +404,12 @@ func TestInfoRefsReceivePack_repoNotFound(t *testing.T) {
testhelper.RequireGrpcError(t, expectedErr, err)
}
-func TestInfoRefsReceivePack_repoNotSet(t *testing.T) {
+func TestInfoRefsReceivePackRepoNotSet(t *testing.T) {
+ t.Parallel()
+ testhelper.NewFeatureSets(featureflag.UploadPackHideRefs).Run(t, testInfoRefsReceivePackRepoNotSet)
+}
+
+func testInfoRefsReceivePackRepoNotSet(t *testing.T, ctx context.Context) {
t.Parallel()
cfg := testcfg.Build(t)
@@ -358,7 +417,6 @@ func TestInfoRefsReceivePack_repoNotSet(t *testing.T) {
serverSocketPath := runSmartHTTPServer(t, cfg)
rpcRequest := &gitalypb.InfoRefsRequest{}
- ctx := testhelper.Context(t)
_, err := makeInfoRefsReceivePackRequest(ctx, t, serverSocketPath, cfg.Auth.Token, rpcRequest)
testhelper.RequireGrpcCode(t, err, codes.InvalidArgument)
}
@@ -418,7 +476,12 @@ func (ms *mockStreamer) PutStream(ctx context.Context, repo *gitalypb.Repository
return ms.Streamer.PutStream(ctx, repo, req, src)
}
-func TestInfoRefsUploadPack_cache(t *testing.T) {
+func TestInfoRefsUploadPackCache(t *testing.T) {
+ t.Parallel()
+ testhelper.NewFeatureSets(featureflag.UploadPackHideRefs).Run(t, testInfoRefsUploadPackCache)
+}
+
+func testInfoRefsUploadPackCache(t *testing.T, ctx context.Context) {
t.Parallel()
cfg := testcfg.Build(t)
@@ -434,8 +497,6 @@ func TestInfoRefsUploadPack_cache(t *testing.T) {
gitalyServer := startSmartHTTPServer(t, cfg, withInfoRefCache(mockInfoRefCache))
cfg.SocketPath = gitalyServer.Address()
- ctx := testhelper.Context(t)
-
repo, repoPath := gittest.CreateRepository(ctx, t, cfg)
commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"), gittest.WithParents())