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-07-28 14:23:19 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-08-01 07:34:57 +0300
commitd5fc739d1677ce42f37c9cb74aceb271aec75a64 (patch)
treedf88c6f33bd5f225192f8cd3821fa07121f110b1
parent78e9a9cc83102f2a608a353d7739d2bec2dd47f4 (diff)
ssh: Get rid of some seeded repositories in our tests
Get rid of some trivial cases where we can get rid of seeded repos in our SSHReceivePack tests.
-rw-r--r--internal/gitaly/service/ssh/receive_pack_test.go52
1 files changed, 15 insertions, 37 deletions
diff --git a/internal/gitaly/service/ssh/receive_pack_test.go b/internal/gitaly/service/ssh/receive_pack_test.go
index 695654a5f..4c604c569 100644
--- a/internal/gitaly/service/ssh/receive_pack_test.go
+++ b/internal/gitaly/service/ssh/receive_pack_test.go
@@ -124,21 +124,17 @@ func TestReceivePack_validation(t *testing.T) {
func TestReceivePack_success(t *testing.T) {
t.Parallel()
+ ctx := testhelper.Context(t)
cfg := testcfg.Build(t)
-
cfg.GitlabShell.Dir = "/foo/bar/gitlab-shell"
gitCmdFactory, hookOutputFile := gittest.CaptureHookEnv(t, cfg)
-
testcfg.BuildGitalySSH(t, cfg)
cfg.SocketPath = runSSHServer(t, cfg, testserver.WithGitCommandFactory(gitCmdFactory))
- ctx := testhelper.Context(t)
- repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- Seed: gittest.SeedGitLabTest,
- RelativePath: "gitlab-test-ssh-receive-pack.git",
- })
+ repo, repoPath := gittest.CreateRepository(ctx, t, cfg)
+ gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"))
glRepository := "project-456"
glProjectPath := "project/path"
@@ -219,9 +215,8 @@ func TestReceive_gitProtocol(t *testing.T) {
cfg.SocketPath = runSSHServer(t, cfg, testserver.WithGitCommandFactory(protocolDetectingFactory))
- repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- Seed: gittest.SeedGitLabTest,
- })
+ repo, repoPath := gittest.CreateRepository(ctx, t, cfg)
+ gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"))
lHead, rHead, err := testCloneAndPush(ctx, t, cfg, cfg.SocketPath, repo, repoPath, pushParams{
storageName: testhelper.DefaultStorageName,
@@ -230,8 +225,7 @@ func TestReceive_gitProtocol(t *testing.T) {
gitProtocol: git.ProtocolV2,
})
require.NoError(t, err)
-
- require.Equal(t, lHead, rHead, "local and remote head not equal. push failed")
+ require.Equal(t, lHead, rHead)
envData := protocolDetectingFactory.ReadProtocol(t)
require.Contains(t, envData, fmt.Sprintf("GIT_PROTOCOL=%s\n", git.ProtocolV2))
@@ -272,17 +266,15 @@ func TestReceivePack_failure(t *testing.T) {
func TestReceivePack_hookFailure(t *testing.T) {
t.Parallel()
+ ctx := testhelper.Context(t)
cfg := testcfg.Build(t)
gitCmdFactory := gittest.NewCommandFactory(t, cfg, git.WithHooksPath(testhelper.TempDir(t)))
testcfg.BuildGitalySSH(t, cfg)
cfg.SocketPath = runSSHServer(t, cfg, testserver.WithGitCommandFactory(gitCmdFactory))
- ctx := testhelper.Context(t)
- repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- Seed: gittest.SeedGitLabTest,
- })
+ repo, repoPath := gittest.CreateRepository(ctx, t, cfg)
hookContent := []byte("#!/bin/sh\nexit 1")
require.NoError(t, os.WriteFile(filepath.Join(gitCmdFactory.HooksPath(ctx), "pre-receive"), hookContent, 0o755))
@@ -295,18 +287,14 @@ func TestReceivePack_hookFailure(t *testing.T) {
func TestReceivePack_customHookFailure(t *testing.T) {
t.Parallel()
+ ctx := testhelper.Context(t)
cfg := testcfg.Build(t)
- gitCmdFactory := gittest.NewCommandFactory(t, cfg)
+ cfg.SocketPath = runSSHServer(t, cfg)
testcfg.BuildGitalySSH(t, cfg)
testcfg.BuildGitalyHooks(t, cfg)
- cfg.SocketPath = runSSHServer(t, cfg, testserver.WithGitCommandFactory(gitCmdFactory))
- ctx := testhelper.Context(t)
-
- repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- Seed: gittest.SeedGitLabTest,
- })
+ repo, repoPath := gittest.CreateRepository(ctx, t, cfg)
cloneDetails, cleanup := setupSSHClone(t, cfg, repo, repoPath)
defer cleanup()
@@ -325,7 +313,6 @@ func TestReceivePack_customHookFailure(t *testing.T) {
require.NoError(t, err)
stderr, err := cmd.StderrPipe()
require.NoError(t, err)
-
require.NoError(t, cmd.Start())
c, err := io.Copy(io.Discard, stdout)
@@ -339,23 +326,19 @@ func TestReceivePack_customHookFailure(t *testing.T) {
require.Contains(t, string(slurpErr), "remote: this is wrong")
require.Contains(t, string(slurpErr), "(pre-receive hook declined)")
-
require.NotContains(t, string(slurpErr), "final transactional vote: transaction was stopped")
}
func TestReceivePack_hidesObjectPoolReferences(t *testing.T) {
t.Parallel()
+ ctx := testhelper.Context(t)
cfg := testcfg.Build(t)
+ cfg.SocketPath = runSSHServer(t, cfg)
testcfg.BuildGitalyHooks(t, cfg)
- cfg.SocketPath = runSSHServer(t, cfg)
-
- ctx := testhelper.Context(t)
- repoProto, _ := gittest.CreateRepository(testhelper.Context(t), t, cfg, gittest.CreateRepositoryConfig{
- Seed: gittest.SeedGitLabTest,
- })
+ repoProto, _ := gittest.CreateRepository(ctx, t, cfg)
repo := localrepo.NewTestRepo(t, cfg, repoProto)
txManager := transaction.NewManager(cfg, backchannel.NewRegistry())
@@ -375,16 +358,13 @@ func TestReceivePack_hidesObjectPoolReferences(t *testing.T) {
gittest.NewObjectPoolName(t),
)
require.NoError(t, err)
-
require.NoError(t, pool.Create(ctx, repo))
-
require.NoError(t, pool.Link(ctx, repo))
commitID := gittest.WriteCommit(t, cfg, pool.FullPath(), gittest.WithBranch(t.Name()))
// First request
require.NoError(t, stream.Send(&gitalypb.SSHReceivePackRequest{Repository: repoProto, GlId: "user-123"}))
-
require.NoError(t, stream.Send(&gitalypb.SSHReceivePackRequest{Stdin: []byte("0000")}))
require.NoError(t, stream.CloseSend())
@@ -621,9 +601,7 @@ func TestReceivePack_objectExistsHook(t *testing.T) {
protocolDetectingFactory := gittest.NewProtocolDetectingCommandFactory(ctx, t, cfg)
cfg.SocketPath = runSSHServer(t, cfg, testserver.WithGitCommandFactory(protocolDetectingFactory))
- repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- Seed: gittest.SeedGitLabTest,
- })
+ repo, repoPath := gittest.CreateRepository(ctx, t, cfg)
tempGitlabShellDir := testhelper.TempDir(t)