github.com/hms58/moby@v1.13.1/integration-cli/docker_api_auth_test.go (about)

     1  package main
     2  
     3  import (
     4  	"net/http"
     5  
     6  	"github.com/docker/docker/api/types"
     7  	"github.com/docker/docker/pkg/integration/checker"
     8  	"github.com/go-check/check"
     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  
    19  	expected := "Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password"
    20  	status, body, err := sockRequest("POST", "/auth", config)
    21  	c.Assert(err, check.IsNil)
    22  	c.Assert(status, check.Equals, http.StatusUnauthorized)
    23  	msg := getErrorMessage(c, body)
    24  	c.Assert(msg, checker.Contains, expected, check.Commentf("Expected: %v, got: %v", expected, msg))
    25  }