1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-10 01:46:55 +00:00
kyverno/pkg/registryclient/client_test.go
Charles-Edouard Brétéché 39b72eefb9
feat: add http clients tracing (#5630)
* feat: add http clients tracing

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* check we are in a span before creating one and and context to metrics recording calls

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
Co-authored-by: shuting <shuting@nirmata.com>
2022-12-09 09:09:11 +00:00

31 lines
918 B
Go

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)
}