Merge pull request #30916 from jessesimpson36/v3-remove-registry-login-url-with-tests

test: add functional tests for "Fix 3.18.0 regression: registry login with scheme"
pull/30941/head
Scott Rigby 4 months ago committed by GitHub
commit 62759a819e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -28,6 +28,7 @@ import (
type HTTPRegistryClientTestSuite struct {
TestSuite
protocol string
}
func (suite *HTTPRegistryClientTestSuite) SetupSuite() {
@ -56,14 +57,23 @@ func (suite *HTTPRegistryClientTestSuite) Test_0_Login() {
}
func (suite *HTTPRegistryClientTestSuite) Test_1_Push() {
if suite.protocol != "" || suite.Repo != "" {
suite.T().Skip("Skipping we don't strip protocol or repo prior to execution")
}
testPush(&suite.TestSuite)
}
func (suite *HTTPRegistryClientTestSuite) Test_2_Pull() {
if suite.protocol != "" || suite.Repo != "" {
suite.T().Skip("Skipping we don't strip protocol or repo prior to execution")
}
testPull(&suite.TestSuite)
}
func (suite *HTTPRegistryClientTestSuite) Test_3_Tags() {
if suite.protocol != "" || suite.Repo != "" {
suite.T().Skip("Skipping we don't strip protocol or repo prior to execution")
}
testTags(&suite.TestSuite)
}
@ -78,4 +88,14 @@ func (suite *HTTPRegistryClientTestSuite) Test_4_ManInTheMiddle() {
func TestHTTPRegistryClientTestSuite(t *testing.T) {
suite.Run(t, new(HTTPRegistryClientTestSuite))
var suiteWithRepo = new(HTTPRegistryClientTestSuite)
suiteWithRepo.Repo = "/testrepo/"
suite.Run(t, suiteWithRepo)
for _, protocol := range []string{"oci://", "http://", "https://"} {
var protocolSpecificTestSuite = new(HTTPRegistryClientTestSuite)
protocolSpecificTestSuite.protocol = protocol
protocolSpecificTestSuite.DockerRegistryHost = protocol + "helm-test-registry"
suite.Run(t, protocolSpecificTestSuite)
}
}

@ -65,6 +65,7 @@ type TestSuite struct {
CompromisedRegistryHost string
WorkspaceDir string
RegistryClient *Client
Repo string
// A mock DNS server needed for TLS connection testing.
srv *mockdns.Server
@ -127,7 +128,12 @@ func setup(suite *TestSuite, tlsEnabled, insecure bool) *registry.Registry {
// Change the registry host to another host which is not localhost.
// This is required because Docker enforces HTTP if the registry
// host is localhost/127.0.0.1.
suite.DockerRegistryHost = fmt.Sprintf("helm-test-registry:%d", port)
if suite.DockerRegistryHost == "" {
suite.DockerRegistryHost = fmt.Sprintf("helm-test-registry:%d%s", port, suite.Repo)
} else {
// may programmatically set this for custom protocol handling
suite.DockerRegistryHost = fmt.Sprintf("%s:%d%s", suite.DockerRegistryHost, port, suite.Repo)
}
suite.srv, err = mockdns.NewServer(map[string]mockdns.Zone{
"helm-test-registry.": {
A: []string{"127.0.0.1"},

Loading…
Cancel
Save