From 347b20fc91505584bc9efbeca89590a411b95e79 Mon Sep 17 00:00:00 2001 From: Jeroen Wijenbergh Date: Tue, 6 May 2025 12:40:47 +0200 Subject: All: Run modernize --test --fix --- internal/api/api.go | 2 +- internal/api/api_test.go | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'internal/api') diff --git a/internal/api/api.go b/internal/api/api.go index ea0fc6f..7111c45 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -378,7 +378,7 @@ func getEndpoints(ctx context.Context, url string, tp http.RoundTripper) (*endpo type OAuthLogger struct{} // Logf logs a message with parameters -func (ol *OAuthLogger) Logf(msg string, params ...interface{}) { +func (ol *OAuthLogger) Logf(msg string, params ...any) { log.Logger.Debugf(msg, params...) } diff --git a/internal/api/api_test.go b/internal/api/api_test.go index 2170743..f611f07 100644 --- a/internal/api/api_test.go +++ b/internal/api/api_test.go @@ -21,6 +21,7 @@ import ( "codeberg.org/eduVPN/eduvpn-common/types/protocol" "codeberg.org/eduVPN/eduvpn-common/types/server" "github.com/jwijenbergh/eduoauth-go" + "slices" ) func tokenHandler(t *testing.T, gt []string) func(http.ResponseWriter, *http.Request) { @@ -38,20 +39,18 @@ func tokenHandler(t *testing.T, gt []string) func(http.ResponseWriter, *http.Req } grant := parsed.Get("grant_type") - for _, v := range gt { - if v == grant { - _, err = w.Write([]byte(` + if slices.Contains(gt, grant) { + _, err = w.Write([]byte(` { "access_token": "validaccess", "refresh_token": "validrefresh", "expires_in": 3600 } `)) - if err != nil { - t.Fatalf("failed writing in token handler: %v", err) - } - return + if err != nil { + t.Fatalf("failed writing in token handler: %v", err) } + return } t.Fatalf("grant type: %v, not allowed", grant) } @@ -260,7 +259,7 @@ func TestAPIInfo(t *testing.T) { cases := []struct { hp test.HandlerPath info *profiles.Info - err interface{} + err any }{ { hp: test.HandlerPath{ -- cgit v1.2.3