Skip to content

Commit 39ca1a6

Browse files
ashmckenzieArchish27
authored andcommitted
Merge branch '796-accessverifier-lint' into 'main'
Lint fixes in accessverifier package Closes #796 See merge request https://gitlab.com/gitlab-org/gitlab-shell/-/merge_requests/1153 Merged-by: Ash McKenzie <[email protected]> Approved-by: Ash McKenzie <[email protected]> Co-authored-by: Archish <[email protected]>
2 parents f3f0958 + 13f3194 commit 39ca1a6

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

internal/command/shared/accessverifier/accessverifier.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package accessverifier handles the verification of access permission.
12
package accessverifier
23

34
import (
@@ -11,14 +12,17 @@ import (
1112
"gitlab.com/gitlab-org/gitlab-shell/v14/internal/gitlabnet/accessverifier"
1213
)
1314

15+
// Response is an alias for accessverifier.Response, representing the result of an access verification.
1416
type Response = accessverifier.Response
1517

18+
// Command handles access verification commands.
1619
type Command struct {
1720
Config *config.Config
1821
Args *commandargs.Shell
1922
ReadWriter *readwriter.ReadWriter
2023
}
2124

25+
// Verify checks access permissions and returns a response.
2226
func (c *Command) Verify(ctx context.Context, action commandargs.CommandType, repo string) (*Response, error) {
2327
client, err := accessverifier.NewClient(c.Config)
2428
if err != nil {

internal/command/shared/accessverifier/accessverifier_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"net/http"
99
"testing"
1010

11+
"github.com/stretchr/testify/assert"
1112
"github.com/stretchr/testify/require"
1213

1314
"gitlab.com/gitlab-org/gitlab-shell/v14/client/testserver"
@@ -28,23 +29,23 @@ func setup(t *testing.T) (*Command, *bytes.Buffer, *bytes.Buffer) {
2829
Path: "/api/v4/internal/allowed",
2930
Handler: func(w http.ResponseWriter, r *http.Request) {
3031
b, err := io.ReadAll(r.Body)
31-
require.NoError(t, err)
32+
assert.NoError(t, err)
3233

3334
var requestBody *accessverifier.Request
3435
err = json.Unmarshal(b, &requestBody)
35-
require.NoError(t, err)
36+
assert.NoError(t, err)
3637

3738
if requestBody.KeyID == "1" {
3839
body := map[string]interface{}{
3940
"gl_console_messages": []string{"console", "message"},
4041
}
41-
require.NoError(t, json.NewEncoder(w).Encode(body))
42+
assert.NoError(t, json.NewEncoder(w).Encode(body))
4243
} else {
4344
body := map[string]interface{}{
4445
"status": false,
4546
"message": "missing user",
4647
}
47-
require.NoError(t, json.NewEncoder(w).Encode(body))
48+
assert.NoError(t, json.NewEncoder(w).Encode(body))
4849
}
4950
},
5051
},

support/lint_last_known_acceptable.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,6 @@ internal/command/readwriter/readwriter.go:7:6: exported: exported type ReadWrite
198198
internal/command/receivepack/gitalycall_test.go:24:4: S1038: should use t.Logf(...) instead of t.Log(fmt.Sprintf(...)) (gosimple)
199199
internal/command/receivepack/gitalycall_test.go:31:5: var-naming: struct field keyId should be keyID (revive)
200200
internal/command/receivepack/gitalycall_test.go:98:5: expected-actual: need to reverse actual and expected values (testifylint)
201-
internal/command/shared/accessverifier/accessverifier.go:1:1: package-comments: should have a package comment (revive)
202-
internal/command/shared/accessverifier/accessverifier.go:14:6: exported: exported type Response should have comment or be unexported (revive)
203-
internal/command/shared/accessverifier/accessverifier.go:16:6: exported: exported type Command should have comment or be unexported (revive)
204-
internal/command/shared/accessverifier/accessverifier.go:22:1: exported: exported method Command.Verify should have comment or be unexported (revive)
205-
internal/command/shared/accessverifier/accessverifier_test.go:31:5: go-require: do not use require in http handlers (testifylint)
206-
internal/command/shared/accessverifier/accessverifier_test.go:35:5: go-require: do not use require in http handlers (testifylint)
207-
internal/command/shared/accessverifier/accessverifier_test.go:41:6: go-require: do not use require in http handlers (testifylint)
208-
internal/command/shared/accessverifier/accessverifier_test.go:47:6: go-require: do not use require in http handlers (testifylint)
209201
internal/command/shared/customaction/customaction_test.go:27:5: go-require: do not use require in http handlers (testifylint)
210202
internal/command/shared/customaction/customaction_test.go:30:5: go-require: do not use require in http handlers (testifylint)
211203
internal/command/shared/customaction/customaction_test.go:32:5: go-require: do not use require in http handlers (testifylint)

0 commit comments

Comments
 (0)