oci: add tests for plain HTTP and insecure HTTPS registries

Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
pull/12128/head
Sanskar Jaiswal 1 year ago
parent 2538b927a7
commit 6defb96dac
No known key found for this signature in database
GPG Key ID: 5982D0279C227FFD

@ -39,7 +39,8 @@ func TestOCIGetter(t *testing.T) {
ca, pub, priv := join(cd, "rootca.crt"), join(cd, "crt.pem"), join(cd, "key.pem") ca, pub, priv := join(cd, "rootca.crt"), join(cd, "crt.pem"), join(cd, "key.pem")
timeout := time.Second * 5 timeout := time.Second * 5
transport := &http.Transport{} transport := &http.Transport{}
insecureSkipTLSverify := false insecureSkipVerifyTLS := false
plainHTTP := false
// Test with options // Test with options
g, err = NewOCIGetter( g, err = NewOCIGetter(
@ -47,7 +48,8 @@ func TestOCIGetter(t *testing.T) {
WithTLSClientConfig(pub, priv, ca), WithTLSClientConfig(pub, priv, ca),
WithTimeout(timeout), WithTimeout(timeout),
WithTransport(transport), WithTransport(transport),
WithInsecureSkipVerifyTLS(insecureSkipTLSverify), WithInsecureSkipVerifyTLS(insecureSkipVerifyTLS),
WithPlainHTTP(plainHTTP),
) )
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -86,6 +88,14 @@ func TestOCIGetter(t *testing.T) {
t.Errorf("Expected NewOCIGetter to contain %p as Transport, got %p", transport, og.opts.transport) t.Errorf("Expected NewOCIGetter to contain %p as Transport, got %p", transport, og.opts.transport)
} }
if og.opts.plainHTTP != plainHTTP {
t.Errorf("Expected NewOCIGetter to have plainHTTP as %t, got %t", plainHTTP, og.opts.plainHTTP)
}
if og.opts.insecureSkipVerifyTLS != insecureSkipVerifyTLS {
t.Errorf("Expected NewOCIGetter to have insecureSkipVerifyTLS as %t, got %t", insecureSkipVerifyTLS, og.opts.insecureSkipVerifyTLS)
}
// Test if setting registryClient is being passed to the ops // Test if setting registryClient is being passed to the ops
registryClient, err := registry.NewClient() registryClient, err := registry.NewClient()
if err != nil { if err != nil {

@ -36,11 +36,13 @@ func TestNewOCIPusher(t *testing.T) {
join := filepath.Join join := filepath.Join
ca, pub, priv := join(cd, "rootca.crt"), join(cd, "crt.pem"), join(cd, "key.pem") ca, pub, priv := join(cd, "rootca.crt"), join(cd, "crt.pem"), join(cd, "key.pem")
insecureSkipTLSverify := false insecureSkipTLSverify := false
plainHTTP := false
// Test with options // Test with options
p, err = NewOCIPusher( p, err = NewOCIPusher(
WithTLSClientConfig(pub, priv, ca), WithTLSClientConfig(pub, priv, ca),
WithInsecureSkipTLSVerify(insecureSkipTLSverify), WithInsecureSkipTLSVerify(insecureSkipTLSverify),
WithPlainHTTP(plainHTTP),
) )
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -63,6 +65,14 @@ func TestNewOCIPusher(t *testing.T) {
t.Errorf("Expected NewOCIPusher to contain %q as the CA file, got %q", ca, op.opts.caFile) t.Errorf("Expected NewOCIPusher to contain %q as the CA file, got %q", ca, op.opts.caFile)
} }
if op.opts.plainHTTP != plainHTTP {
t.Errorf("Expected NewOCIPusher to have plainHTTP as %t, got %t", plainHTTP, op.opts.plainHTTP)
}
if op.opts.insecureSkipTLSverify != insecureSkipTLSverify {
t.Errorf("Expected NewOCIPusher to have insecureSkipVerifyTLS as %t, got %t", insecureSkipTLSverify, op.opts.insecureSkipTLSverify)
}
// Test if setting registryClient is being passed to the ops // Test if setting registryClient is being passed to the ops
registryClient, err := registry.NewClient() registryClient, err := registry.NewClient()
if err != nil { if err != nil {

@ -0,0 +1,68 @@
/*
Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package registry
import (
"fmt"
"os"
"testing"
"github.com/containerd/containerd/errdefs"
"github.com/stretchr/testify/suite"
)
type HTTPRegistryClientTestSuite struct {
TestSuite
}
func (suite *HTTPRegistryClientTestSuite) SetupSuite() {
// init test client
dockerRegistry := setup(&suite.TestSuite, false, false)
// Start Docker registry
go dockerRegistry.ListenAndServe()
}
func (suite *HTTPRegistryClientTestSuite) TearDownSuite() {
teardown(&suite.TestSuite)
os.RemoveAll(suite.WorkspaceDir)
}
func (suite *HTTPRegistryClientTestSuite) Test_1_Push() {
testPush(&suite.TestSuite)
}
func (suite *HTTPRegistryClientTestSuite) Test_2_Pull() {
testPull(&suite.TestSuite)
}
func (suite *HTTPRegistryClientTestSuite) Test_3_Tags() {
testTags(&suite.TestSuite)
}
func (suite *HTTPRegistryClientTestSuite) Test_4_ManInTheMiddle() {
ref := fmt.Sprintf("%s/testrepo/supposedlysafechart:9.9.9", suite.CompromisedRegistryHost)
// returns content that does not match the expected digest
_, err := suite.RegistryClient.Pull(ref)
suite.NotNil(err)
suite.True(errdefs.IsFailedPrecondition(err))
}
func TestHTTPRegistryClientTestSuite(t *testing.T) {
suite.Run(t, new(HTTPRegistryClientTestSuite))
}

@ -17,65 +17,54 @@ limitations under the License.
package registry package registry
import ( import (
"fmt"
"os" "os"
"testing" "testing"
"github.com/containerd/containerd/errdefs"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )
type RegistryClientTestSuite struct { type InsecureTLSRegistryClientTestSuite struct {
TestSuite TestSuite
} }
func (suite *RegistryClientTestSuite) SetupSuite() { func (suite *InsecureTLSRegistryClientTestSuite) SetupSuite() {
// init test client // init test client
dockerRegistry := setup(&suite.TestSuite, false, false) dockerRegistry := setup(&suite.TestSuite, true, true)
// Start Docker registry // Start Docker registry
go dockerRegistry.ListenAndServe() go dockerRegistry.ListenAndServe()
} }
func (suite *RegistryClientTestSuite) TearDownSuite() { func (suite *InsecureTLSRegistryClientTestSuite) TearDownSuite() {
teardown(&suite.TestSuite)
os.RemoveAll(suite.WorkspaceDir) os.RemoveAll(suite.WorkspaceDir)
} }
func (suite *RegistryClientTestSuite) Test_0_Login() { func (suite *InsecureTLSRegistryClientTestSuite) Test_0_Login() {
err := suite.RegistryClient.Login(suite.DockerRegistryHost, err := suite.RegistryClient.Login(suite.DockerRegistryHost,
LoginOptBasicAuth("badverybad", "ohsobad"),
LoginOptInsecure(false))
suite.NotNil(err, "error logging into registry with bad credentials")
err = suite.RegistryClient.Login(suite.DockerRegistryHost,
LoginOptBasicAuth("badverybad", "ohsobad"), LoginOptBasicAuth("badverybad", "ohsobad"),
LoginOptInsecure(true)) LoginOptInsecure(true))
suite.NotNil(err, "error logging into registry with bad credentials, insecure mode") suite.NotNil(err, "error logging into registry with bad credentials")
err = suite.RegistryClient.Login(suite.DockerRegistryHost,
LoginOptBasicAuth(testUsername, testPassword),
LoginOptInsecure(false))
suite.Nil(err, "no error logging into registry with good credentials")
err = suite.RegistryClient.Login(suite.DockerRegistryHost, err = suite.RegistryClient.Login(suite.DockerRegistryHost,
LoginOptBasicAuth(testUsername, testPassword), LoginOptBasicAuth(testUsername, testPassword),
LoginOptInsecure(true)) LoginOptInsecure(true))
suite.Nil(err, "no error logging into registry with good credentials, insecure mode") suite.Nil(err, "no error logging into registry with good credentials")
} }
func (suite *RegistryClientTestSuite) Test_1_Push() { func (suite *InsecureTLSRegistryClientTestSuite) Test_1_Push() {
testPush(&suite.TestSuite) testPush(&suite.TestSuite)
} }
func (suite *RegistryClientTestSuite) Test_2_Pull() { func (suite *InsecureTLSRegistryClientTestSuite) Test_2_Pull() {
testPull(&suite.TestSuite) testPull(&suite.TestSuite)
} }
func (suite *RegistryClientTestSuite) Test_3_Tags() { func (suite *InsecureTLSRegistryClientTestSuite) Test_3_Tags() {
testTags(&suite.TestSuite) testTags(&suite.TestSuite)
} }
func (suite *RegistryClientTestSuite) Test_4_Logout() { func (suite *InsecureTLSRegistryClientTestSuite) Test_4_Logout() {
err := suite.RegistryClient.Logout("this-host-aint-real:5000") err := suite.RegistryClient.Logout("this-host-aint-real:5000")
suite.NotNil(err, "error logging out of registry that has no entry") suite.NotNil(err, "error logging out of registry that has no entry")
@ -83,15 +72,6 @@ func (suite *RegistryClientTestSuite) Test_4_Logout() {
suite.Nil(err, "no error logging out of registry") suite.Nil(err, "no error logging out of registry")
} }
func (suite *RegistryClientTestSuite) Test_5_ManInTheMiddle() { func TestInsecureTLSRegistryClientTestSuite(t *testing.T) {
ref := fmt.Sprintf("%s/testrepo/supposedlysafechart:9.9.9", suite.CompromisedRegistryHost) suite.Run(t, new(InsecureTLSRegistryClientTestSuite))
// returns content that does not match the expected digest
_, err := suite.RegistryClient.Pull(ref)
suite.NotNil(err)
suite.True(errdefs.IsFailedPrecondition(err))
}
func TestRegistryClientTestSuite(t *testing.T) {
suite.Run(t, new(RegistryClientTestSuite))
} }

@ -50,11 +50,6 @@ func (suite *TLSRegistryClientTestSuite) Test_0_Login() {
LoginOptBasicAuth(testUsername, testPassword), LoginOptBasicAuth(testUsername, testPassword),
LoginOptTLSClientConfig(tlsCert, tlsKey, tlsCA)) LoginOptTLSClientConfig(tlsCert, tlsKey, tlsCA))
suite.Nil(err, "no error logging into registry with good credentials") suite.Nil(err, "no error logging into registry with good credentials")
err = suite.RegistryClient.Login(suite.DockerRegistryHost,
LoginOptBasicAuth(testUsername, testPassword),
LoginOptTLSClientConfig(tlsCert, tlsKey, tlsCA))
suite.Nil(err, "no error logging into registry with good credentials, insecure mode")
} }
func (suite *TLSRegistryClientTestSuite) Test_1_Push() { func (suite *TLSRegistryClientTestSuite) Test_1_Push() {

@ -1,21 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIDhzCCAm+gAwIBAgIUdI/ees1mQ4N++1jpF5xI5fq6TSUwDQYJKoZIhvcNAQEL
BQAwUjELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMQswCQYDVQQHDAJTRjENMAsG
A1UECgwEaGVsbTEaMBgGA1UEAwwRcmVnaXN0cnktdGVzdC5jb20wIBcNMjIwOTIw
MDgyMDQ2WhgPMzAyMjAxMjEwODIwNDZaM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alGznQxevf5WZb2l5YSxUIZYm
aUAq3dCMLPs+z54G+b51D8cPlNkfhIrg34108hYooQKBgQDWMbc6wY6frvJCmesx
i7F/JHJweqcQdW649RCvtK8M/O062/3vvSNTxqEjPaJOGiD4Cn+D5pYchVujqlTM
8DK77N97NzQvpHm81lpKVIg5sObarvT3RnCSRpOumbX5SCBoBUs+nVC01/zZz79c
AJFLAeHI1RjhB0AFpRDCvZZk6w==
-----END PRIVATE KEY-----

@ -44,11 +44,11 @@ import (
) )
const ( const (
tlsServerKey = "./testdata/tls/server-key.pem" tlsServerKey = "./testdata/tls/server.key"
tlsServerCert = "./testdata/tls/server-cert.pem" tlsServerCert = "./testdata/tls/server.crt"
tlsCA = "./testdata/tls/ca-cert.pem" tlsCA = "./testdata/tls/ca.crt"
tlsKey = "./testdata/tls/client-key.pem" tlsKey = "./testdata/tls/client.key"
tlsCert = "./testdata/tls/client-cert.pem" tlsCert = "./testdata/tls/client.crt"
) )
var ( var (
@ -70,7 +70,7 @@ type TestSuite struct {
srv *mockdns.Server srv *mockdns.Server
} }
func setup(suite *TestSuite, tlsEnabled bool, insecure bool) *registry.Registry { func setup(suite *TestSuite, tlsEnabled, insecure bool) *registry.Registry {
suite.WorkspaceDir = testWorkspaceDir suite.WorkspaceDir = testWorkspaceDir
os.RemoveAll(suite.WorkspaceDir) os.RemoveAll(suite.WorkspaceDir)
os.Mkdir(suite.WorkspaceDir, 0700) os.Mkdir(suite.WorkspaceDir, 0700)
@ -83,31 +83,32 @@ func setup(suite *TestSuite, tlsEnabled bool, insecure bool) *registry.Registry
credentialsFile := filepath.Join(suite.WorkspaceDir, CredentialsFileBasename) credentialsFile := filepath.Join(suite.WorkspaceDir, CredentialsFileBasename)
// init test client // init test client
opts := []ClientOption{
ClientOptDebug(true),
ClientOptEnableCache(true),
ClientOptWriter(suite.Out),
ClientOptCredentialsFile(credentialsFile),
}
if tlsEnabled { if tlsEnabled {
var tlsConf *tls.Config var tlsConf *tls.Config
tlsConf, err = tlsutil.NewClientTLS(tlsCert, tlsKey, tlsCA, insecure) if insecure {
tlsConf, err = tlsutil.NewClientTLS("", "", "", true)
} else {
tlsConf, err = tlsutil.NewClientTLS(tlsCert, tlsKey, tlsCA, false)
}
httpClient := &http.Client{ httpClient := &http.Client{
Transport: &http.Transport{ Transport: &http.Transport{
TLSClientConfig: tlsConf, TLSClientConfig: tlsConf,
}, },
} }
suite.Nil(err, "no error loading tlsconfog") suite.Nil(err, "no error loading tls config")
suite.RegistryClient, err = NewClient( opts = append(opts, ClientOptHTTPClient(httpClient))
ClientOptDebug(true),
ClientOptEnableCache(true),
ClientOptWriter(suite.Out),
ClientOptCredentialsFile(credentialsFile),
ClientOptHTTPClient(httpClient),
)
} else { } else {
suite.RegistryClient, err = NewClient( opts = append(opts, ClientOptPlainHTTP())
ClientOptDebug(true),
ClientOptEnableCache(true),
ClientOptWriter(suite.Out),
ClientOptCredentialsFile(credentialsFile),
)
} }
suite.RegistryClient, err = NewClient(opts...)
suite.Nil(err, "no error creating registry client") suite.Nil(err, "no error creating registry client")
// create htpasswd file (w BCrypt, which is required) // create htpasswd file (w BCrypt, which is required)
@ -121,33 +122,30 @@ func setup(suite *TestSuite, tlsEnabled bool, insecure bool) *registry.Registry
config := &configuration.Configuration{} config := &configuration.Configuration{}
port, err := freeport.GetFreePort() port, err := freeport.GetFreePort()
suite.Nil(err, "no error finding free port for test registry") suite.Nil(err, "no error finding free port for test registry")
if tlsEnabled {
// docker has "MatchLocalhost is a host match function which returns true for // Change the registry host to another host which is not localhost.
// localhost, and is used to enforce http for localhost requests." // This is required because Docker enforces HTTP if the registry
// That function does not handle matching of ip addresses in octal, // host is localhost/127.0.0.1.
// decimal or hex form. suite.DockerRegistryHost = fmt.Sprintf("helm-test-registry:%d", port)
suite.DockerRegistryHost = fmt.Sprintf("0x7f000001:%d", port) suite.srv, _ = mockdns.NewServer(map[string]mockdns.Zone{
"helm-test-registry.": {
// As of Go 1.20, Go may lookup "0x7f000001" as a DNS entry and fail. A: []string{"127.0.0.1"},
// Using a mock DNS server to handle the address. },
suite.srv, _ = mockdns.NewServer(map[string]mockdns.Zone{ }, false)
"0x7f000001.": { suite.srv.PatchNet(net.DefaultResolver)
A: []string{"127.0.0.1"},
},
}, false)
suite.srv.PatchNet(net.DefaultResolver)
} else {
suite.DockerRegistryHost = fmt.Sprintf("localhost:%d", port)
}
config.HTTP.Addr = fmt.Sprintf(":%d", port) config.HTTP.Addr = fmt.Sprintf(":%d", port)
// config.HTTP.Addr = fmt.Sprintf("127.0.0.1:%d", port)
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{}{}}
config.Auth = configuration.Auth{
"htpasswd": configuration.Parameters{ // Basic auth is not possible if we are serving HTTP.
"realm": "localhost", if tlsEnabled {
"path": htpasswdPath, config.Auth = configuration.Auth{
}, "htpasswd": configuration.Parameters{
"realm": "localhost",
"path": htpasswdPath,
},
}
} }
// config tls // config tls
@ -157,7 +155,10 @@ func setup(suite *TestSuite, tlsEnabled bool, insecure bool) *registry.Registry
// server tls config // server tls config
config.HTTP.TLS.Certificate = tlsServerCert config.HTTP.TLS.Certificate = tlsServerCert
config.HTTP.TLS.Key = tlsServerKey config.HTTP.TLS.Key = tlsServerKey
config.HTTP.TLS.ClientCAs = []string{tlsCA} // Skip client authentication if the registry is insecure.
if !insecure {
config.HTTP.TLS.ClientCAs = []string{tlsCA}
}
} }
dockerRegistry, err := registry.NewRegistry(context.Background(), config) dockerRegistry, err := registry.NewRegistry(context.Background(), config)
suite.Nil(err, "no error creating test registry") suite.Nil(err, "no error creating test registry")

Loading…
Cancel
Save