github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/integration-cli/docker_cli_login_test.go (about)

     1  package main
     2  
     3  import (
     4  	"bytes"
     5  	"os/exec"
     6  
     7  	"github.com/docker/docker/integration-cli/checker"
     8  	"github.com/go-check/check"
     9  )
    10  
    11  func (s *DockerSuite) TestLoginWithoutTTY(c *check.C) {
    12  	cmd := exec.Command(dockerBinary, "login")
    13  
    14  	// Send to stdin so the process does not get the TTY
    15  	cmd.Stdin = bytes.NewBufferString("buffer test string \n")
    16  
    17  	// run the command and block until it's done
    18  	err := cmd.Run()
    19  	c.Assert(err, checker.NotNil) //"Expected non nil err when logging in & TTY not available"
    20  }
    21  
    22  func (s *DockerRegistryAuthHtpasswdSuite) TestLoginToPrivateRegistry(c *check.C) {
    23  	// wrong credentials
    24  	out, _, err := dockerCmdWithError("login", "-u", s.reg.Username(), "-p", "WRONGPASSWORD", privateRegistryURL)
    25  	c.Assert(err, checker.NotNil, check.Commentf(out))
    26  	c.Assert(out, checker.Contains, "401 Unauthorized")
    27  
    28  	// now it's fine
    29  	dockerCmd(c, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
    30  }