@@ -215,12 +215,13 @@ func Test_ValidateAndCombineConfig(t *testing.T) {
215215 Name : "d1" ,
216216 Config : & dummyConfig {},
217217 }},
218- Period : 5 * time .Minute ,
219- Server : "http://example.com" ,
220- OrganizationID : "example" ,
221- EndpointPath : "api/v1/data" ,
222- BackoffMaxTime : 10 * time .Minute ,
223- InstallNS : "venafi" ,
218+ Period : 5 * time .Minute ,
219+ Server : "http://example.com" ,
220+ OrganizationID : "example" ,
221+ EndpointPath : "api/v1/data" ,
222+ BackoffMaxTime : 10 * time .Minute ,
223+ InstallNS : "venafi" ,
224+ DisableCompression : true ,
224225 }
225226 require .NoError (t , err )
226227 assert .Equal (t , expect , got )
@@ -255,13 +256,14 @@ func Test_ValidateAndCombineConfig(t *testing.T) {
255256 DataGatherers : []DataGatherer {
256257 {Name : "d1" , Kind : "dummy" , Config : & dummyConfig {AlwaysFail : false }},
257258 },
258- InputPath : "/home" ,
259- OutputPath : "/nothome" ,
260- UploadPath : "/testing/path" ,
261- AuthMode : VenafiCloudKeypair ,
262- ClusterID : "the cluster name" ,
263- BackoffMaxTime : 99 * time .Minute ,
264- InstallNS : "venafi" ,
259+ InputPath : "/home" ,
260+ OutputPath : "/nothome" ,
261+ UploadPath : "/testing/path" ,
262+ AuthMode : VenafiCloudKeypair ,
263+ ClusterID : "the cluster name" ,
264+ BackoffMaxTime : 99 * time .Minute ,
265+ InstallNS : "venafi" ,
266+ DisableCompression : true ,
265267 }
266268 require .NoError (t , err )
267269 assert .Equal (t , expect , got )
@@ -371,7 +373,7 @@ func Test_ValidateAndCombineConfig(t *testing.T) {
371373 ` )),
372374 withCmdLineFlags ("--credentials-file" , path ))
373375 require .NoError (t , err )
374- assert .Equal (t , CombinedConfig {Server : "https://api.venafi.eu" , Period : time .Hour , OrganizationID : "foo" , ClusterID : "bar" , AuthMode : JetstackSecureOAuth , BackoffMaxTime : 10 * time .Minute , InstallNS : "venafi" }, got )
376+ assert .Equal (t , CombinedConfig {Server : "https://api.venafi.eu" , Period : time .Hour , OrganizationID : "foo" , ClusterID : "bar" , AuthMode : JetstackSecureOAuth , BackoffMaxTime : 10 * time .Minute , InstallNS : "venafi" , DisableCompression : true }, got )
375377 assert .IsType (t , & client.OAuthClient {}, cl )
376378 })
377379
@@ -384,8 +386,8 @@ func Test_ValidateAndCombineConfig(t *testing.T) {
384386 organization_id: foo
385387 cluster_id: bar
386388 ` )),
387- withCmdLineFlags ("--disable-compression" , "--credentials-file" , path , "--install-namespace" , "venafi" ))
388- require .EqualError (t , err , "1 error occurred:\n \t * --disable-compression can only be used with the Venafi Cloud Key Pair Service Account and Venafi Cloud VenafiConnection modes\n \n " )
389+ withCmdLineFlags ("--disable-compression=false " , "--credentials-file" , path , "--install-namespace" , "venafi" ))
390+ require .EqualError (t , err , "1 error occurred:\n \t * --disable-compression=false can only be used with the Venafi Cloud Key Pair Service Account and Venafi Cloud VenafiConnection modes\n \n " )
389391 })
390392
391393 t .Run ("jetstack-secure-oauth-auth: --credential-file used but file is missing" , func (t * testing.T ) {
@@ -463,7 +465,7 @@ func Test_ValidateAndCombineConfig(t *testing.T) {
463465 ` )),
464466 withCmdLineFlags ("--client-id" , "5bc7d07c-45da-11ef-a878-523f1e1d7de1" , "--private-key-path" , path ))
465467 require .NoError (t , err )
466- assert .Equal (t , CombinedConfig {Server : "https://api.venafi.eu" , Period : time .Hour , AuthMode : VenafiCloudKeypair , ClusterID : "the cluster name" , UploadPath : "/foo/bar" , BackoffMaxTime : 10 * time .Minute , InstallNS : "venafi" }, got )
468+ assert .Equal (t , CombinedConfig {Server : "https://api.venafi.eu" , Period : time .Hour , AuthMode : VenafiCloudKeypair , ClusterID : "the cluster name" , UploadPath : "/foo/bar" , BackoffMaxTime : 10 * time .Minute , InstallNS : "venafi" , DisableCompression : true }, got )
467469 assert .IsType (t , & client.VenafiCloudClient {}, cl )
468470 })
469471
@@ -485,7 +487,7 @@ func Test_ValidateAndCombineConfig(t *testing.T) {
485487 ` )),
486488 withCmdLineFlags ("--venafi-cloud" , "--credentials-file" , credsPath ))
487489 require .NoError (t , err )
488- assert .Equal (t , CombinedConfig {Server : "https://api.venafi.eu" , Period : time .Hour , AuthMode : VenafiCloudKeypair , ClusterID : "the cluster name" , UploadPath : "/foo/bar" , BackoffMaxTime : 10 * time .Minute , InstallNS : "venafi" }, got )
490+ assert .Equal (t , CombinedConfig {Server : "https://api.venafi.eu" , Period : time .Hour , AuthMode : VenafiCloudKeypair , ClusterID : "the cluster name" , UploadPath : "/foo/bar" , BackoffMaxTime : 10 * time .Minute , InstallNS : "venafi" , DisableCompression : true }, got )
489491 })
490492
491493 t .Run ("venafi-cloud-keypair-auth: venafi-cloud.upload_path field is required" , func (t * testing.T ) {
@@ -560,13 +562,14 @@ func Test_ValidateAndCombineConfig(t *testing.T) {
560562 withCmdLineFlags ("--venafi-connection" , "venafi-components" ))
561563 require .NoError (t , err )
562564 assert .Equal (t , CombinedConfig {
563- Period : 1 * time .Hour ,
564- ClusterID : "the cluster name" ,
565- AuthMode : VenafiCloudVenafiConnection ,
566- VenConnName : "venafi-components" ,
567- VenConnNS : "venafi" ,
568- InstallNS : "venafi" ,
569- BackoffMaxTime : 10 * time .Minute ,
565+ Period : 1 * time .Hour ,
566+ ClusterID : "the cluster name" ,
567+ AuthMode : VenafiCloudVenafiConnection ,
568+ VenConnName : "venafi-components" ,
569+ VenConnNS : "venafi" ,
570+ InstallNS : "venafi" ,
571+ BackoffMaxTime : 10 * time .Minute ,
572+ DisableCompression : true ,
570573 }, got )
571574 assert .IsType (t , & client.VenConnClient {}, cl )
572575 })
@@ -648,7 +651,7 @@ func Test_ValidateAndCombineConfig_VenafiCloudKeyPair(t *testing.T) {
648651 require .NoError (t , err )
649652 })
650653
651- t .Run ("the request body is compressed" , func (t * testing.T ) {
654+ t .Run ("the request body is compressed if --disable-compression=false " , func (t * testing.T ) {
652655 srv , cert , setVenafiCloudAssert := testutil .FakeVenafiCloud (t )
653656 setVenafiCloudAssert (func (t testing.TB , gotReq * http.Request ) {
654657 if gotReq .URL .Path == "/v1/oauth/token/serviceaccount" {
@@ -675,7 +678,7 @@ func Test_ValidateAndCombineConfig_VenafiCloudKeyPair(t *testing.T) {
675678 uploader_id: no
676679 upload_path: /v1/tlspk/upload/clusterdata
677680 ` )),
678- withCmdLineFlags ("--client-id" , "5bc7d07c-45da-11ef-a878-523f1e1d7de1" , "--private-key-path" , privKeyPath , "--install-namespace" , "venafi" ),
681+ withCmdLineFlags ("--disable-compression=false" , "-- client-id" , "5bc7d07c-45da-11ef-a878-523f1e1d7de1" , "--private-key-path" , privKeyPath , "--install-namespace" , "venafi" ),
679682 )
680683 require .NoError (t , err )
681684 testutil .TrustCA (t , cl , cert )
@@ -686,7 +689,7 @@ func Test_ValidateAndCombineConfig_VenafiCloudKeyPair(t *testing.T) {
686689 require .NoError (t , err )
687690 })
688691
689- t .Run ("--disable-compression works " , func (t * testing.T ) {
692+ t .Run ("the request is not compressed by default " , func (t * testing.T ) {
690693 srv , cert , setVenafiCloudAssert := testutil .FakeVenafiCloud (t )
691694 setVenafiCloudAssert (func (t testing.TB , gotReq * http.Request ) {
692695 // Only care about /v1/tlspk/upload/clusterdata/:uploader_id?name=
@@ -714,7 +717,7 @@ func Test_ValidateAndCombineConfig_VenafiCloudKeyPair(t *testing.T) {
714717 uploader_id: no
715718 upload_path: /v1/tlspk/upload/clusterdata
716719 ` )),
717- withCmdLineFlags ("--disable-compression" , "-- client-id" , "5bc7d07c-45da-11ef-a878-523f1e1d7de1" , "--private-key-path" , privKeyPath , "--install-namespace" , "venafi" ),
720+ withCmdLineFlags ("--client-id" , "5bc7d07c-45da-11ef-a878-523f1e1d7de1" , "--private-key-path" , privKeyPath , "--install-namespace" , "venafi" ),
718721 )
719722 require .NoError (t , err )
720723 testutil .TrustCA (t , cl , cert )
@@ -821,7 +824,7 @@ func Test_ValidateAndCombineConfig_VenafiConnection(t *testing.T) {
821824 require .NoError (t , err )
822825 })
823826
824- t .Run ("the request is compressed by default " , func (t * testing.T ) {
827+ t .Run ("the request is only compressed when --disable-compression=false is passed " , func (t * testing.T ) {
825828 setVenafiCloudAssert (func (t testing.TB , gotReq * http.Request ) {
826829 // Let's check that the body is compressed as expected.
827830 assert .Equal (t , "gzip" , gotReq .Header .Get ("Content-Encoding" ))
@@ -837,15 +840,15 @@ func Test_ValidateAndCombineConfig_VenafiConnection(t *testing.T) {
837840 period: 1h
838841 cluster_id: test cluster name
839842 ` )),
840- withCmdLineFlags ("--venafi-connection" , "venafi-components" , "--install-namespace" , "venafi" ))
843+ withCmdLineFlags ("--disable-compression=false" , "-- venafi-connection" , "venafi-components" , "--install-namespace" , "venafi" ))
841844 require .NoError (t , err )
842845 testutil .VenConnStartWatching (t , cl )
843846 testutil .TrustCA (t , cl , cert )
844847 err = cl .PostDataReadingsWithOptions (nil , client.Options {ClusterName : cfg .ClusterID })
845848 require .NoError (t , err )
846849 })
847850
848- t .Run ("--disable- compression works " , func (t * testing.T ) {
851+ t .Run ("compression is disabled by default " , func (t * testing.T ) {
849852 setVenafiCloudAssert (func (t testing.TB , gotReq * http.Request ) {
850853 // Let's check that the body isn't compressed.
851854 assert .Equal (t , "" , gotReq .Header .Get ("Content-Encoding" ))
@@ -860,7 +863,7 @@ func Test_ValidateAndCombineConfig_VenafiConnection(t *testing.T) {
860863 period: 1h
861864 cluster_id: test cluster name
862865 ` )),
863- withCmdLineFlags ("--disable-compression" , "-- venafi-connection" , "venafi-components" , "--install-namespace" , "venafi" ))
866+ withCmdLineFlags ("--venafi-connection" , "venafi-components" , "--install-namespace" , "venafi" ))
864867 require .NoError (t , err )
865868 testutil .VenConnStartWatching (t , cl )
866869 testutil .TrustCA (t , cl , cert )
0 commit comments