summaryrefslogtreecommitdiff
path: root/go/internal/command/uploadpack/uploadpack_test.go
diff options
context:
space:
mode:
authorIgor <idrozdov@gitlab.com>2019-06-03 15:21:25 +0000
committerNick Thomas <nick@gitlab.com>2019-06-03 15:21:25 +0000
commitcde5b73cb8776c70c6d00ff34c568ea4438bcba9 (patch)
treeddc0d81da81ebfdb2c05819c88cde2c56dbaf4d5 /go/internal/command/uploadpack/uploadpack_test.go
parentbeb5855542645cdc9bf7f954b9c5a9333dfb3975 (diff)
downloadgitlab-shell-cde5b73cb8776c70c6d00ff34c568ea4438bcba9.tar.gz
Go implementation for git-upload-pack
Diffstat (limited to 'go/internal/command/uploadpack/uploadpack_test.go')
-rw-r--r--go/internal/command/uploadpack/uploadpack_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/go/internal/command/uploadpack/uploadpack_test.go b/go/internal/command/uploadpack/uploadpack_test.go
new file mode 100644
index 0000000..a06ba24
--- /dev/null
+++ b/go/internal/command/uploadpack/uploadpack_test.go
@@ -0,0 +1,31 @@
+package uploadpack
+
+import (
+ "bytes"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+
+ "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/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 := requesthandlers.BuildDisallowedByApiHandlers(t)
+ url, cleanup := testserver.StartHttpServer(t, requests)
+ defer cleanup()
+
+ output := &bytes.Buffer{}
+
+ cmd := &Command{
+ Config: &config.Config{GitlabUrl: url},
+ Args: &commandargs.CommandArgs{GitlabKeyId: "disallowed", SshArgs: []string{"git-upload-pack", "group/repo"}},
+ ReadWriter: &readwriter.ReadWriter{ErrOut: output, Out: output},
+ }
+
+ err := cmd.Execute()
+ require.Equal(t, "Disallowed by API call", err.Error())
+}