|
|
@ -21,7 +21,6 @@ import (
|
|
|
|
"context"
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"io"
|
|
|
|
"io/ioutil"
|
|
|
|
|
|
|
|
"net/http"
|
|
|
|
"net/http"
|
|
|
|
"net/http/httptest"
|
|
|
|
"net/http/httptest"
|
|
|
|
"net/url"
|
|
|
|
"net/url"
|
|
|
@ -80,7 +79,7 @@ func (suite *RegistryClientTestSuite) SetupSuite() {
|
|
|
|
pwBytes, err := bcrypt.GenerateFromPassword([]byte(testPassword), bcrypt.DefaultCost)
|
|
|
|
pwBytes, err := bcrypt.GenerateFromPassword([]byte(testPassword), bcrypt.DefaultCost)
|
|
|
|
suite.Nil(err, "no error generating bcrypt password for test htpasswd file")
|
|
|
|
suite.Nil(err, "no error generating bcrypt password for test htpasswd file")
|
|
|
|
htpasswdPath := filepath.Join(suite.WorkspaceDir, testHtpasswdFileBasename)
|
|
|
|
htpasswdPath := filepath.Join(suite.WorkspaceDir, testHtpasswdFileBasename)
|
|
|
|
err = ioutil.WriteFile(htpasswdPath, []byte(fmt.Sprintf("%s:%s\n", testUsername, string(pwBytes))), 0644)
|
|
|
|
err = os.WriteFile(htpasswdPath, []byte(fmt.Sprintf("%s:%s\n", testUsername, string(pwBytes))), 0644)
|
|
|
|
suite.Nil(err, "no error creating test htpasswd file")
|
|
|
|
suite.Nil(err, "no error creating test htpasswd file")
|
|
|
|
|
|
|
|
|
|
|
|
// Registry config
|
|
|
|
// Registry config
|
|
|
@ -139,7 +138,7 @@ func (suite *RegistryClientTestSuite) Test_1_Push() {
|
|
|
|
suite.NotNil(err, "error pushing non-chart bytes")
|
|
|
|
suite.NotNil(err, "error pushing non-chart bytes")
|
|
|
|
|
|
|
|
|
|
|
|
// Load a test chart
|
|
|
|
// Load a test chart
|
|
|
|
chartData, err := ioutil.ReadFile("../repo/repotest/testdata/examplechart-0.1.0.tgz")
|
|
|
|
chartData, err := os.ReadFile("../repo/repotest/testdata/examplechart-0.1.0.tgz")
|
|
|
|
suite.Nil(err, "no error loading test chart")
|
|
|
|
suite.Nil(err, "no error loading test chart")
|
|
|
|
meta, err := extractChartMeta(chartData)
|
|
|
|
meta, err := extractChartMeta(chartData)
|
|
|
|
suite.Nil(err, "no error extracting chart meta")
|
|
|
|
suite.Nil(err, "no error extracting chart meta")
|
|
|
@ -163,7 +162,7 @@ func (suite *RegistryClientTestSuite) Test_1_Push() {
|
|
|
|
suite.Nil(err, "no error pushing non-strict ref (bad tag), with strict mode disabled")
|
|
|
|
suite.Nil(err, "no error pushing non-strict ref (bad tag), with strict mode disabled")
|
|
|
|
|
|
|
|
|
|
|
|
// basic push, good ref
|
|
|
|
// basic push, good ref
|
|
|
|
chartData, err = ioutil.ReadFile("../downloader/testdata/local-subchart-0.1.0.tgz")
|
|
|
|
chartData, err = os.ReadFile("../downloader/testdata/local-subchart-0.1.0.tgz")
|
|
|
|
suite.Nil(err, "no error loading test chart")
|
|
|
|
suite.Nil(err, "no error loading test chart")
|
|
|
|
meta, err = extractChartMeta(chartData)
|
|
|
|
meta, err = extractChartMeta(chartData)
|
|
|
|
suite.Nil(err, "no error extracting chart meta")
|
|
|
|
suite.Nil(err, "no error extracting chart meta")
|
|
|
@ -175,13 +174,13 @@ func (suite *RegistryClientTestSuite) Test_1_Push() {
|
|
|
|
suite.Nil(err, "no error pulling a simple chart")
|
|
|
|
suite.Nil(err, "no error pulling a simple chart")
|
|
|
|
|
|
|
|
|
|
|
|
// Load another test chart
|
|
|
|
// Load another test chart
|
|
|
|
chartData, err = ioutil.ReadFile("../downloader/testdata/signtest-0.1.0.tgz")
|
|
|
|
chartData, err = os.ReadFile("../downloader/testdata/signtest-0.1.0.tgz")
|
|
|
|
suite.Nil(err, "no error loading test chart")
|
|
|
|
suite.Nil(err, "no error loading test chart")
|
|
|
|
meta, err = extractChartMeta(chartData)
|
|
|
|
meta, err = extractChartMeta(chartData)
|
|
|
|
suite.Nil(err, "no error extracting chart meta")
|
|
|
|
suite.Nil(err, "no error extracting chart meta")
|
|
|
|
|
|
|
|
|
|
|
|
// Load prov file
|
|
|
|
// Load prov file
|
|
|
|
provData, err := ioutil.ReadFile("../downloader/testdata/signtest-0.1.0.tgz.prov")
|
|
|
|
provData, err := os.ReadFile("../downloader/testdata/signtest-0.1.0.tgz.prov")
|
|
|
|
suite.Nil(err, "no error loading test prov")
|
|
|
|
suite.Nil(err, "no error loading test prov")
|
|
|
|
|
|
|
|
|
|
|
|
// push with prov
|
|
|
|
// push with prov
|
|
|
@ -223,7 +222,7 @@ func (suite *RegistryClientTestSuite) Test_2_Pull() {
|
|
|
|
suite.NotNil(err, "error on bad/missing ref")
|
|
|
|
suite.NotNil(err, "error on bad/missing ref")
|
|
|
|
|
|
|
|
|
|
|
|
// Load test chart (to build ref pushed in previous test)
|
|
|
|
// Load test chart (to build ref pushed in previous test)
|
|
|
|
chartData, err := ioutil.ReadFile("../downloader/testdata/local-subchart-0.1.0.tgz")
|
|
|
|
chartData, err := os.ReadFile("../downloader/testdata/local-subchart-0.1.0.tgz")
|
|
|
|
suite.Nil(err, "no error loading test chart")
|
|
|
|
suite.Nil(err, "no error loading test chart")
|
|
|
|
meta, err := extractChartMeta(chartData)
|
|
|
|
meta, err := extractChartMeta(chartData)
|
|
|
|
suite.Nil(err, "no error extracting chart meta")
|
|
|
|
suite.Nil(err, "no error extracting chart meta")
|
|
|
@ -245,14 +244,14 @@ func (suite *RegistryClientTestSuite) Test_2_Pull() {
|
|
|
|
"no error pulling a chart with prov when no prov exists, ignoring missing")
|
|
|
|
"no error pulling a chart with prov when no prov exists, ignoring missing")
|
|
|
|
|
|
|
|
|
|
|
|
// Load test chart (to build ref pushed in previous test)
|
|
|
|
// Load test chart (to build ref pushed in previous test)
|
|
|
|
chartData, err = ioutil.ReadFile("../downloader/testdata/signtest-0.1.0.tgz")
|
|
|
|
chartData, err = os.ReadFile("../downloader/testdata/signtest-0.1.0.tgz")
|
|
|
|
suite.Nil(err, "no error loading test chart")
|
|
|
|
suite.Nil(err, "no error loading test chart")
|
|
|
|
meta, err = extractChartMeta(chartData)
|
|
|
|
meta, err = extractChartMeta(chartData)
|
|
|
|
suite.Nil(err, "no error extracting chart meta")
|
|
|
|
suite.Nil(err, "no error extracting chart meta")
|
|
|
|
ref = fmt.Sprintf("%s/testrepo/%s:%s", suite.DockerRegistryHost, meta.Name, meta.Version)
|
|
|
|
ref = fmt.Sprintf("%s/testrepo/%s:%s", suite.DockerRegistryHost, meta.Name, meta.Version)
|
|
|
|
|
|
|
|
|
|
|
|
// Load prov file
|
|
|
|
// Load prov file
|
|
|
|
provData, err := ioutil.ReadFile("../downloader/testdata/signtest-0.1.0.tgz.prov")
|
|
|
|
provData, err := os.ReadFile("../downloader/testdata/signtest-0.1.0.tgz.prov")
|
|
|
|
suite.Nil(err, "no error loading test prov")
|
|
|
|
suite.Nil(err, "no error loading test prov")
|
|
|
|
|
|
|
|
|
|
|
|
// no chart and no prov causes error
|
|
|
|
// no chart and no prov causes error
|
|
|
@ -298,7 +297,7 @@ func (suite *RegistryClientTestSuite) Test_2_Pull() {
|
|
|
|
func (suite *RegistryClientTestSuite) Test_3_Tags() {
|
|
|
|
func (suite *RegistryClientTestSuite) Test_3_Tags() {
|
|
|
|
|
|
|
|
|
|
|
|
// Load test chart (to build ref pushed in previous test)
|
|
|
|
// Load test chart (to build ref pushed in previous test)
|
|
|
|
chartData, err := ioutil.ReadFile("../downloader/testdata/local-subchart-0.1.0.tgz")
|
|
|
|
chartData, err := os.ReadFile("../downloader/testdata/local-subchart-0.1.0.tgz")
|
|
|
|
suite.Nil(err, "no error loading test chart")
|
|
|
|
suite.Nil(err, "no error loading test chart")
|
|
|
|
meta, err := extractChartMeta(chartData)
|
|
|
|
meta, err := extractChartMeta(chartData)
|
|
|
|
suite.Nil(err, "no error extracting chart meta")
|
|
|
|
suite.Nil(err, "no error extracting chart meta")
|
|
|
|