@@ -12,6 +12,7 @@ import (
1212 "github.com/spf13/cobra"
1313 "github.com/stretchr/testify/assert"
1414 "github.com/stretchr/testify/require"
15+ "k8s.io/klog/v2"
1516 "k8s.io/klog/v2/ktesting"
1617
1718 "github.com/jetstack/preflight/pkg/client"
@@ -620,6 +621,12 @@ func Test_ValidateAndCombineConfig(t *testing.T) {
620621func Test_ValidateAndCombineConfig_VenafiCloudKeyPair (t * testing.T ) {
621622 t .Run ("server, uploader_id, and cluster name are correctly passed" , func (t * testing.T ) {
622623 t .Setenv ("POD_NAMESPACE" , "venafi" )
624+
625+ ctx , cancel := context .WithCancel (context .Background ())
626+ defer cancel ()
627+ log := ktesting .NewLogger (t , ktesting .NewConfig (ktesting .Verbosity (10 )))
628+ ctx = klog .NewContext (ctx , log )
629+
623630 srv , cert , setVenafiCloudAssert := testutil .FakeVenafiCloud (t )
624631 setVenafiCloudAssert (func (t testing.TB , gotReq * http.Request ) {
625632 // Only care about /v1/tlspk/upload/clusterdata/:uploader_id?name=
@@ -648,7 +655,7 @@ func Test_ValidateAndCombineConfig_VenafiCloudKeyPair(t *testing.T) {
648655 testutil .TrustCA (t , cl , cert )
649656 assert .Equal (t , VenafiCloudKeypair , got .AuthMode )
650657
651- err = cl .PostDataReadingsWithOptions (nil , client.Options {ClusterName : "test cluster name" })
658+ err = cl .PostDataReadingsWithOptions (ctx , nil , client.Options {ClusterName : "test cluster name" })
652659 require .NoError (t , err )
653660 })
654661}
@@ -724,6 +731,11 @@ func Test_ValidateAndCombineConfig_VenafiConnection(t *testing.T) {
724731 })
725732
726733 t .Run ("the server field is ignored when VenafiConnection is used" , func (t * testing.T ) {
734+ ctx , cancel := context .WithCancel (context .Background ())
735+ defer cancel ()
736+ log := ktesting .NewLogger (t , ktesting .NewConfig (ktesting .Verbosity (10 )))
737+ ctx = klog .NewContext (ctx , log )
738+
727739 expected := srv .URL
728740 setVenafiCloudAssert (func (t testing.TB , gotReq * http.Request ) {
729741 assert .Equal (t , expected , "https://" + gotReq .Host )
@@ -744,7 +756,7 @@ func Test_ValidateAndCombineConfig_VenafiConnection(t *testing.T) {
744756 // TODO(mael): the client should keep track of the cluster ID, we
745757 // shouldn't need to pass it as an option to
746758 // PostDataReadingsWithOptions.
747- err = cl .PostDataReadingsWithOptions (nil , client.Options {ClusterName : cfg .ClusterID })
759+ err = cl .PostDataReadingsWithOptions (ctx , nil , client.Options {ClusterName : cfg .ClusterID })
748760 require .NoError (t , err )
749761 })
750762}
0 commit comments