Skip to content

Commit

Permalink
fix lint and gofumpt issues
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Lee <[email protected]>
  • Loading branch information
dave-gray101 committed Jun 10, 2024
1 parent f118663 commit a432b80
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion middleware/keyauth/keyauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TokenFromContext(c fiber.Ctx) string {
return token
}

func parseSingleExtractor(keyLookup string, authScheme string) (extractorFunc, error) {
func parseSingleExtractor(keyLookup, authScheme string) (extractorFunc, error) {
parts := strings.Split(keyLookup, ":")
if len(parts) <= 1 {
return nil, fmt.Errorf("invalid keyLookup: %s", keyLookup)
Expand Down
10 changes: 5 additions & 5 deletions middleware/keyauth/keyauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func TestMultipleKeyLookup(t *testing.T) {
authMiddleware := New(Config{
KeyLookup: "header:key",
FallbackKeyLookups: []string{"cookie:key", "query:key"},
Validator: func(c fiber.Ctx, key string) (bool, error) {
Validator: func(_ fiber.Ctx, key string) (bool, error) {
if key == CorrectKey {
return true, nil
}
Expand All @@ -156,24 +156,24 @@ func TestMultipleKeyLookup(t *testing.T) {
// construct the test HTTP request
var req *http.Request
req, err := http.NewRequestWithContext(context.Background(), fiber.MethodGet, "/foo", nil)
require.Equal(t, err, nil)
require.NoError(t, err)
q := req.URL.Query()
q.Add("key", CorrectKey)
req.URL.RawQuery = q.Encode()

res, err := app.Test(req, -1)

require.Equal(t, nil, err, desc)
require.NoError(t, err)

// test the body of the request
body, err := io.ReadAll(res.Body)
require.Equal(t, 200, res.StatusCode, desc)
// body
require.Equal(t, nil, err, desc)
require.NoError(t, err)
require.Equal(t, success, string(body), desc)

err = res.Body.Close()
require.Equal(t, err, nil)
require.NoError(t, err)
}

func Test_MultipleKeyAuth(t *testing.T) {
Expand Down

0 comments on commit a432b80

Please sign in to comment.