mirror of https://github.com/helm/helm
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.2 KiB
78 lines
2.2 KiB
4 years ago
|
/*
|
||
|
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"
|
||
|
)
|
||
|
|
||
2 years ago
|
type InsecureTLSRegistryClientTestSuite struct {
|
||
3 years ago
|
TestSuite
|
||
4 years ago
|
}
|
||
|
|
||
2 years ago
|
func (suite *InsecureTLSRegistryClientTestSuite) SetupSuite() {
|
||
4 years ago
|
// init test client
|
||
2 years ago
|
dockerRegistry := setup(&suite.TestSuite, true, true)
|
||
4 years ago
|
|
||
|
// Start Docker registry
|
||
|
go dockerRegistry.ListenAndServe()
|
||
|
}
|
||
|
|
||
2 years ago
|
func (suite *InsecureTLSRegistryClientTestSuite) TearDownSuite() {
|
||
|
teardown(&suite.TestSuite)
|
||
4 years ago
|
os.RemoveAll(suite.WorkspaceDir)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (suite *InsecureTLSRegistryClientTestSuite) Test_0_Login() {
|
||
4 years ago
|
err := suite.RegistryClient.Login(suite.DockerRegistryHost,
|
||
4 years ago
|
LoginOptBasicAuth("badverybad", "ohsobad"),
|
||
|
LoginOptInsecure(true))
|
||
2 years ago
|
suite.NotNil(err, "error logging into registry with bad credentials")
|
||
4 years ago
|
|
||
4 years ago
|
err = suite.RegistryClient.Login(suite.DockerRegistryHost,
|
||
4 years ago
|
LoginOptBasicAuth(testUsername, testPassword),
|
||
|
LoginOptInsecure(true))
|
||
2 years ago
|
suite.Nil(err, "no error logging into registry with good credentials")
|
||
4 years ago
|
}
|
||
|
|
||
2 years ago
|
func (suite *InsecureTLSRegistryClientTestSuite) Test_1_Push() {
|
||
3 years ago
|
testPush(&suite.TestSuite)
|
||
4 years ago
|
}
|
||
|
|
||
2 years ago
|
func (suite *InsecureTLSRegistryClientTestSuite) Test_2_Pull() {
|
||
3 years ago
|
testPull(&suite.TestSuite)
|
||
4 years ago
|
}
|
||
|
|
||
2 years ago
|
func (suite *InsecureTLSRegistryClientTestSuite) Test_3_Tags() {
|
||
3 years ago
|
testTags(&suite.TestSuite)
|
||
3 years ago
|
}
|
||
|
|
||
2 years ago
|
func (suite *InsecureTLSRegistryClientTestSuite) Test_4_Logout() {
|
||
4 years ago
|
err := suite.RegistryClient.Logout("this-host-aint-real:5000")
|
||
4 years ago
|
suite.NotNil(err, "error logging out of registry that has no entry")
|
||
|
|
||
4 years ago
|
err = suite.RegistryClient.Logout(suite.DockerRegistryHost)
|
||
4 years ago
|
suite.Nil(err, "no error logging out of registry")
|
||
|
}
|
||
|
|
||
2 years ago
|
func TestInsecureTLSRegistryClientTestSuite(t *testing.T) {
|
||
|
suite.Run(t, new(InsecureTLSRegistryClientTestSuite))
|
||
4 years ago
|
}
|