summaryrefslogtreecommitdiff
path: root/internal/command/receivepack/receivepack_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/command/receivepack/receivepack_test.go')
-rw-r--r--internal/command/receivepack/receivepack_test.go22
1 files changed, 18 insertions, 4 deletions
diff --git a/internal/command/receivepack/receivepack_test.go b/internal/command/receivepack/receivepack_test.go
index 1d7bd21..d464e35 100644
--- a/internal/command/receivepack/receivepack_test.go
+++ b/internal/command/receivepack/receivepack_test.go
@@ -15,18 +15,32 @@ import (
func TestForbiddenAccess(t *testing.T) {
requests := requesthandlers.BuildDisallowedByApiHandlers(t)
- url, cleanup := testserver.StartHttpServer(t, requests)
+ cmd, _, cleanup := setup(t, "disallowed", requests)
defer cleanup()
+ err := cmd.Execute()
+ require.Equal(t, "Disallowed by API call", err.Error())
+}
+
+func TestCustomReceivePack(t *testing.T) {
+ cmd, output, cleanup := setup(t, "1", requesthandlers.BuildAllowedWithCustomActionsHandlers(t))
+ defer cleanup()
+
+ require.NoError(t, cmd.Execute())
+ require.Equal(t, "customoutput", output.String())
+}
+
+func setup(t *testing.T, keyId string, requests []testserver.TestRequestHandler) (*Command, *bytes.Buffer, func()) {
+ url, cleanup := testserver.StartSocketHttpServer(t, requests)
+
output := &bytes.Buffer{}
input := bytes.NewBufferString("input")
cmd := &Command{
Config: &config.Config{GitlabUrl: url},
- Args: &commandargs.Shell{GitlabKeyId: "disallowed", SshArgs: []string{"git-receive-pack", "group/repo"}},
+ Args: &commandargs.Shell{GitlabKeyId: keyId, SshArgs: []string{"git-receive-pack", "group/repo"}},
ReadWriter: &readwriter.ReadWriter{ErrOut: output, Out: output, In: input},
}
- err := cmd.Execute()
- require.Equal(t, "Disallowed by API call", err.Error())
+ return cmd, output, cleanup
}