Skip to content

Commit

Permalink
Fix lint errors from new golangci-lint (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
ewanharris authored Feb 21, 2024
1 parent f9765fc commit c2b8f43
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion authentication/authentication_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (o *requestOption) apply(r *http.Request, b url.Values) {

// Header configures a request to add HTTP headers to requests made to Auth0.
func Header(key, value string) RequestOption {
return newRequestOption(func(r *http.Request, b url.Values) {
return newRequestOption(func(r *http.Request, _ url.Values) {
r.Header.Set(key, value)
})
}
18 changes: 9 additions & 9 deletions authentication/authentication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func TestUserInfo(t *testing.T) {

func TestAuth0Client(t *testing.T) {
t.Run("Defaults to the default data", func(t *testing.T) {
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
header := r.Header.Get("Auth0-Client")
auth0ClientDecoded, err := base64.StdEncoding.DecodeString(header)
assert.NoError(t, err)
Expand Down Expand Up @@ -245,7 +245,7 @@ func TestAuth0Client(t *testing.T) {
})

t.Run("Allows disabling Auth0ClientInfo", func(t *testing.T) {
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
rawHeader := r.Header.Get("Auth0-Client")
assert.Empty(t, rawHeader)
})
Expand All @@ -268,7 +268,7 @@ func TestAuth0Client(t *testing.T) {
})

t.Run("Allows passing extra env info", func(t *testing.T) {
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
header := r.Header.Get("Auth0-Client")
auth0ClientDecoded, err := base64.StdEncoding.DecodeString(header)
assert.NoError(t, err)
Expand Down Expand Up @@ -300,7 +300,7 @@ func TestAuth0Client(t *testing.T) {
})

t.Run("Handles when client info has been disabled", func(t *testing.T) {
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
header := r.Header.Get("Auth0-Client")
assert.Equal(t, "", header)
})
Expand Down Expand Up @@ -328,7 +328,7 @@ func TestRetries(t *testing.T) {
start := time.Now()
i := 0

h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
i++
if i == 1 {
w.WriteHeader(http.StatusTooManyRequests)
Expand Down Expand Up @@ -360,7 +360,7 @@ func TestRetries(t *testing.T) {
start := time.Now()
i := 0

h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
i++
if i < 2 {
w.WriteHeader(http.StatusBadGateway)
Expand Down Expand Up @@ -393,7 +393,7 @@ func TestRetries(t *testing.T) {
t.Run("Disabling retries", func(t *testing.T) {
i := 0

h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
i++
w.WriteHeader(http.StatusBadGateway)
})
Expand All @@ -419,7 +419,7 @@ func TestRetries(t *testing.T) {
i := 0
ctx, cancel := context.WithCancel(context.Background())

h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
i++
cancel()
w.WriteHeader(http.StatusBadGateway)
Expand Down Expand Up @@ -448,7 +448,7 @@ func TestWithClockTolerance(t *testing.T) {
idTokenClientID := "test-client-id"

var idToken string
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
tokenSet := &oauth.TokenSet{
AccessToken: "test-access-token",
ExpiresIn: 86400,
Expand Down
2 changes: 1 addition & 1 deletion authentication/oauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ func withIDToken(t *testing.T, extras map[string]interface{}) (*Authentication,
idTokenClientid := "test-client-id"

var idToken string
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
tokenSet := &oauth.TokenSet{
AccessToken: "test-access-token",
ExpiresIn: 86400,
Expand Down
20 changes: 10 additions & 10 deletions internal/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestRetries(t *testing.T) {
start := time.Now()
i := 0

h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
i++
if i == 1 {
w.WriteHeader(http.StatusTooManyRequests)
Expand All @@ -48,7 +48,7 @@ func TestRetries(t *testing.T) {

t.Run("Max retries", func(t *testing.T) {
i := 0
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
i++
if i <= 5 {
w.WriteHeader(http.StatusGatewayTimeout)
Expand All @@ -71,7 +71,7 @@ func TestRetries(t *testing.T) {

t.Run("Pass empty struct to disable", func(t *testing.T) {
i := 0
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
i++
if i <= 2 {
w.WriteHeader(http.StatusGatewayTimeout)
Expand All @@ -94,7 +94,7 @@ func TestRetries(t *testing.T) {
t.Run("Should retry errors", func(t *testing.T) {
start := time.Now()

h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
h := http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {})

s := httptest.NewUnstartedServer(h)
c := WrapWithTokenSource(s.Client(), StaticToken(""), WithRetries(DefaultRetryOptions))
Expand All @@ -109,7 +109,7 @@ func TestRetries(t *testing.T) {
t.Run("Should not retry some errors", func(t *testing.T) {
i := 0
start := time.Now()
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
i++
w.WriteHeader(http.StatusOK)
})
Expand All @@ -128,7 +128,7 @@ func TestRetries(t *testing.T) {
start := time.Now()
i := 0

h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
i++
if i == 1 {
t.Log(start.Unix())
Expand Down Expand Up @@ -160,7 +160,7 @@ func TestRetries(t *testing.T) {
start := time.Now()
i := 0

h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
i++
if i == 1 {
t.Log(start.Unix())
Expand Down Expand Up @@ -190,7 +190,7 @@ func TestRetries(t *testing.T) {
}

func TestWrapUserAgent(t *testing.T) {
testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
testHandler := http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
ua := r.Header.Get("User-Agent")
if ua != UserAgent {
t.Errorf("Expected User-Agent header to match %q but got %q", UserAgent, ua)
Expand Down Expand Up @@ -239,7 +239,7 @@ func TestOAuth2ClientCredentialsAndAudience(t *testing.T) {

func TestWrapAuth0ClientInfo(t *testing.T) {
t.Run("Default client", func(t *testing.T) {
testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
testHandler := http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
header := r.Header.Get("Auth0-Client")
auth0ClientDecoded, err := base64.StdEncoding.DecodeString(header)
assert.NoError(t, err)
Expand Down Expand Up @@ -282,7 +282,7 @@ func TestWrapAuth0ClientInfo(t *testing.T) {

for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
testHandler := http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
header := r.Header.Get("Auth0-Client")
assert.Equal(t, testCase.expected, header)
})
Expand Down
2 changes: 1 addition & 1 deletion internal/idtokenvalidator/idtokenvalidator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ func configureSigning(t *testing.T, args jwtArgs) (jwa.SignatureAlgorithm, jwk.K
if err != nil {
return jwa.RS256, nil, nil, err
}
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
b, err := json.Marshal(publicKey)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
Expand Down
16 changes: 8 additions & 8 deletions management/management_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func TestManagement_URI(t *testing.T) {

func TestAuth0Client(t *testing.T) {
t.Run("Defaults to the default data", func(t *testing.T) {
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
header := r.Header.Get("Auth0-Client")
auth0ClientDecoded, err := base64.StdEncoding.DecodeString(header)
assert.NoError(t, err)
Expand All @@ -317,7 +317,7 @@ func TestAuth0Client(t *testing.T) {
})

t.Run("Allows disabling Auth0ClientInfo", func(t *testing.T) {
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
rawHeader := r.Header.Get("Auth0-Client")
assert.Empty(t, rawHeader)
})
Expand All @@ -334,7 +334,7 @@ func TestAuth0Client(t *testing.T) {
})

t.Run("Allows passing extra env info", func(t *testing.T) {
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
header := r.Header.Get("Auth0-Client")
auth0ClientDecoded, err := base64.StdEncoding.DecodeString(header)
assert.NoError(t, err)
Expand All @@ -361,7 +361,7 @@ func TestAuth0Client(t *testing.T) {
})

t.Run("Handles when client info has been disabled", func(t *testing.T) {
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
header := r.Header.Get("Auth0-Client")
assert.Equal(t, "", header)
})
Expand Down Expand Up @@ -399,7 +399,7 @@ func TestRetries(t *testing.T) {
start := time.Now()
i := 0

h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
i++
if i == 1 {
w.WriteHeader(http.StatusTooManyRequests)
Expand Down Expand Up @@ -429,7 +429,7 @@ func TestRetries(t *testing.T) {
start := time.Now()
i := 0

h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
i++
if i < 2 {
w.WriteHeader(http.StatusBadGateway)
Expand Down Expand Up @@ -460,7 +460,7 @@ func TestRetries(t *testing.T) {
t.Run("Disabling retries", func(t *testing.T) {
i := 0

h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
i++
w.WriteHeader(http.StatusBadGateway)
})
Expand All @@ -484,7 +484,7 @@ func TestRetries(t *testing.T) {
i := 0
ctx, cancel := context.WithCancel(context.Background())

h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
i++
cancel()
w.WriteHeader(http.StatusBadGateway)
Expand Down

0 comments on commit c2b8f43

Please sign in to comment.