mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-10 09:56:55 +00:00
* 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>
31 lines
918 B
Go
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)
|
|
}
|