github.com/noxiouz/docker@v0.7.3-0.20160629055221-3d231c78e8c5/integration-cli/docker_api_auth_test.go (about)

     1  package main
     2  
     3  import (
     4  	"net/http"
     5  
     6  	"github.com/docker/docker/pkg/integration/checker"
     7  	"github.com/docker/engine-api/types"
     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  }