|
@@ -9,6 +9,7 @@ import (
|
|
|
"strings"
|
|
|
"testing"
|
|
|
|
|
|
+ "github.com/docker/docker/integration-cli/cli"
|
|
|
"github.com/docker/docker/testutil"
|
|
|
"gotest.tools/v3/assert"
|
|
|
)
|
|
@@ -26,7 +27,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithExternalAuth(c *testing.
|
|
|
testPath := fmt.Sprintf("%s%c%s", osPath, filepath.ListSeparator, absolute)
|
|
|
c.Setenv("PATH", testPath)
|
|
|
|
|
|
- repoName := fmt.Sprintf("%v/dockercli/busybox:authtest", privateRegistryURL)
|
|
|
+ imgRepoName := fmt.Sprintf("%v/dockercli/busybox:authtest", privateRegistryURL)
|
|
|
|
|
|
tmp, err := os.MkdirTemp("", "integration-cli-")
|
|
|
assert.NilError(c, err)
|
|
@@ -46,9 +47,9 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithExternalAuth(c *testing.
|
|
|
assert.Assert(c, !strings.Contains(string(b), `"auth":`))
|
|
|
assert.Assert(c, strings.Contains(string(b), privateRegistryURL))
|
|
|
|
|
|
- _, err = s.d.Cmd("--config", tmp, "tag", "busybox", repoName)
|
|
|
+ _, err = s.d.Cmd("--config", tmp, "tag", "busybox", imgRepoName)
|
|
|
assert.NilError(c, err)
|
|
|
- _, err = s.d.Cmd("--config", tmp, "push", repoName)
|
|
|
+ _, err = s.d.Cmd("--config", tmp, "push", imgRepoName)
|
|
|
assert.NilError(c, err)
|
|
|
_, err = s.d.Cmd("--config", tmp, "logout", privateRegistryURL)
|
|
|
assert.NilError(c, err)
|
|
@@ -58,7 +59,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithExternalAuth(c *testing.
|
|
|
assert.Assert(c, !strings.Contains(string(b), privateRegistryURL))
|
|
|
|
|
|
// check I cannot pull anymore
|
|
|
- out, err := s.d.Cmd("--config", tmp, "pull", repoName)
|
|
|
+ out, err := s.d.Cmd("--config", tmp, "pull", imgRepoName)
|
|
|
assert.ErrorContains(c, err, "", out)
|
|
|
assert.Assert(c, strings.Contains(out, "no basic auth credentials"))
|
|
|
}
|
|
@@ -88,14 +89,14 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithWrongHostnamesStored(c *
|
|
|
err = os.WriteFile(configPath, []byte(externalAuthConfig), 0o644)
|
|
|
assert.NilError(c, err)
|
|
|
|
|
|
- dockerCmd(c, "--config", tmp, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
|
|
|
+ cli.DockerCmd(c, "--config", tmp, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
|
|
|
|
|
|
b, err := os.ReadFile(configPath)
|
|
|
assert.NilError(c, err)
|
|
|
assert.Assert(c, strings.Contains(string(b), fmt.Sprintf(`"https://%s": {}`, privateRegistryURL)))
|
|
|
assert.Assert(c, strings.Contains(string(b), fmt.Sprintf(`"%s": {}`, privateRegistryURL)))
|
|
|
|
|
|
- dockerCmd(c, "--config", tmp, "logout", privateRegistryURL)
|
|
|
+ cli.DockerCmd(c, "--config", tmp, "logout", privateRegistryURL)
|
|
|
|
|
|
b, err = os.ReadFile(configPath)
|
|
|
assert.NilError(c, err)
|