docker_cli_login_test.go 936 B

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