mirror of https://github.com/helm/helm
Signed-off-by: Tom Runyon <runyontr@gmail.com> Signed-off-by: Tom Runyon <tom@defenseunicorns.com>pull/11623/head
parent
330105ca6f
commit
3265d17a81
@ -0,0 +1,76 @@
|
||||
/*
|
||||
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 (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"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() {
|
||||
os.RemoveAll(suite.WorkspaceDir)
|
||||
}
|
||||
|
||||
func (suite *HTTPRegistryClientTestSuite) Test_0_Login() {
|
||||
err := suite.RegistryClient.Login(suite.DockerRegistryHost,
|
||||
LoginOptBasicAuth(testUsername, testPassword),
|
||||
LoginOptInsecure(false))
|
||||
suite.Nil(err, "Expected no error logging into registry with good credentials: %v", err)
|
||||
|
||||
err = suite.RegistryClient.Login(suite.DockerRegistryHost,
|
||||
LoginOptBasicAuth(testUsername, "badpassword"),
|
||||
LoginOptInsecure(true))
|
||||
suite.NotNil(err, "error logging into registry with good credentials, insecure mode")
|
||||
}
|
||||
|
||||
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_Logout() {
|
||||
err := suite.RegistryClient.Logout("this-host-aint-real:5000")
|
||||
suite.NotNil(err, "error logging out of registry that has no entry")
|
||||
|
||||
err = suite.RegistryClient.Logout(suite.DockerRegistryHost)
|
||||
suite.Nil(err, "no error logging out of registry")
|
||||
}
|
||||
|
||||
func TestHTTPRegistryClientTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(HTTPRegistryClientTestSuite))
|
||||
}
|
Loading…
Reference in new issue