Browse code

integration-cli: DockerRegistryAuthHtpasswdSuite: replace dockerCmd

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2023/07/28 01:27:51
Showing 2 changed files
... ...
@@ -7,6 +7,7 @@ import (
7 7
 	"strings"
8 8
 	"testing"
9 9
 
10
+	"github.com/docker/docker/integration-cli/cli"
10 11
 	"gotest.tools/v3/assert"
11 12
 )
12 13
 
... ...
@@ -30,7 +31,7 @@ func (s *DockerCLILoginSuite) TestLoginWithoutTTY(c *testing.T) {
30 30
 
31 31
 	// run the command and block until it's done
32 32
 	err := cmd.Run()
33
-	assert.ErrorContains(c, err, "") //"Expected non nil err when logging in & TTY not available"
33
+	assert.ErrorContains(c, err, "") // "Expected non nil err when logging in & TTY not available"
34 34
 }
35 35
 
36 36
 func (s *DockerRegistryAuthHtpasswdSuite) TestLoginToPrivateRegistry(c *testing.T) {
... ...
@@ -40,5 +41,5 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestLoginToPrivateRegistry(c *testing.
40 40
 	assert.Assert(c, strings.Contains(out, "401 Unauthorized"))
41 41
 
42 42
 	// now it's fine
43
-	dockerCmd(c, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
43
+	cli.DockerCmd(c, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
44 44
 }
... ...
@@ -9,6 +9,7 @@ import (
9 9
 	"strings"
10 10
 	"testing"
11 11
 
12
+	"github.com/docker/docker/integration-cli/cli"
12 13
 	"github.com/docker/docker/testutil"
13 14
 	"gotest.tools/v3/assert"
14 15
 )
... ...
@@ -26,7 +27,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithExternalAuth(c *testing.
26 26
 	testPath := fmt.Sprintf("%s%c%s", osPath, filepath.ListSeparator, absolute)
27 27
 	c.Setenv("PATH", testPath)
28 28
 
29
-	repoName := fmt.Sprintf("%v/dockercli/busybox:authtest", privateRegistryURL)
29
+	imgRepoName := fmt.Sprintf("%v/dockercli/busybox:authtest", privateRegistryURL)
30 30
 
31 31
 	tmp, err := os.MkdirTemp("", "integration-cli-")
32 32
 	assert.NilError(c, err)
... ...
@@ -46,9 +47,9 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithExternalAuth(c *testing.
46 46
 	assert.Assert(c, !strings.Contains(string(b), `"auth":`))
47 47
 	assert.Assert(c, strings.Contains(string(b), privateRegistryURL))
48 48
 
49
-	_, err = s.d.Cmd("--config", tmp, "tag", "busybox", repoName)
49
+	_, err = s.d.Cmd("--config", tmp, "tag", "busybox", imgRepoName)
50 50
 	assert.NilError(c, err)
51
-	_, err = s.d.Cmd("--config", tmp, "push", repoName)
51
+	_, err = s.d.Cmd("--config", tmp, "push", imgRepoName)
52 52
 	assert.NilError(c, err)
53 53
 	_, err = s.d.Cmd("--config", tmp, "logout", privateRegistryURL)
54 54
 	assert.NilError(c, err)
... ...
@@ -58,7 +59,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithExternalAuth(c *testing.
58 58
 	assert.Assert(c, !strings.Contains(string(b), privateRegistryURL))
59 59
 
60 60
 	// check I cannot pull anymore
61
-	out, err := s.d.Cmd("--config", tmp, "pull", repoName)
61
+	out, err := s.d.Cmd("--config", tmp, "pull", imgRepoName)
62 62
 	assert.ErrorContains(c, err, "", out)
63 63
 	assert.Assert(c, strings.Contains(out, "no basic auth credentials"))
64 64
 }
... ...
@@ -88,14 +89,14 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithWrongHostnamesStored(c *
88 88
 	err = os.WriteFile(configPath, []byte(externalAuthConfig), 0o644)
89 89
 	assert.NilError(c, err)
90 90
 
91
-	dockerCmd(c, "--config", tmp, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
91
+	cli.DockerCmd(c, "--config", tmp, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
92 92
 
93 93
 	b, err := os.ReadFile(configPath)
94 94
 	assert.NilError(c, err)
95 95
 	assert.Assert(c, strings.Contains(string(b), fmt.Sprintf(`"https://%s": {}`, privateRegistryURL)))
96 96
 	assert.Assert(c, strings.Contains(string(b), fmt.Sprintf(`"%s": {}`, privateRegistryURL)))
97 97
 
98
-	dockerCmd(c, "--config", tmp, "logout", privateRegistryURL)
98
+	cli.DockerCmd(c, "--config", tmp, "logout", privateRegistryURL)
99 99
 
100 100
 	b, err = os.ReadFile(configPath)
101 101
 	assert.NilError(c, err)