diff --git a/authentication/authentication_request.go b/authentication/authentication_request.go index 4882467a..8f18e3e7 100644 --- a/authentication/authentication_request.go +++ b/authentication/authentication_request.go @@ -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) }) } diff --git a/authentication/authentication_test.go b/authentication/authentication_test.go index c0d35dca..ff91ecd9 100644 --- a/authentication/authentication_test.go +++ b/authentication/authentication_test.go @@ -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) @@ -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) }) @@ -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) @@ -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) }) @@ -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) @@ -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) @@ -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) }) @@ -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) @@ -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, diff --git a/authentication/oauth_test.go b/authentication/oauth_test.go index 26120d3e..69c638d3 100644 --- a/authentication/oauth_test.go +++ b/authentication/oauth_test.go @@ -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, diff --git a/internal/client/client_test.go b/internal/client/client_test.go index eaa1fca6..daf1cdf2 100644 --- a/internal/client/client_test.go +++ b/internal/client/client_test.go @@ -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) @@ -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) @@ -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) @@ -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)) @@ -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) }) @@ -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()) @@ -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()) @@ -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) @@ -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) @@ -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) }) diff --git a/internal/idtokenvalidator/idtokenvalidator_test.go b/internal/idtokenvalidator/idtokenvalidator_test.go index 2805f41b..9bdb1695 100644 --- a/internal/idtokenvalidator/idtokenvalidator_test.go +++ b/internal/idtokenvalidator/idtokenvalidator_test.go @@ -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) diff --git a/management/management_test.go b/management/management_test.go index 3a762913..49c28dff 100644 --- a/management/management_test.go +++ b/management/management_test.go @@ -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) @@ -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) }) @@ -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) @@ -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) }) @@ -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) @@ -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) @@ -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) }) @@ -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)