mirror of
https://github.com/distribution/distribution.git
synced 2026-08-08 16:04:52 +00:00
internal/client/auth/challenge: fix minor linting issues
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -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:]
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user