internal/client/auth/challenge: fix minor linting issues

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2026-03-28 17:08:38 +01:00
parent 055cc71b4e
commit 3c670635c2
2 changed files with 9 additions and 9 deletions

View File

@@ -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:]

View File

@@ -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)