docker_api_auth_test.go 682 B

12345678910111213141516171819202122232425
  1. package main
  2. import (
  3. "github.com/docker/docker/api/types"
  4. "github.com/docker/docker/client"
  5. "github.com/docker/docker/integration-cli/checker"
  6. "github.com/go-check/check"
  7. "golang.org/x/net/context"
  8. )
  9. // Test case for #22244
  10. func (s *DockerSuite) TestAuthAPI(c *check.C) {
  11. testRequires(c, Network)
  12. config := types.AuthConfig{
  13. Username: "no-user",
  14. Password: "no-password",
  15. }
  16. cli, err := client.NewEnvClient()
  17. c.Assert(err, checker.IsNil)
  18. defer cli.Close()
  19. _, err = cli.RegistryLogin(context.Background(), config)
  20. expected := "Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password"
  21. c.Assert(err.Error(), checker.Contains, expected)
  22. }