Return remote API errors as JSON

Signed-off-by: Ben Firshman <ben@firshman.co.uk>
Upstream-commit: 322e2a7d059a81617b593cf6ece2cfd9f6d4ea03
Component: engine
This commit is contained in:
Ben Firshman
2016-05-21 12:56:04 +01:00
parent 9504e2f68b
commit ecda48bde7
13 changed files with 135 additions and 59 deletions

View File

@ -16,9 +16,10 @@ func (s *DockerSuite) TestAuthApi(c *check.C) {
Password: "no-password",
}
expected := "Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password\n"
expected := "Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password"
status, body, err := sockRequest("POST", "/auth", config)
c.Assert(err, check.IsNil)
c.Assert(status, check.Equals, http.StatusUnauthorized)
c.Assert(string(body), checker.Contains, expected, check.Commentf("Expected: %v, got: %v", expected, string(body)))
msg := getErrorMessage(c, body)
c.Assert(msg, checker.Contains, expected, check.Commentf("Expected: %v, got: %v", expected, msg))
}