...

Source file src/helm.sh/helm/v3/pkg/registry/client_tls_test.go

Documentation: helm.sh/helm/v3/pkg/registry

     1  /*
     2  Copyright The Helm Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package registry
    18  
    19  import (
    20  	"os"
    21  	"testing"
    22  
    23  	"github.com/stretchr/testify/suite"
    24  )
    25  
    26  type TLSRegistryClientTestSuite struct {
    27  	TestSuite
    28  }
    29  
    30  func (suite *TLSRegistryClientTestSuite) SetupSuite() {
    31  	// init test client
    32  	dockerRegistry := setup(&suite.TestSuite, true, false)
    33  
    34  	// Start Docker registry
    35  	go dockerRegistry.ListenAndServe()
    36  }
    37  
    38  func (suite *TLSRegistryClientTestSuite) TearDownSuite() {
    39  	teardown(&suite.TestSuite)
    40  	os.RemoveAll(suite.WorkspaceDir)
    41  }
    42  
    43  func (suite *TLSRegistryClientTestSuite) Test_0_Login() {
    44  	err := suite.RegistryClient.Login(suite.DockerRegistryHost,
    45  		LoginOptBasicAuth("badverybad", "ohsobad"),
    46  		LoginOptTLSClientConfig(tlsCert, tlsKey, tlsCA))
    47  	suite.NotNil(err, "error logging into registry with bad credentials")
    48  
    49  	err = suite.RegistryClient.Login(suite.DockerRegistryHost,
    50  		LoginOptBasicAuth(testUsername, testPassword),
    51  		LoginOptTLSClientConfig(tlsCert, tlsKey, tlsCA))
    52  	suite.Nil(err, "no error logging into registry with good credentials")
    53  }
    54  
    55  func (suite *TLSRegistryClientTestSuite) Test_1_Push() {
    56  	testPush(&suite.TestSuite)
    57  }
    58  
    59  func (suite *TLSRegistryClientTestSuite) Test_2_Pull() {
    60  	testPull(&suite.TestSuite)
    61  }
    62  
    63  func (suite *TLSRegistryClientTestSuite) Test_3_Tags() {
    64  	testTags(&suite.TestSuite)
    65  }
    66  
    67  func (suite *TLSRegistryClientTestSuite) Test_4_Logout() {
    68  	err := suite.RegistryClient.Logout("this-host-aint-real:5000")
    69  	suite.NotNil(err, "error logging out of registry that has no entry")
    70  
    71  	err = suite.RegistryClient.Logout(suite.DockerRegistryHost)
    72  	suite.Nil(err, "no error logging out of registry")
    73  }
    74  
    75  func TestTLSRegistryClientTestSuite(t *testing.T) {
    76  	suite.Run(t, new(TLSRegistryClientTestSuite))
    77  }
    78  

View as plain text