|
|
@ -37,7 +37,6 @@ import (
|
|
|
|
_ "github.com/distribution/distribution/v3/registry/auth/token"
|
|
|
|
_ "github.com/distribution/distribution/v3/registry/auth/token"
|
|
|
|
_ "github.com/distribution/distribution/v3/registry/storage/driver/inmemory"
|
|
|
|
_ "github.com/distribution/distribution/v3/registry/storage/driver/inmemory"
|
|
|
|
"github.com/foxcpp/go-mockdns"
|
|
|
|
"github.com/foxcpp/go-mockdns"
|
|
|
|
"github.com/phayes/freeport"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
"golang.org/x/crypto/bcrypt"
|
|
|
|
"golang.org/x/crypto/bcrypt"
|
|
|
|
|
|
|
|
|
|
|
@ -126,12 +125,14 @@ func setup(suite *TestSuite, tlsEnabled, insecure bool, auth string) *registry.R
|
|
|
|
|
|
|
|
|
|
|
|
// Registry config
|
|
|
|
// Registry config
|
|
|
|
config := &configuration.Configuration{}
|
|
|
|
config := &configuration.Configuration{}
|
|
|
|
port, err := freeport.GetFreePort()
|
|
|
|
ln, err := net.Listen("tcp", "127.0.0.1:0")
|
|
|
|
suite.Nil(err, "no error finding free port for test registry")
|
|
|
|
suite.Nil(err, "no error finding free port for test registry")
|
|
|
|
|
|
|
|
defer ln.Close()
|
|
|
|
|
|
|
|
|
|
|
|
// Change the registry host to another host which is not localhost.
|
|
|
|
// Change the registry host to another host which is not localhost.
|
|
|
|
// This is required because Docker enforces HTTP if the registry
|
|
|
|
// This is required because Docker enforces HTTP if the registry
|
|
|
|
// host is localhost/127.0.0.1.
|
|
|
|
// host is localhost/127.0.0.1.
|
|
|
|
|
|
|
|
port := ln.Addr().(*net.TCPAddr).Port
|
|
|
|
if suite.DockerRegistryHost == "" {
|
|
|
|
if suite.DockerRegistryHost == "" {
|
|
|
|
suite.DockerRegistryHost = fmt.Sprintf("helm-test-registry:%d%s", port, suite.Repo)
|
|
|
|
suite.DockerRegistryHost = fmt.Sprintf("helm-test-registry:%d%s", port, suite.Repo)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -146,15 +147,17 @@ func setup(suite *TestSuite, tlsEnabled, insecure bool, auth string) *registry.R
|
|
|
|
suite.Nil(err, "no error creating mock DNS server")
|
|
|
|
suite.Nil(err, "no error creating mock DNS server")
|
|
|
|
suite.srv.PatchNet(net.DefaultResolver)
|
|
|
|
suite.srv.PatchNet(net.DefaultResolver)
|
|
|
|
|
|
|
|
|
|
|
|
config.HTTP.Addr = fmt.Sprintf(":%d", port)
|
|
|
|
config.HTTP.Addr = ln.Addr().String()
|
|
|
|
config.HTTP.DrainTimeout = time.Duration(10) * time.Second
|
|
|
|
config.HTTP.DrainTimeout = time.Duration(10) * time.Second
|
|
|
|
config.Storage = map[string]configuration.Parameters{"inmemory": map[string]interface{}{}}
|
|
|
|
config.Storage = map[string]configuration.Parameters{"inmemory": map[string]interface{}{}}
|
|
|
|
|
|
|
|
|
|
|
|
if auth == "token" {
|
|
|
|
if auth == "token" {
|
|
|
|
port, err := freeport.GetFreePort()
|
|
|
|
ln, err := net.Listen("tcp", "127.0.0.1:0")
|
|
|
|
suite.Nil(err, "no error finding free port for test auth server")
|
|
|
|
suite.Nil(err, "no error finding free port for test auth server")
|
|
|
|
|
|
|
|
defer ln.Close()
|
|
|
|
|
|
|
|
|
|
|
|
suite.AuthServerHost = fmt.Sprintf("localhost:%d", port)
|
|
|
|
//set test auth server host
|
|
|
|
|
|
|
|
suite.AuthServerHost = ln.Addr().String()
|
|
|
|
|
|
|
|
|
|
|
|
config.Auth = configuration.Auth{
|
|
|
|
config.Auth = configuration.Auth{
|
|
|
|
"token": configuration.Parameters{
|
|
|
|
"token": configuration.Parameters{
|
|
|
|