As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Unverified Commit a703b51e authored by Archish Thakkar's avatar Archish Thakkar Committed by GitLab
Browse files

Lint fixes for commandargs packages

parent 55cd93ff
No related branches found
No related tags found
No related merge requests found
Showing
with 52 additions and 80 deletions
Loading
@@ -74,7 +74,7 @@ func TestExecute(t *testing.T) {
Loading
@@ -74,7 +74,7 @@ func TestExecute(t *testing.T) {
}{ }{
{ {
desc: "With a known key id", desc: "With a known key id",
arguments: &commandargs.Shell{GitlabKeyId: "1"}, arguments: &commandargs.Shell{GitlabKeyID: "1"},
answer: "yes\n", answer: "yes\n",
expectedOutput: question + expectedOutput: question +
"Your two-factor authentication recovery codes are:\n\nrecovery\ncodes\n\n" + "Your two-factor authentication recovery codes are:\n\nrecovery\ncodes\n\n" +
Loading
@@ -84,19 +84,19 @@ func TestExecute(t *testing.T) {
Loading
@@ -84,19 +84,19 @@ func TestExecute(t *testing.T) {
}, },
{ {
desc: "With bad response", desc: "With bad response",
arguments: &commandargs.Shell{GitlabKeyId: "-1"}, arguments: &commandargs.Shell{GitlabKeyID: "-1"},
answer: "yes\n", answer: "yes\n",
expectedOutput: question + errorHeader + "parsing failed\n", expectedOutput: question + errorHeader + "parsing failed\n",
}, },
{ {
desc: "With API returns an error", desc: "With API returns an error",
arguments: &commandargs.Shell{GitlabKeyId: "forbidden"}, arguments: &commandargs.Shell{GitlabKeyID: "forbidden"},
answer: "yes\n", answer: "yes\n",
expectedOutput: question + errorHeader + "Forbidden!\n", expectedOutput: question + errorHeader + "Forbidden!\n",
}, },
{ {
desc: "With API fails", desc: "With API fails",
arguments: &commandargs.Shell{GitlabKeyId: "broken"}, arguments: &commandargs.Shell{GitlabKeyID: "broken"},
answer: "yes\n", answer: "yes\n",
expectedOutput: question + errorHeader + "Internal API unreachable\n", expectedOutput: question + errorHeader + "Internal API unreachable\n",
}, },
Loading
Loading
Loading
@@ -104,39 +104,39 @@ func TestExecute(t *testing.T) {
Loading
@@ -104,39 +104,39 @@ func TestExecute(t *testing.T) {
}{ }{
{ {
desc: "Verify via OTP", desc: "Verify via OTP",
arguments: &commandargs.Shell{GitlabKeyId: "verify_via_otp"}, arguments: &commandargs.Shell{GitlabKeyID: "verify_via_otp"},
expectedOutput: "OTP validation successful. Git operations are now allowed.\n", expectedOutput: "OTP validation successful. Git operations are now allowed.\n",
}, },
{ {
desc: "Verify via OTP", desc: "Verify via OTP",
arguments: &commandargs.Shell{GitlabKeyId: "verify_via_otp_with_push_error"}, arguments: &commandargs.Shell{GitlabKeyID: "verify_via_otp_with_push_error"},
expectedOutput: "OTP validation successful. Git operations are now allowed.\n", expectedOutput: "OTP validation successful. Git operations are now allowed.\n",
}, },
{ {
desc: "Verify via push authentication", desc: "Verify via push authentication",
arguments: &commandargs.Shell{GitlabKeyId: "verify_via_push"}, arguments: &commandargs.Shell{GitlabKeyID: "verify_via_push"},
input: &blockingReader{}, input: &blockingReader{},
expectedOutput: "OTP has been validated by Push Authentication. Git operations are now allowed.\n", expectedOutput: "OTP has been validated by Push Authentication. Git operations are now allowed.\n",
}, },
{ {
desc: "With an empty OTP", desc: "With an empty OTP",
arguments: &commandargs.Shell{GitlabKeyId: "verify_via_otp"}, arguments: &commandargs.Shell{GitlabKeyID: "verify_via_otp"},
input: bytes.NewBufferString("\n"), input: bytes.NewBufferString("\n"),
expectedOutput: errorHeader + "OTP cannot be blank\n", expectedOutput: errorHeader + "OTP cannot be blank\n",
}, },
{ {
desc: "With bad response", desc: "With bad response",
arguments: &commandargs.Shell{GitlabKeyId: "-1"}, arguments: &commandargs.Shell{GitlabKeyID: "-1"},
expectedOutput: errorHeader + "parsing failed\n", expectedOutput: errorHeader + "parsing failed\n",
}, },
{ {
desc: "With API returns an error", desc: "With API returns an error",
arguments: &commandargs.Shell{GitlabKeyId: "error"}, arguments: &commandargs.Shell{GitlabKeyID: "error"},
expectedOutput: errorHeader + "error message\n", expectedOutput: errorHeader + "error message\n",
}, },
{ {
desc: "With API fails", desc: "With API fails",
arguments: &commandargs.Shell{GitlabKeyId: "broken"}, arguments: &commandargs.Shell{GitlabKeyID: "broken"},
expectedOutput: errorHeader + "Internal API unreachable\n", expectedOutput: errorHeader + "Internal API unreachable\n",
}, },
{ {
Loading
@@ -177,7 +177,7 @@ func TestCanceledContext(t *testing.T) {
Loading
@@ -177,7 +177,7 @@ func TestCanceledContext(t *testing.T) {
url := testserver.StartSocketHTTPServer(t, requests) url := testserver.StartSocketHTTPServer(t, requests)
cmd := &Command{ cmd := &Command{
Config: &config.Config{GitlabUrl: url}, Config: &config.Config{GitlabUrl: url},
Args: &commandargs.Shell{GitlabKeyId: "wait_infinitely"}, Args: &commandargs.Shell{GitlabKeyID: "wait_infinitely"},
ReadWriter: &readwriter.ReadWriter{Out: output, In: &blockingReader{}}, ReadWriter: &readwriter.ReadWriter{Out: output, In: &blockingReader{}},
} }
Loading
Loading
Loading
@@ -39,9 +39,9 @@ func TestUploadArchive(t *testing.T) {
Loading
@@ -39,9 +39,9 @@ func TestUploadArchive(t *testing.T) {
} }
args := &commandargs.Shell{ args := &commandargs.Shell{
GitlabKeyId: userID, GitlabKeyID: userID,
CommandType: commandargs.UploadArchive, CommandType: commandargs.UploadArchive,
SshArgs: []string{"git-upload-archive", repo}, SSHArgs: []string{"git-upload-archive", repo},
Env: env, Env: env,
} }
Loading
Loading
Loading
@@ -23,7 +23,7 @@ type logInfo struct{}
Loading
@@ -23,7 +23,7 @@ type logInfo struct{}
// Execute executes the upload archive command // Execute executes the upload archive command
func (c *Command) Execute(ctx context.Context) (context.Context, error) { func (c *Command) Execute(ctx context.Context) (context.Context, error) {
args := c.Args.SshArgs args := c.Args.SSHArgs
if len(args) != 2 { if len(args) != 2 {
return ctx, disallowedcommand.Error return ctx, disallowedcommand.Error
} }
Loading
Loading
Loading
@@ -51,7 +51,7 @@ func setup(t *testing.T, keyID string, requests []testserver.TestRequestHandler)
Loading
@@ -51,7 +51,7 @@ func setup(t *testing.T, keyID string, requests []testserver.TestRequestHandler)
cmd := &Command{ cmd := &Command{
Config: &config.Config{GitlabUrl: url}, Config: &config.Config{GitlabUrl: url},
Args: &commandargs.Shell{GitlabKeyId: keyID, SshArgs: []string{"git-upload-archive", "group/repo"}}, Args: &commandargs.Shell{GitlabKeyID: keyID, SSHArgs: []string{"git-upload-archive", "group/repo"}},
ReadWriter: &readwriter.ReadWriter{ErrOut: output, Out: output, In: input}, ReadWriter: &readwriter.ReadWriter{ErrOut: output, Out: output, In: input},
} }
Loading
Loading
Loading
@@ -39,9 +39,9 @@ func TestUploadPack(t *testing.T) {
Loading
@@ -39,9 +39,9 @@ func TestUploadPack(t *testing.T) {
} }
args := &commandargs.Shell{ args := &commandargs.Shell{
GitlabKeyId: userID, GitlabKeyID: userID,
CommandType: commandargs.UploadPack, CommandType: commandargs.UploadPack,
SshArgs: []string{"git-upload-pack", repo}, SSHArgs: []string{"git-upload-pack", repo},
Env: env, Env: env,
} }
Loading
Loading
Loading
@@ -27,7 +27,7 @@ type logDataKey struct{}
Loading
@@ -27,7 +27,7 @@ type logDataKey struct{}
// Execute executes the upload-pack command // Execute executes the upload-pack command
func (c *Command) Execute(ctx context.Context) (context.Context, error) { func (c *Command) Execute(ctx context.Context) (context.Context, error) {
args := c.Args.SshArgs args := c.Args.SSHArgs
if len(args) != 2 { if len(args) != 2 {
return ctx, disallowedcommand.Error return ctx, disallowedcommand.Error
} }
Loading
Loading
Loading
@@ -47,7 +47,7 @@ func setup(t *testing.T, keyID string, requests []testserver.TestRequestHandler)
Loading
@@ -47,7 +47,7 @@ func setup(t *testing.T, keyID string, requests []testserver.TestRequestHandler)
cmd := &Command{ cmd := &Command{
Config: &config.Config{GitlabUrl: url}, Config: &config.Config{GitlabUrl: url},
Args: &commandargs.Shell{GitlabKeyId: keyID, SshArgs: []string{"git-upload-pack", "group/repo"}}, Args: &commandargs.Shell{GitlabKeyID: keyID, SSHArgs: []string{"git-upload-pack", "group/repo"}},
ReadWriter: &readwriter.ReadWriter{ErrOut: output, Out: output, In: input}, ReadWriter: &readwriter.ReadWriter{ErrOut: output, Out: output, In: input},
} }
Loading
Loading
Loading
@@ -114,7 +114,7 @@ func (c *Client) Verify(ctx context.Context, args *commandargs.Shell, action com
Loading
@@ -114,7 +114,7 @@ func (c *Client) Verify(ctx context.Context, args *commandargs.Shell, action com
case args.GitlabKrb5Principal != "": case args.GitlabKrb5Principal != "":
request.Krb5Principal = args.GitlabKrb5Principal request.Krb5Principal = args.GitlabKrb5Principal
default: default:
request.KeyID = args.GitlabKeyId request.KeyID = args.GitlabKeyID
} }
request.CheckIP = gitlabnet.ParseIP(args.Env.RemoteAddr) request.CheckIP = gitlabnet.ParseIP(args.Env.RemoteAddr)
Loading
@@ -134,8 +134,8 @@ func parse(hr *http.Response, args *commandargs.Shell) (*Response, error) {
Loading
@@ -134,8 +134,8 @@ func parse(hr *http.Response, args *commandargs.Shell) (*Response, error) {
return nil, err return nil, err
} }
if args.GitlabKeyId != "" { if args.GitlabKeyID != "" {
response.Who = "key-" + args.GitlabKeyId response.Who = "key-" + args.GitlabKeyID
} else { } else {
response.Who = response.UserID response.Who = response.UserID
} }
Loading
Loading
Loading
@@ -71,7 +71,7 @@ func TestSuccessfulResponses(t *testing.T) {
Loading
@@ -71,7 +71,7 @@ func TestSuccessfulResponses(t *testing.T) {
}{ }{
{ {
desc: "Provide key id within the request", desc: "Provide key id within the request",
args: &commandargs.Shell{GitlabKeyId: "1"}, args: &commandargs.Shell{GitlabKeyID: "1"},
who: "key-1", who: "key-1",
}, { }, {
desc: "Provide username within the request", desc: "Provide username within the request",
Loading
@@ -186,7 +186,7 @@ func TestErrorResponses(t *testing.T) {
Loading
@@ -186,7 +186,7 @@ func TestErrorResponses(t *testing.T) {
for _, tc := range testCases { for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) { t.Run(tc.desc, func(t *testing.T) {
args := &commandargs.Shell{GitlabKeyId: tc.fakeID} args := &commandargs.Shell{GitlabKeyID: tc.fakeID}
resp, err := client.Verify(context.Background(), args, receivePackAction, repo) resp, err := client.Verify(context.Background(), args, receivePackAction, repo)
require.EqualError(t, err, tc.expectedError) require.EqualError(t, err, tc.expectedError)
Loading
Loading
Loading
@@ -42,8 +42,8 @@ func (c *Client) GetByCommandArgs(ctx context.Context, args *commandargs.Shell)
Loading
@@ -42,8 +42,8 @@ func (c *Client) GetByCommandArgs(ctx context.Context, args *commandargs.Shell)
switch { switch {
case args.GitlabUsername != "": case args.GitlabUsername != "":
params.Add("username", args.GitlabUsername) params.Add("username", args.GitlabUsername)
case args.GitlabKeyId != "": case args.GitlabKeyID != "":
params.Add("key_id", args.GitlabKeyId) params.Add("key_id", args.GitlabKeyID)
case args.GitlabKrb5Principal != "": case args.GitlabKrb5Principal != "":
params.Add("krb5principal", args.GitlabKrb5Principal) params.Add("krb5principal", args.GitlabKrb5Principal)
default: default:
Loading
Loading
Loading
@@ -49,8 +49,8 @@ func NewClient(config *config.Config, args *commandargs.Shell) (*Client, error)
Loading
@@ -49,8 +49,8 @@ func NewClient(config *config.Config, args *commandargs.Shell) (*Client, error)
// Authenticate performs authentication for LFS requests // Authenticate performs authentication for LFS requests
func (c *Client) Authenticate(ctx context.Context, operation, repo, userID string) (*Response, error) { func (c *Client) Authenticate(ctx context.Context, operation, repo, userID string) (*Response, error) {
request := &Request{Operation: operation, Repo: repo} request := &Request{Operation: operation, Repo: repo}
if c.args.GitlabKeyId != "" { if c.args.GitlabKeyID != "" {
request.KeyID = c.args.GitlabKeyId request.KeyID = c.args.GitlabKeyID
} else { } else {
request.UserID = strings.TrimPrefix(userID, "user-") request.UserID = strings.TrimPrefix(userID, "user-")
} }
Loading
Loading
Loading
@@ -64,17 +64,17 @@ func TestFailedRequests(t *testing.T) {
Loading
@@ -64,17 +64,17 @@ func TestFailedRequests(t *testing.T) {
}{ }{
{ {
desc: "With bad response", desc: "With bad response",
args: &commandargs.Shell{GitlabKeyId: "-1", CommandType: commandargs.LfsAuthenticate, SshArgs: []string{"git-lfs-authenticate", repo, "download"}}, args: &commandargs.Shell{GitlabKeyID: "-1", CommandType: commandargs.LfsAuthenticate, SSHArgs: []string{"git-lfs-authenticate", repo, "download"}},
expectedOutput: "parsing failed", expectedOutput: "parsing failed",
}, },
{ {
desc: "With API returns an error", desc: "With API returns an error",
args: &commandargs.Shell{GitlabKeyId: "forbidden", CommandType: commandargs.LfsAuthenticate, SshArgs: []string{"git-lfs-authenticate", repo, "download"}}, args: &commandargs.Shell{GitlabKeyID: "forbidden", CommandType: commandargs.LfsAuthenticate, SSHArgs: []string{"git-lfs-authenticate", repo, "download"}},
expectedOutput: "Internal API error (403)", expectedOutput: "Internal API error (403)",
}, },
{ {
desc: "With API fails", desc: "With API fails",
args: &commandargs.Shell{GitlabKeyId: "broken", CommandType: commandargs.LfsAuthenticate, SshArgs: []string{"git-lfs-authenticate", repo, "download"}}, args: &commandargs.Shell{GitlabKeyID: "broken", CommandType: commandargs.LfsAuthenticate, SSHArgs: []string{"git-lfs-authenticate", repo, "download"}},
expectedOutput: "Internal API unreachable", expectedOutput: "Internal API unreachable",
}, },
} }
Loading
@@ -84,7 +84,7 @@ func TestFailedRequests(t *testing.T) {
Loading
@@ -84,7 +84,7 @@ func TestFailedRequests(t *testing.T) {
client, err := NewClient(&config.Config{GitlabUrl: url}, tc.args) client, err := NewClient(&config.Config{GitlabUrl: url}, tc.args)
require.NoError(t, err) require.NoError(t, err)
operation := tc.args.SshArgs[2] operation := tc.args.SSHArgs[2]
_, err = client.Authenticate(context.Background(), operation, repo, "") _, err = client.Authenticate(context.Background(), operation, repo, "")
require.Error(t, err) require.Error(t, err)
Loading
@@ -115,7 +115,7 @@ func TestSuccessfulRequests(t *testing.T) {
Loading
@@ -115,7 +115,7 @@ func TestSuccessfulRequests(t *testing.T) {
for _, tc := range testCases { for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) { t.Run(tc.desc, func(t *testing.T) {
operation := tc.operation operation := tc.operation
args := &commandargs.Shell{GitlabKeyId: keyID, CommandType: commandargs.LfsAuthenticate, SshArgs: []string{"git-lfs-authenticate", repo, operation}} args := &commandargs.Shell{GitlabKeyID: keyID, CommandType: commandargs.LfsAuthenticate, SSHArgs: []string{"git-lfs-authenticate", repo, operation}}
client, err := NewClient(&config.Config{GitlabUrl: url}, args) client, err := NewClient(&config.Config{GitlabUrl: url}, args)
require.NoError(t, err) require.NoError(t, err)
Loading
Loading
Loading
@@ -84,8 +84,8 @@ func (c *Client) getRequestBody(ctx context.Context, args *commandargs.Shell, na
Loading
@@ -84,8 +84,8 @@ func (c *Client) getRequestBody(ctx context.Context, args *commandargs.Shell, na
} }
requestBody := &RequestBody{Name: name, Scopes: *scopes, ExpiresAt: expiresAt} requestBody := &RequestBody{Name: name, Scopes: *scopes, ExpiresAt: expiresAt}
if args.GitlabKeyId != "" { if args.GitlabKeyID != "" {
requestBody.KeyID = args.GitlabKeyId requestBody.KeyID = args.GitlabKeyID
return requestBody, nil return requestBody, nil
} }
Loading
Loading
Loading
@@ -88,7 +88,7 @@ func initialize(t *testing.T) {
Loading
@@ -88,7 +88,7 @@ func initialize(t *testing.T) {
func TestGetPersonalAccessTokenByKeyId(t *testing.T) { func TestGetPersonalAccessTokenByKeyId(t *testing.T) {
client := setup(t) client := setup(t)
args := &commandargs.Shell{GitlabKeyId: "0"} args := &commandargs.Shell{GitlabKeyID: "0"}
result, err := client.GetPersonalAccessToken( result, err := client.GetPersonalAccessToken(
context.Background(), args, "newtoken", &[]string{"read_api", "read_repository"}, "", context.Background(), args, "newtoken", &[]string{"read_api", "read_repository"}, "",
) )
Loading
@@ -118,7 +118,7 @@ func TestGetRecoveryCodesByUsername(t *testing.T) {
Loading
@@ -118,7 +118,7 @@ func TestGetRecoveryCodesByUsername(t *testing.T) {
func TestMissingUser(t *testing.T) { func TestMissingUser(t *testing.T) {
client := setup(t) client := setup(t)
args := &commandargs.Shell{GitlabKeyId: "1"} args := &commandargs.Shell{GitlabKeyID: "1"}
_, err := client.GetPersonalAccessToken( _, err := client.GetPersonalAccessToken(
context.Background(), args, "newtoken", &[]string{"api"}, "", context.Background(), args, "newtoken", &[]string{"api"}, "",
) )
Loading
@@ -152,7 +152,7 @@ func TestErrorResponses(t *testing.T) {
Loading
@@ -152,7 +152,7 @@ func TestErrorResponses(t *testing.T) {
for _, tc := range testCases { for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) { t.Run(tc.desc, func(t *testing.T) {
args := &commandargs.Shell{GitlabKeyId: tc.fakeID} args := &commandargs.Shell{GitlabKeyID: tc.fakeID}
resp, err := client.GetPersonalAccessToken( resp, err := client.GetPersonalAccessToken(
context.Background(), args, "newtoken", &[]string{"api"}, "", context.Background(), args, "newtoken", &[]string{"api"}, "",
) )
Loading
Loading
Loading
@@ -81,8 +81,8 @@ func (c *Client) getRequestBody(ctx context.Context, args *commandargs.Shell) (*
Loading
@@ -81,8 +81,8 @@ func (c *Client) getRequestBody(ctx context.Context, args *commandargs.Shell) (*
} }
var requestBody *RequestBody var requestBody *RequestBody
if args.GitlabKeyId != "" { if args.GitlabKeyID != "" {
requestBody = &RequestBody{KeyID: args.GitlabKeyId} requestBody = &RequestBody{KeyID: args.GitlabKeyID}
} else { } else {
userInfo, err := client.GetByCommandArgs(ctx, args) userInfo, err := client.GetByCommandArgs(ctx, args)
Loading
Loading
Loading
@@ -84,7 +84,7 @@ func initialize(t *testing.T) {
Loading
@@ -84,7 +84,7 @@ func initialize(t *testing.T) {
func TestGetRecoveryCodesByKeyId(t *testing.T) { func TestGetRecoveryCodesByKeyId(t *testing.T) {
client := setup(t) client := setup(t)
args := &commandargs.Shell{GitlabKeyId: "0"} args := &commandargs.Shell{GitlabKeyID: "0"}
result, err := client.GetRecoveryCodes(context.Background(), args) result, err := client.GetRecoveryCodes(context.Background(), args)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, []string{"recovery 1", "codes 1"}, result) require.Equal(t, []string{"recovery 1", "codes 1"}, result)
Loading
@@ -102,7 +102,7 @@ func TestGetRecoveryCodesByUsername(t *testing.T) {
Loading
@@ -102,7 +102,7 @@ func TestGetRecoveryCodesByUsername(t *testing.T) {
func TestMissingUser(t *testing.T) { func TestMissingUser(t *testing.T) {
client := setup(t) client := setup(t)
args := &commandargs.Shell{GitlabKeyId: "1"} args := &commandargs.Shell{GitlabKeyID: "1"}
_, err := client.GetRecoveryCodes(context.Background(), args) _, err := client.GetRecoveryCodes(context.Background(), args)
require.Equal(t, "missing user", err.Error()) require.Equal(t, "missing user", err.Error())
} }
Loading
@@ -134,7 +134,7 @@ func TestErrorResponses(t *testing.T) {
Loading
@@ -134,7 +134,7 @@ func TestErrorResponses(t *testing.T) {
for _, tc := range testCases { for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) { t.Run(tc.desc, func(t *testing.T) {
args := &commandargs.Shell{GitlabKeyId: tc.fakeID} args := &commandargs.Shell{GitlabKeyID: tc.fakeID}
resp, err := client.GetRecoveryCodes(context.Background(), args) resp, err := client.GetRecoveryCodes(context.Background(), args)
require.EqualError(t, err, tc.expectedError) require.EqualError(t, err, tc.expectedError)
Loading
Loading
Loading
@@ -96,8 +96,8 @@ func (c *Client) getRequestBody(ctx context.Context, args *commandargs.Shell, ot
Loading
@@ -96,8 +96,8 @@ func (c *Client) getRequestBody(ctx context.Context, args *commandargs.Shell, ot
} }
var requestBody *RequestBody var requestBody *RequestBody
if args.GitlabKeyId != "" { if args.GitlabKeyID != "" {
requestBody = &RequestBody{KeyID: args.GitlabKeyId, OTPAttempt: otp} requestBody = &RequestBody{KeyID: args.GitlabKeyID, OTPAttempt: otp}
} else { } else {
userInfo, err := client.GetByCommandArgs(ctx, args) userInfo, err := client.GetByCommandArgs(ctx, args)
Loading
Loading
Loading
@@ -91,7 +91,7 @@ const (
Loading
@@ -91,7 +91,7 @@ const (
func TestVerifyOTPByKeyId(t *testing.T) { func TestVerifyOTPByKeyId(t *testing.T) {
client := setup(t) client := setup(t)
args := &commandargs.Shell{GitlabKeyId: "0"} args := &commandargs.Shell{GitlabKeyID: "0"}
err := client.VerifyOTP(context.Background(), args, otpAttempt) err := client.VerifyOTP(context.Background(), args, otpAttempt)
require.NoError(t, err) require.NoError(t, err)
} }
Loading
@@ -107,7 +107,7 @@ func TestVerifyOTPByUsername(t *testing.T) {
Loading
@@ -107,7 +107,7 @@ func TestVerifyOTPByUsername(t *testing.T) {
func TestErrorMessage(t *testing.T) { func TestErrorMessage(t *testing.T) {
client := setup(t) client := setup(t)
args := &commandargs.Shell{GitlabKeyId: "1"} args := &commandargs.Shell{GitlabKeyID: "1"}
err := client.VerifyOTP(context.Background(), args, otpAttempt) err := client.VerifyOTP(context.Background(), args, otpAttempt)
require.Equal(t, "error message", err.Error()) require.Equal(t, "error message", err.Error())
} }
Loading
@@ -139,7 +139,7 @@ func TestErrorResponses(t *testing.T) {
Loading
@@ -139,7 +139,7 @@ func TestErrorResponses(t *testing.T) {
for _, tc := range testCases { for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) { t.Run(tc.desc, func(t *testing.T) {
args := &commandargs.Shell{GitlabKeyId: tc.fakeID} args := &commandargs.Shell{GitlabKeyID: tc.fakeID}
err := client.VerifyOTP(context.Background(), args, otpAttempt) err := client.VerifyOTP(context.Background(), args, otpAttempt)
require.EqualError(t, err, tc.expectedError) require.EqualError(t, err, tc.expectedError)
Loading
@@ -150,7 +150,7 @@ func TestErrorResponses(t *testing.T) {
Loading
@@ -150,7 +150,7 @@ func TestErrorResponses(t *testing.T) {
func TestVerifyPush(t *testing.T) { func TestVerifyPush(t *testing.T) {
client := setup(t) client := setup(t)
args := &commandargs.Shell{GitlabKeyId: "0"} args := &commandargs.Shell{GitlabKeyID: "0"}
err := client.PushAuth(context.Background(), args) err := client.PushAuth(context.Background(), args)
require.NoError(t, err) require.NoError(t, err)
} }
Loading
@@ -158,7 +158,7 @@ func TestVerifyPush(t *testing.T) {
Loading
@@ -158,7 +158,7 @@ func TestVerifyPush(t *testing.T) {
func TestErrorMessagePush(t *testing.T) { func TestErrorMessagePush(t *testing.T) {
client := setup(t) client := setup(t)
args := &commandargs.Shell{GitlabKeyId: "1"} args := &commandargs.Shell{GitlabKeyID: "1"}
err := client.PushAuth(context.Background(), args) err := client.PushAuth(context.Background(), args)
require.Equal(t, "error message", err.Error()) require.Equal(t, "error message", err.Error())
} }
Loading
@@ -190,7 +190,7 @@ func TestErrorResponsesPush(t *testing.T) {
Loading
@@ -190,7 +190,7 @@ func TestErrorResponsesPush(t *testing.T) {
for _, tc := range testCases { for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) { t.Run(tc.desc, func(t *testing.T) {
args := &commandargs.Shell{GitlabKeyId: tc.fakeID} args := &commandargs.Shell{GitlabKeyID: tc.fakeID}
err := client.PushAuth(context.Background(), args) err := client.PushAuth(context.Background(), args)
require.EqualError(t, err, tc.expectedError) require.EqualError(t, err, tc.expectedError)
Loading
Loading
Loading
@@ -47,34 +47,6 @@ internal/command/command.go:32:1: exported: exported function CheckForVersionFla
Loading
@@ -47,34 +47,6 @@ internal/command/command.go:32:1: exported: exported function CheckForVersionFla
internal/command/command.go:43:1: exported: comment on exported function Setup should be of the form "Setup ..." (revive) internal/command/command.go:43:1: exported: comment on exported function Setup should be of the form "Setup ..." (revive)
internal/command/command.go:75:15: Error return value of `closer.Close` is not checked (errcheck) internal/command/command.go:75:15: Error return value of `closer.Close` is not checked (errcheck)
internal/command/command.go:79:1: exported: exported function NewLogData should have comment or be unexported (revive) internal/command/command.go:79:1: exported: exported function NewLogData should have comment or be unexported (revive)
internal/command/commandargs/authorized_keys.go:1:1: package-comments: should have a package comment (revive)
internal/command/commandargs/authorized_keys.go:8:6: exported: exported type AuthorizedKeys should have comment or be unexported (revive)
internal/command/commandargs/authorized_keys.go:15:1: exported: exported method AuthorizedKeys.Parse should have comment or be unexported (revive)
internal/command/commandargs/authorized_keys.go:27:1: exported: exported method AuthorizedKeys.GetArguments should have comment or be unexported (revive)
internal/command/commandargs/authorized_keys.go:35:10: errorf: should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...) (revive)
internal/command/commandargs/authorized_principals.go:1:1: ST1000: at least one file in a package should have a package comment (stylecheck)
internal/command/commandargs/authorized_principals.go:8:6: exported: exported type AuthorizedPrincipals should have comment or be unexported (revive)
internal/command/commandargs/authorized_principals.go:10:2: var-naming: struct field KeyId should be KeyID (revive)
internal/command/commandargs/authorized_principals.go:14:1: exported: exported method AuthorizedPrincipals.Parse should have comment or be unexported (revive)
internal/command/commandargs/authorized_principals.go:25:1: exported: exported method AuthorizedPrincipals.GetArguments should have comment or be unexported (revive)
internal/command/commandargs/authorized_principals.go:33:10: errorf: should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...) (revive)
internal/command/commandargs/authorized_principals.go:36:2: var-naming: var keyId should be keyID (revive)
internal/command/commandargs/command_args.go:1:1: ST1000: at least one file in a package should have a package comment (stylecheck)
internal/command/commandargs/command_args.go:3:6: exported: exported type CommandType should have comment or be unexported (revive)
internal/command/commandargs/command_args.go:5:6: exported: exported type CommandArgs should have comment or be unexported (revive)
internal/command/commandargs/shell.go:1:1: ST1000: at least one file in a package should have a package comment (stylecheck)
internal/command/commandargs/shell.go:13:2: exported: exported const Discover should have comment (or a comment on this block) or be unexported (revive)
internal/command/commandargs/shell.go:28:2: exported: exported var GitCommands should have comment or be unexported (revive)
internal/command/commandargs/shell.go:31:6: exported: exported type Shell should have comment or be unexported (revive)
internal/command/commandargs/shell.go:34:2: var-naming: struct field GitlabKeyId should be GitlabKeyID (revive)
internal/command/commandargs/shell.go:36:2: var-naming: struct field SshArgs should be SSHArgs (revive)
internal/command/commandargs/shell.go:41:1: exported: exported method Shell.Parse should have comment or be unexported (revive)
internal/command/commandargs/shell.go:51:1: exported: exported method Shell.GetArguments should have comment or be unexported (revive)
internal/command/commandargs/shell.go:57:10: ST1005: error strings should not be capitalized (stylecheck)
internal/command/commandargs/shell.go:61:10: ST1005: error strings should not be capitalized (stylecheck)
internal/command/commandargs/shell.go:69:6: var-naming: var keyId should be keyID (revive)
internal/command/commandargs/shell.go:98:6: var-naming: func tryParseKeyId should be tryParseKeyID (revive)
internal/command/commandargs/shell.go:106:1: exported: exported method Shell.ParseCommand should have comment or be unexported (revive)
internal/command/lfsauthenticate/lfsauthenticate.go:87:13: Error return value of `fmt.Fprintf` is not checked (errcheck) internal/command/lfsauthenticate/lfsauthenticate.go:87:13: Error return value of `fmt.Fprintf` is not checked (errcheck)
internal/command/lfstransfer/gitlab_backend.go:40:6: exported: exported type GitlabAuthentication should have comment or be unexported (revive) internal/command/lfstransfer/gitlab_backend.go:40:6: exported: exported type GitlabAuthentication should have comment or be unexported (revive)
internal/command/lfstransfer/gitlab_backend.go:45:6: exported: exported type GitlabBackend should have comment or be unexported (revive) internal/command/lfstransfer/gitlab_backend.go:45:6: exported: exported type GitlabBackend should have comment or be unexported (revive)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment