github.com/xdlianrong208/docker-ce-comments@v17.12.1-ce-rc2+incompatible/components/engine/integration-cli/docker_api_auth_test.go (about)

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