github.com/trgill/moby@v1.13.1/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/pkg/integration/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 loginning 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 } 31 32 func (s *DockerRegistryAuthHtpasswdSuite) TestLoginToPrivateRegistryDeprecatedEmailFlag(c *check.C) { 33 // Test to make sure login still works with the deprecated -e and --email flags 34 // wrong credentials 35 out, _, err := dockerCmdWithError("login", "-u", s.reg.username, "-p", "WRONGPASSWORD", "-e", s.reg.email, privateRegistryURL) 36 c.Assert(err, checker.NotNil, check.Commentf(out)) 37 c.Assert(out, checker.Contains, "401 Unauthorized") 38 39 // now it's fine 40 // -e flag 41 dockerCmd(c, "login", "-u", s.reg.username, "-p", s.reg.password, "-e", s.reg.email, privateRegistryURL) 42 // --email flag 43 dockerCmd(c, "login", "-u", s.reg.username, "-p", s.reg.password, "--email", s.reg.email, privateRegistryURL) 44 }