mirror of
https://github.com/docker/cli.git
synced 2026-11-06 13:10:41 -04:00
This adds an e2e regression test for authenticated pull/push against a private registry, covering the auth regression reported in docker/cli#5963. Includes: - New privateregistry service in the e2e Compose stack with htpasswd auth on port 5001, and --insecure-registry for the engine container. - TestPullPushPrivateRepository test that verifies authenticated push/pull and rejects unauthenticated operations. - Auth config and test credentials in e2e/testdata/registry/. - 90-second retry loop for transient DNS/container startup races. - Service health wait loop in scripts/test/e2e/run. - Increase TestProcessTermination timeout from 10s to 20s for connhelper-ssh + engine 25 combination. - Connhelper-ssh engine Dockerfile for private registry integration. Signed-off-by: Lohit Kolluri <lohitkolluri@gmail.com>
59 lines
1.4 KiB
Go
59 lines
1.4 KiB
Go
package fixtures
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/docker/cli/cli/config"
|
|
"gotest.tools/v3/fs"
|
|
"gotest.tools/v3/icmd"
|
|
)
|
|
|
|
const (
|
|
// AlpineImage is an image in the test registry
|
|
AlpineImage = "registry:5000/alpine:frozen"
|
|
// BusyboxImage is an image in the test registry
|
|
BusyboxImage = "registry:5000/busybox:frozen"
|
|
)
|
|
|
|
// SetupConfigFile creates a config.json file for testing
|
|
func SetupConfigFile(t *testing.T) fs.Dir {
|
|
t.Helper()
|
|
dir := fs.NewDir(t, "trust_test", fs.WithMode(0o700), fs.WithFile("config.json", `{
|
|
"auths": {
|
|
"registry:5000": {
|
|
"auth": "ZWlhaXM6cGFzc3dvcmQK"
|
|
},
|
|
"privateregistry:5001": {
|
|
"auth": "ZTJlOnBhc3N3b3Jk"
|
|
},
|
|
"tlsregistry:5003": {
|
|
"auth": "ZTJlOnBhc3N3b3Jk"
|
|
}
|
|
}}`), fs.WithDir("trust", fs.WithDir("private")))
|
|
return *dir
|
|
}
|
|
|
|
// WithConfig sets an environment variable for the docker config location
|
|
func WithConfig(dir string) func(cmd *icmd.Cmd) {
|
|
return func(cmd *icmd.Cmd) {
|
|
addEnvs(cmd, config.EnvOverrideConfigDir+"="+dir)
|
|
}
|
|
}
|
|
|
|
// WithHome sets the HOME environment variable
|
|
func WithHome(path string) func(*icmd.Cmd) {
|
|
return func(cmd *icmd.Cmd) {
|
|
addEnvs(cmd, "HOME="+path)
|
|
}
|
|
}
|
|
|
|
// addEnvs adds environment variables to cmd, making sure to preserve the
|
|
// current os.Environ(), which would otherwise be omitted (for non-empty .Env).
|
|
func addEnvs(cmd *icmd.Cmd, envs ...string) {
|
|
if len(cmd.Env) == 0 {
|
|
cmd.Env = os.Environ()
|
|
}
|
|
cmd.Env = append(cmd.Env, envs...)
|
|
}
|