Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Antonio Murdaca authored on 2016/03/19 02:54:05... | ... |
@@ -93,7 +93,8 @@ func retryOnError(err error) error { |
93 | 93 |
return xfer.DoNotRetry{Err: err} |
94 | 94 |
} |
95 | 95 |
case *url.Error: |
96 |
- if v.Err == auth.ErrNoBasicAuthCredentials { |
|
96 |
+ switch v.Err { |
|
97 |
+ case auth.ErrNoBasicAuthCredentials, auth.ErrNoToken: |
|
97 | 98 |
return xfer.DoNotRetry{Err: v.Err} |
98 | 99 |
} |
99 | 100 |
return retryOnError(v.Err) |
... | ... |
@@ -546,6 +546,7 @@ func (s *DockerSuite) TestPushToCentralRegistryUnauthorized(c *check.C) { |
546 | 546 |
dockerCmd(c, "tag", "busybox", repoName) |
547 | 547 |
out, _, err := dockerCmdWithError("push", repoName) |
548 | 548 |
c.Assert(err, check.NotNil, check.Commentf(out)) |
549 |
+ c.Assert(out, check.Not(checker.Contains), "Retrying") |
|
549 | 550 |
c.Assert(out, checker.Contains, "unauthorized: access to the requested resource is not authorized") |
550 | 551 |
} |
551 | 552 |
|
... | ... |
@@ -607,3 +608,16 @@ func (s *DockerRegistryAuthTokenSuite) TestPushMisconfiguredTokenServiceResponse |
607 | 607 |
split := strings.Split(out, "\n") |
608 | 608 |
c.Assert(split[len(split)-2], checker.Contains, "error parsing HTTP 403 response body: ") |
609 | 609 |
} |
610 |
+ |
|
611 |
+func (s *DockerRegistryAuthTokenSuite) TestPushMisconfiguredTokenServiceResponseNoToken(c *check.C) { |
|
612 |
+ ts := getTestTokenService(http.StatusOK, `{"something": "wrong"}`) |
|
613 |
+ defer ts.Close() |
|
614 |
+ s.setupRegistryWithTokenService(c, ts.URL) |
|
615 |
+ repoName := fmt.Sprintf("%s/busybox", privateRegistryURL) |
|
616 |
+ dockerCmd(c, "tag", "busybox", repoName) |
|
617 |
+ out, _, err := dockerCmdWithError("push", repoName) |
|
618 |
+ c.Assert(err, check.NotNil, check.Commentf(out)) |
|
619 |
+ c.Assert(out, checker.Not(checker.Contains), "Retrying") |
|
620 |
+ split := strings.Split(out, "\n") |
|
621 |
+ c.Assert(split[len(split)-2], check.Equals, "authorization server did not include a token in the response") |
|
622 |
+} |