github.com/noxiouz/docker@v0.7.3-0.20160629055221-3d231c78e8c5/integration-cli/docker_cli_logout_test.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "io/ioutil" 6 "os" 7 "path/filepath" 8 9 "github.com/docker/docker/pkg/integration/checker" 10 "github.com/go-check/check" 11 ) 12 13 func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithExternalAuth(c *check.C) { 14 osPath := os.Getenv("PATH") 15 defer os.Setenv("PATH", osPath) 16 17 workingDir, err := os.Getwd() 18 c.Assert(err, checker.IsNil) 19 absolute, err := filepath.Abs(filepath.Join(workingDir, "fixtures", "auth")) 20 c.Assert(err, checker.IsNil) 21 testPath := fmt.Sprintf("%s%c%s", osPath, filepath.ListSeparator, absolute) 22 23 os.Setenv("PATH", testPath) 24 25 repoName := fmt.Sprintf("%v/dockercli/busybox:authtest", privateRegistryURL) 26 27 tmp, err := ioutil.TempDir("", "integration-cli-") 28 c.Assert(err, checker.IsNil) 29 30 externalAuthConfig := `{ "credsStore": "shell-test" }` 31 32 configPath := filepath.Join(tmp, "config.json") 33 err = ioutil.WriteFile(configPath, []byte(externalAuthConfig), 0644) 34 c.Assert(err, checker.IsNil) 35 36 dockerCmd(c, "--config", tmp, "login", "-u", s.reg.username, "-p", s.reg.password, privateRegistryURL) 37 38 b, err := ioutil.ReadFile(configPath) 39 c.Assert(err, checker.IsNil) 40 c.Assert(string(b), checker.Not(checker.Contains), "\"auth\":") 41 c.Assert(string(b), checker.Contains, privateRegistryURL) 42 43 dockerCmd(c, "--config", tmp, "tag", "busybox", repoName) 44 dockerCmd(c, "--config", tmp, "push", repoName) 45 46 dockerCmd(c, "--config", tmp, "logout", privateRegistryURL) 47 48 b, err = ioutil.ReadFile(configPath) 49 c.Assert(err, checker.IsNil) 50 c.Assert(string(b), checker.Not(checker.Contains), privateRegistryURL) 51 52 // check I cannot pull anymore 53 out, _, err := dockerCmdWithError("--config", tmp, "pull", repoName) 54 c.Assert(err, check.NotNil, check.Commentf(out)) 55 c.Assert(out, checker.Contains, "Error: image dockercli/busybox:authtest not found") 56 }