summaryrefslogtreecommitdiff
path: root/go/internal/command/receivepack
diff options
context:
space:
mode:
Diffstat (limited to 'go/internal/command/receivepack')
-rw-r--r--go/internal/command/receivepack/gitalycall.go10
-rw-r--r--go/internal/command/receivepack/receivepack.go9
-rw-r--r--go/internal/command/receivepack/receivepack_test.go18
3 files changed, 5 insertions, 32 deletions
diff --git a/go/internal/command/receivepack/gitalycall.go b/go/internal/command/receivepack/gitalycall.go
index 22652d7..87ef9c5 100644
--- a/go/internal/command/receivepack/gitalycall.go
+++ b/go/internal/command/receivepack/gitalycall.go
@@ -20,16 +20,8 @@ func (c *Command) performGitalyCall(response *accessverifier.Response) error {
Token: response.Gitaly.Token,
}
- repo := response.Gitaly.Repo
request := &pb.SSHReceivePackRequest{
- Repository: &pb.Repository{
- StorageName: repo.StorageName,
- RelativePath: repo.RelativePath,
- GitObjectDirectory: repo.GitObjectDirectory,
- GitAlternateObjectDirectories: repo.GitAlternateObjectDirectories,
- GlRepository: repo.RepoName,
- GlProjectPath: repo.ProjectPath,
- },
+ Repository: &response.Gitaly.Repo,
GlId: response.UserId,
GlRepository: response.Repo,
GlUsername: response.Username,
diff --git a/go/internal/command/receivepack/receivepack.go b/go/internal/command/receivepack/receivepack.go
index d1ff3f8..d6b788c 100644
--- a/go/internal/command/receivepack/receivepack.go
+++ b/go/internal/command/receivepack/receivepack.go
@@ -1,18 +1,13 @@
package receivepack
import (
- "errors"
-
"gitlab.com/gitlab-org/gitlab-shell/go/internal/command/commandargs"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/command/readwriter"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/command/shared/accessverifier"
+ "gitlab.com/gitlab-org/gitlab-shell/go/internal/command/shared/disallowedcommand"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/config"
)
-var (
- disallowedCommandError = errors.New("> GitLab: Disallowed command")
-)
-
type Command struct {
Config *config.Config
Args *commandargs.CommandArgs
@@ -22,7 +17,7 @@ type Command struct {
func (c *Command) Execute() error {
args := c.Args.SshArgs
if len(args) != 2 {
- return disallowedCommandError
+ return disallowedcommand.Error
}
repo := args[1]
diff --git a/go/internal/command/receivepack/receivepack_test.go b/go/internal/command/receivepack/receivepack_test.go
index 874bac3..e5263f5 100644
--- a/go/internal/command/receivepack/receivepack_test.go
+++ b/go/internal/command/receivepack/receivepack_test.go
@@ -2,8 +2,6 @@ package receivepack
import (
"bytes"
- "encoding/json"
- "net/http"
"testing"
"github.com/stretchr/testify/require"
@@ -12,23 +10,11 @@ import (
"gitlab.com/gitlab-org/gitlab-shell/go/internal/command/readwriter"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/config"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/gitlabnet/testserver"
+ "gitlab.com/gitlab-org/gitlab-shell/go/internal/testhelper/requesthandlers"
)
func TestForbiddenAccess(t *testing.T) {
- requests := []testserver.TestRequestHandler{
- {
- Path: "/api/v4/internal/allowed",
- Handler: func(w http.ResponseWriter, r *http.Request) {
- body := map[string]interface{}{
- "status": false,
- "message": "Disallowed by API call",
- }
- w.WriteHeader(http.StatusForbidden)
- require.NoError(t, json.NewEncoder(w).Encode(body))
- },
- },
- }
-
+ requests := requesthandlers.BuildDisallowedByApiHandlers(t)
url, cleanup := testserver.StartHttpServer(t, requests)
defer cleanup()