From 3c670635c27de9a41278af03c12837be9e5d0b78 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 28 Mar 2026 17:08:38 +0100 Subject: [PATCH] internal/client/auth/challenge: fix minor linting issues Signed-off-by: Sebastiaan van Stijn --- internal/client/auth/challenge/authchallenge.go | 2 +- .../client/auth/challenge/authchallenge_test.go | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/client/auth/challenge/authchallenge.go b/internal/client/auth/challenge/authchallenge.go index 4aaebcd27..d4cd3bde6 100644 --- a/internal/client/auth/challenge/authchallenge.go +++ b/internal/client/auth/challenge/authchallenge.go @@ -199,7 +199,7 @@ func expectToken(s string) (token, rest string) { } func expectTokenOrQuoted(s string) (value string, rest string) { - if !strings.HasPrefix(s, "\"") { + if !strings.HasPrefix(s, `"`) { return expectToken(s) } s = s[1:] diff --git a/internal/client/auth/challenge/authchallenge_test.go b/internal/client/auth/challenge/authchallenge_test.go index 6e485e359..7ef452e15 100644 --- a/internal/client/auth/challenge/authchallenge_test.go +++ b/internal/client/auth/challenge/authchallenge_test.go @@ -50,26 +50,26 @@ func TestAuthChallengeNormalization(t *testing.T) { func testAuthChallengeNormalization(t *testing.T, host string) { scm := NewSimpleManager() - url, err := url.Parse(fmt.Sprintf("http://%s/v2/", host)) + hostURL, err := url.Parse(fmt.Sprintf("https://%s/v2/", host)) if err != nil { t.Fatal(err) } resp := &http.Response{ Request: &http.Request{ - URL: url, + URL: hostURL, }, Header: make(http.Header), StatusCode: http.StatusUnauthorized, } - resp.Header.Add("WWW-Authenticate", fmt.Sprintf("Bearer realm=\"https://%s/token\",service=\"registry.example.com\"", host)) + resp.Header.Add("WWW-Authenticate", fmt.Sprintf(`Bearer realm="https://%s/token",service="registry.example.com"`, host)) err = scm.AddResponse(resp) if err != nil { t.Fatal(err) } - lowered := *url + lowered := *hostURL lowered.Host = canonicalAddr(&lowered) c, err := scm.GetChallenges(lowered) if err != nil { @@ -84,19 +84,19 @@ func testAuthChallengeNormalization(t *testing.T, host string) { func testAuthChallengeConcurrent(t *testing.T, host string) { scm := NewSimpleManager() - url, err := url.Parse(fmt.Sprintf("http://%s/v2/", host)) + hostURL, err := url.Parse(fmt.Sprintf("https://%s/v2/", host)) if err != nil { t.Fatal(err) } resp := &http.Response{ Request: &http.Request{ - URL: url, + URL: hostURL, }, Header: make(http.Header), StatusCode: http.StatusUnauthorized, } - resp.Header.Add("WWW-Authenticate", fmt.Sprintf("Bearer realm=\"https://%s/token\",service=\"registry.example.com\"", host)) + resp.Header.Add("WWW-Authenticate", fmt.Sprintf(`Bearer realm="https://%s/token",service="registry.example.com"`, host)) var s sync.WaitGroup s.Add(2) go func() { @@ -110,7 +110,7 @@ func testAuthChallengeConcurrent(t *testing.T, host string) { }() go func() { defer s.Done() - lowered := *url + lowered := *hostURL lowered.Host = strings.ToLower(lowered.Host) for range 200 { _, err := scm.GetChallenges(lowered)