1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-10 09:56:55 +00:00
kyverno/pkg/registryclient/client_test.go

32 lines
918 B
Go
Raw Normal View History

package registryclient
import (
"crypto/tls"
"net/http"
"testing"
"gotest.tools/assert"
)
// Make sure that client conforms Client interface.
var _ Client = &client{}
func TestInitClientWithEmptyOptions(t *testing.T) {
c, err := New()
assert.NilError(t, err)
assert.Assert(t, defaultTransport == c.getTransport())
assert.Assert(t, c.getKeychain() != nil)
}
func TestInitClientWithInsecureRegistryOption(t *testing.T) {
expClient := &client{
transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}},
}
c, err := New(WithAllowInsecureRegistry())
expInsecureSkipVerify := expClient.transport.(*http.Transport).TLSClientConfig.InsecureSkipVerify
gotInsecureSkipVerify := c.getTransport().(*http.Transport).TLSClientConfig.InsecureSkipVerify
assert.NilError(t, err)
assert.Assert(t, expInsecureSkipVerify == gotInsecureSkipVerify)
assert.Assert(t, c.getKeychain() != nil)
}