diff options
author | Patrick Bajao <ebajao@gitlab.com> | 2019-07-29 15:59:23 +0800 |
---|---|---|
committer | Patrick Bajao <ebajao@gitlab.com> | 2019-07-31 12:03:43 +0800 |
commit | 592823d5e25006331b361b36cc61df7802fc1938 (patch) | |
tree | e5dfda205795e9526eb94866de65073cd6a83915 /go/internal/command | |
parent | 3b0176df497263323da2fae793a79b568502e6db (diff) | |
download | gitlab-shell-592823d5e25006331b361b36cc61df7802fc1938.tar.gz |
Rename CommandArgs to Shell
Other functions are still expecting for `CommandArgs` instead
of `Shell`. They should be expecting `commandargs.Shell` now
since it has been renamed.
Diffstat (limited to 'go/internal/command')
18 files changed, 37 insertions, 37 deletions
diff --git a/go/internal/command/discover/discover.go b/go/internal/command/discover/discover.go index 7d4ad2b..de94b56 100644 --- a/go/internal/command/discover/discover.go +++ b/go/internal/command/discover/discover.go @@ -11,7 +11,7 @@ import ( type Command struct { Config *config.Config - Args *commandargs.CommandArgs + Args *commandargs.Shell ReadWriter *readwriter.ReadWriter } diff --git a/go/internal/command/discover/discover_test.go b/go/internal/command/discover/discover_test.go index 284610a..7e052f7 100644 --- a/go/internal/command/discover/discover_test.go +++ b/go/internal/command/discover/discover_test.go @@ -49,27 +49,27 @@ func TestExecute(t *testing.T) { testCases := []struct { desc string - arguments *commandargs.CommandArgs + arguments *commandargs.Shell expectedOutput string }{ { desc: "With a known username", - arguments: &commandargs.CommandArgs{GitlabUsername: "alex-doe"}, + arguments: &commandargs.Shell{GitlabUsername: "alex-doe"}, expectedOutput: "Welcome to GitLab, @alex-doe!\n", }, { desc: "With a known key id", - arguments: &commandargs.CommandArgs{GitlabKeyId: "1"}, + arguments: &commandargs.Shell{GitlabKeyId: "1"}, expectedOutput: "Welcome to GitLab, @alex-doe!\n", }, { desc: "With an unknown key", - arguments: &commandargs.CommandArgs{GitlabKeyId: "-1"}, + arguments: &commandargs.Shell{GitlabKeyId: "-1"}, expectedOutput: "Welcome to GitLab, Anonymous!\n", }, { desc: "With an unknown username", - arguments: &commandargs.CommandArgs{GitlabUsername: "unknown"}, + arguments: &commandargs.Shell{GitlabUsername: "unknown"}, expectedOutput: "Welcome to GitLab, Anonymous!\n", }, } @@ -97,22 +97,22 @@ func TestFailingExecute(t *testing.T) { testCases := []struct { desc string - arguments *commandargs.CommandArgs + arguments *commandargs.Shell expectedError string }{ { desc: "With missing arguments", - arguments: &commandargs.CommandArgs{}, + arguments: &commandargs.Shell{}, expectedError: "Failed to get username: who='' is invalid", }, { desc: "When the API returns an error", - arguments: &commandargs.CommandArgs{GitlabUsername: "broken_message"}, + arguments: &commandargs.Shell{GitlabUsername: "broken_message"}, expectedError: "Failed to get username: Forbidden!", }, { desc: "When the API fails", - arguments: &commandargs.CommandArgs{GitlabUsername: "broken"}, + arguments: &commandargs.Shell{GitlabUsername: "broken"}, expectedError: "Failed to get username: Internal API error (500)", }, } diff --git a/go/internal/command/lfsauthenticate/lfsauthenticate.go b/go/internal/command/lfsauthenticate/lfsauthenticate.go index c1dc45f..bff5e7f 100644 --- a/go/internal/command/lfsauthenticate/lfsauthenticate.go +++ b/go/internal/command/lfsauthenticate/lfsauthenticate.go @@ -20,7 +20,7 @@ const ( type Command struct { Config *config.Config - Args *commandargs.CommandArgs + Args *commandargs.Shell ReadWriter *readwriter.ReadWriter } diff --git a/go/internal/command/lfsauthenticate/lfsauthenticate_test.go b/go/internal/command/lfsauthenticate/lfsauthenticate_test.go index 30da94b..a6836a8 100644 --- a/go/internal/command/lfsauthenticate/lfsauthenticate_test.go +++ b/go/internal/command/lfsauthenticate/lfsauthenticate_test.go @@ -25,22 +25,22 @@ func TestFailedRequests(t *testing.T) { testCases := []struct { desc string - arguments *commandargs.CommandArgs + arguments *commandargs.Shell expectedOutput string }{ { desc: "With missing arguments", - arguments: &commandargs.CommandArgs{}, + arguments: &commandargs.Shell{}, expectedOutput: "> GitLab: Disallowed command", }, { desc: "With disallowed command", - arguments: &commandargs.CommandArgs{GitlabKeyId: "1", SshArgs: []string{"git-lfs-authenticate", "group/repo", "unknown"}}, + arguments: &commandargs.Shell{GitlabKeyId: "1", SshArgs: []string{"git-lfs-authenticate", "group/repo", "unknown"}}, expectedOutput: "> GitLab: Disallowed command", }, { desc: "With disallowed user", - arguments: &commandargs.CommandArgs{GitlabKeyId: "disallowed", SshArgs: []string{"git-lfs-authenticate", "group/repo", "download"}}, + arguments: &commandargs.Shell{GitlabKeyId: "disallowed", SshArgs: []string{"git-lfs-authenticate", "group/repo", "download"}}, expectedOutput: "Disallowed by API call", }, } @@ -140,7 +140,7 @@ func TestLfsAuthenticateRequests(t *testing.T) { output := &bytes.Buffer{} cmd := &Command{ Config: &config.Config{GitlabUrl: url}, - Args: &commandargs.CommandArgs{GitlabUsername: tc.username, SshArgs: []string{"git-lfs-authenticate", "group/repo", "upload"}}, + Args: &commandargs.Shell{GitlabUsername: tc.username, SshArgs: []string{"git-lfs-authenticate", "group/repo", "upload"}}, ReadWriter: &readwriter.ReadWriter{ErrOut: output, Out: output}, } diff --git a/go/internal/command/receivepack/customaction_test.go b/go/internal/command/receivepack/customaction_test.go index 80e849c..bd4991d 100644 --- a/go/internal/command/receivepack/customaction_test.go +++ b/go/internal/command/receivepack/customaction_test.go @@ -92,7 +92,7 @@ func TestCustomReceivePack(t *testing.T) { cmd := &Command{ Config: &config.Config{GitlabUrl: url}, - Args: &commandargs.CommandArgs{GitlabKeyId: keyId, CommandType: commandargs.ReceivePack, SshArgs: []string{"git-receive-pack", repo}}, + Args: &commandargs.Shell{GitlabKeyId: keyId, CommandType: commandargs.ReceivePack, SshArgs: []string{"git-receive-pack", repo}}, ReadWriter: &readwriter.ReadWriter{ErrOut: errBuf, Out: outBuf, In: input}, } diff --git a/go/internal/command/receivepack/gitalycall_test.go b/go/internal/command/receivepack/gitalycall_test.go index 0914be6..eac9218 100644 --- a/go/internal/command/receivepack/gitalycall_test.go +++ b/go/internal/command/receivepack/gitalycall_test.go @@ -29,7 +29,7 @@ func TestReceivePack(t *testing.T) { cmd := &Command{ Config: &config.Config{GitlabUrl: url}, - Args: &commandargs.CommandArgs{GitlabKeyId: userId, CommandType: commandargs.ReceivePack, SshArgs: []string{"git-receive-pack", repo}}, + Args: &commandargs.Shell{GitlabKeyId: userId, CommandType: commandargs.ReceivePack, SshArgs: []string{"git-receive-pack", repo}}, ReadWriter: &readwriter.ReadWriter{ErrOut: output, Out: output, In: input}, } diff --git a/go/internal/command/receivepack/receivepack.go b/go/internal/command/receivepack/receivepack.go index d6b788c..eb0b2fe 100644 --- a/go/internal/command/receivepack/receivepack.go +++ b/go/internal/command/receivepack/receivepack.go @@ -10,7 +10,7 @@ import ( type Command struct { Config *config.Config - Args *commandargs.CommandArgs + Args *commandargs.Shell ReadWriter *readwriter.ReadWriter } diff --git a/go/internal/command/receivepack/receivepack_test.go b/go/internal/command/receivepack/receivepack_test.go index e5263f5..a45d054 100644 --- a/go/internal/command/receivepack/receivepack_test.go +++ b/go/internal/command/receivepack/receivepack_test.go @@ -23,7 +23,7 @@ func TestForbiddenAccess(t *testing.T) { cmd := &Command{ Config: &config.Config{GitlabUrl: url}, - Args: &commandargs.CommandArgs{GitlabKeyId: "disallowed", SshArgs: []string{"git-receive-pack", "group/repo"}}, + Args: &commandargs.Shell{GitlabKeyId: "disallowed", SshArgs: []string{"git-receive-pack", "group/repo"}}, ReadWriter: &readwriter.ReadWriter{ErrOut: output, Out: output, In: input}, } diff --git a/go/internal/command/shared/accessverifier/accessverifier.go b/go/internal/command/shared/accessverifier/accessverifier.go index 6d13789..fc6fa17 100644 --- a/go/internal/command/shared/accessverifier/accessverifier.go +++ b/go/internal/command/shared/accessverifier/accessverifier.go @@ -14,7 +14,7 @@ type Response = accessverifier.Response type Command struct { Config *config.Config - Args *commandargs.CommandArgs + Args *commandargs.Shell ReadWriter *readwriter.ReadWriter } diff --git a/go/internal/command/shared/accessverifier/accessverifier_test.go b/go/internal/command/shared/accessverifier/accessverifier_test.go index dd95ded..c19ed37 100644 --- a/go/internal/command/shared/accessverifier/accessverifier_test.go +++ b/go/internal/command/shared/accessverifier/accessverifier_test.go @@ -64,7 +64,7 @@ func TestMissingUser(t *testing.T) { cmd, _, _, cleanup := setup(t) defer cleanup() - cmd.Args = &commandargs.CommandArgs{GitlabKeyId: "2"} + cmd.Args = &commandargs.Shell{GitlabKeyId: "2"} _, err := cmd.Verify(action, repo) require.Equal(t, "missing user", err.Error()) @@ -74,7 +74,7 @@ func TestConsoleMessages(t *testing.T) { cmd, errBuf, outBuf, cleanup := setup(t) defer cleanup() - cmd.Args = &commandargs.CommandArgs{GitlabKeyId: "1"} + cmd.Args = &commandargs.Shell{GitlabKeyId: "1"} cmd.Verify(action, repo) require.Equal(t, "> GitLab: console\n> GitLab: message\n", errBuf.String()) diff --git a/go/internal/command/twofactorrecover/twofactorrecover.go b/go/internal/command/twofactorrecover/twofactorrecover.go index faa35db..c68080a 100644 --- a/go/internal/command/twofactorrecover/twofactorrecover.go +++ b/go/internal/command/twofactorrecover/twofactorrecover.go @@ -12,7 +12,7 @@ import ( type Command struct { Config *config.Config - Args *commandargs.CommandArgs + Args *commandargs.Shell ReadWriter *readwriter.ReadWriter } diff --git a/go/internal/command/twofactorrecover/twofactorrecover_test.go b/go/internal/command/twofactorrecover/twofactorrecover_test.go index 6238e0d..291d499 100644 --- a/go/internal/command/twofactorrecover/twofactorrecover_test.go +++ b/go/internal/command/twofactorrecover/twofactorrecover_test.go @@ -69,13 +69,13 @@ func TestExecute(t *testing.T) { testCases := []struct { desc string - arguments *commandargs.CommandArgs + arguments *commandargs.Shell answer string expectedOutput string }{ { desc: "With a known key id", - arguments: &commandargs.CommandArgs{GitlabKeyId: "1"}, + arguments: &commandargs.Shell{GitlabKeyId: "1"}, answer: "yes\n", expectedOutput: question + "Your two-factor authentication recovery codes are:\n\nrecovery\ncodes\n\n" + @@ -85,31 +85,31 @@ func TestExecute(t *testing.T) { }, { desc: "With bad response", - arguments: &commandargs.CommandArgs{GitlabKeyId: "-1"}, + arguments: &commandargs.Shell{GitlabKeyId: "-1"}, answer: "yes\n", expectedOutput: question + errorHeader + "Parsing failed\n", }, { desc: "With API returns an error", - arguments: &commandargs.CommandArgs{GitlabKeyId: "forbidden"}, + arguments: &commandargs.Shell{GitlabKeyId: "forbidden"}, answer: "yes\n", expectedOutput: question + errorHeader + "Forbidden!\n", }, { desc: "With API fails", - arguments: &commandargs.CommandArgs{GitlabKeyId: "broken"}, + arguments: &commandargs.Shell{GitlabKeyId: "broken"}, answer: "yes\n", expectedOutput: question + errorHeader + "Internal API error (500)\n", }, { desc: "With missing arguments", - arguments: &commandargs.CommandArgs{}, + arguments: &commandargs.Shell{}, answer: "yes\n", expectedOutput: question + errorHeader + "who='' is invalid\n", }, { desc: "With negative answer", - arguments: &commandargs.CommandArgs{}, + arguments: &commandargs.Shell{}, answer: "no\n", expectedOutput: question + "New recovery codes have *not* been generated. Existing codes will remain valid.\n", diff --git a/go/internal/command/uploadarchive/gitalycall_test.go b/go/internal/command/uploadarchive/gitalycall_test.go index 78953a7..5eb2eae 100644 --- a/go/internal/command/uploadarchive/gitalycall_test.go +++ b/go/internal/command/uploadarchive/gitalycall_test.go @@ -29,7 +29,7 @@ func TestUploadPack(t *testing.T) { cmd := &Command{ Config: &config.Config{GitlabUrl: url}, - Args: &commandargs.CommandArgs{GitlabKeyId: userId, CommandType: commandargs.UploadArchive, SshArgs: []string{"git-upload-archive", repo}}, + Args: &commandargs.Shell{GitlabKeyId: userId, CommandType: commandargs.UploadArchive, SshArgs: []string{"git-upload-archive", repo}}, ReadWriter: &readwriter.ReadWriter{ErrOut: output, Out: output, In: input}, } diff --git a/go/internal/command/uploadarchive/uploadarchive.go b/go/internal/command/uploadarchive/uploadarchive.go index 93a52c0..2846455 100644 --- a/go/internal/command/uploadarchive/uploadarchive.go +++ b/go/internal/command/uploadarchive/uploadarchive.go @@ -10,7 +10,7 @@ import ( type Command struct { Config *config.Config - Args *commandargs.CommandArgs + Args *commandargs.Shell ReadWriter *readwriter.ReadWriter } diff --git a/go/internal/command/uploadarchive/uploadarchive_test.go b/go/internal/command/uploadarchive/uploadarchive_test.go index 369bee7..4cd6832 100644 --- a/go/internal/command/uploadarchive/uploadarchive_test.go +++ b/go/internal/command/uploadarchive/uploadarchive_test.go @@ -22,7 +22,7 @@ func TestForbiddenAccess(t *testing.T) { cmd := &Command{ Config: &config.Config{GitlabUrl: url}, - Args: &commandargs.CommandArgs{GitlabKeyId: "disallowed", SshArgs: []string{"git-upload-archive", "group/repo"}}, + Args: &commandargs.Shell{GitlabKeyId: "disallowed", SshArgs: []string{"git-upload-archive", "group/repo"}}, ReadWriter: &readwriter.ReadWriter{ErrOut: output, Out: output}, } diff --git a/go/internal/command/uploadpack/gitalycall_test.go b/go/internal/command/uploadpack/gitalycall_test.go index 2097964..eb18aa8 100644 --- a/go/internal/command/uploadpack/gitalycall_test.go +++ b/go/internal/command/uploadpack/gitalycall_test.go @@ -29,7 +29,7 @@ func TestUploadPack(t *testing.T) { cmd := &Command{ Config: &config.Config{GitlabUrl: url}, - Args: &commandargs.CommandArgs{GitlabKeyId: userId, CommandType: commandargs.UploadPack, SshArgs: []string{"git-upload-pack", repo}}, + Args: &commandargs.Shell{GitlabKeyId: userId, CommandType: commandargs.UploadPack, SshArgs: []string{"git-upload-pack", repo}}, ReadWriter: &readwriter.ReadWriter{ErrOut: output, Out: output, In: input}, } diff --git a/go/internal/command/uploadpack/uploadpack.go b/go/internal/command/uploadpack/uploadpack.go index cff198d..4b08bf2 100644 --- a/go/internal/command/uploadpack/uploadpack.go +++ b/go/internal/command/uploadpack/uploadpack.go @@ -10,7 +10,7 @@ import ( type Command struct { Config *config.Config - Args *commandargs.CommandArgs + Args *commandargs.Shell ReadWriter *readwriter.ReadWriter } diff --git a/go/internal/command/uploadpack/uploadpack_test.go b/go/internal/command/uploadpack/uploadpack_test.go index a06ba24..27a0786 100644 --- a/go/internal/command/uploadpack/uploadpack_test.go +++ b/go/internal/command/uploadpack/uploadpack_test.go @@ -22,7 +22,7 @@ func TestForbiddenAccess(t *testing.T) { cmd := &Command{ Config: &config.Config{GitlabUrl: url}, - Args: &commandargs.CommandArgs{GitlabKeyId: "disallowed", SshArgs: []string{"git-upload-pack", "group/repo"}}, + Args: &commandargs.Shell{GitlabKeyId: "disallowed", SshArgs: []string{"git-upload-pack", "group/repo"}}, ReadWriter: &readwriter.ReadWriter{ErrOut: output, Out: output}, } |