docker_api_auth_test.go 676 B

1234567891011121314151617181920212223
  1. package main
  2. import (
  3. "net/http"
  4. "github.com/docker/docker/pkg/integration/checker"
  5. "github.com/docker/engine-api/types"
  6. "github.com/go-check/check"
  7. )
  8. // Test case for #22244
  9. func (s *DockerSuite) TestAuthApi(c *check.C) {
  10. config := types.AuthConfig{
  11. Username: "no-user",
  12. Password: "no-password",
  13. }
  14. expected := "Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password\n"
  15. status, body, err := sockRequest("POST", "/auth", config)
  16. c.Assert(err, check.IsNil)
  17. c.Assert(status, check.Equals, http.StatusUnauthorized)
  18. c.Assert(string(body), checker.Contains, expected, check.Commentf("Expected: %v, got: %v", expected, string(body)))
  19. }