From 697ac937c6f8cfaa09c31018baaa3b4c4407cb71 Mon Sep 17 00:00:00 2001 From: Will Browne Date: Tue, 17 Aug 2021 12:16:34 +0200 Subject: [PATCH] fix with global config state (#37293) --- .../DataSourceSettings/DataSourceHttpSettings.tsx | 2 +- pkg/models/datasource_cache.go | 3 ++- pkg/models/datasource_cache_test.go | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/grafana-ui/src/components/DataSourceSettings/DataSourceHttpSettings.tsx b/packages/grafana-ui/src/components/DataSourceSettings/DataSourceHttpSettings.tsx index e5a89c9bb60..326305af2f9 100644 --- a/packages/grafana-ui/src/components/DataSourceSettings/DataSourceHttpSettings.tsx +++ b/packages/grafana-ui/src/components/DataSourceSettings/DataSourceHttpSettings.tsx @@ -268,7 +268,7 @@ export const DataSourceHttpSettings: React.FC = (props) => { )} - {dataSourceConfig.jsonData.sigV4Auth && } + {dataSourceConfig.jsonData.sigV4Auth && sigV4AuthToggleEnabled && } {(dataSourceConfig.jsonData.tlsAuth || dataSourceConfig.jsonData.tlsAuthWithCACert) && ( diff --git a/pkg/models/datasource_cache.go b/pkg/models/datasource_cache.go index c0709c4fc5c..3a793787dc1 100644 --- a/pkg/models/datasource_cache.go +++ b/pkg/models/datasource_cache.go @@ -11,6 +11,7 @@ import ( sdkhttpclient "github.com/grafana/grafana-plugin-sdk-go/backend/httpclient" "github.com/grafana/grafana/pkg/components/simplejson" "github.com/grafana/grafana/pkg/infra/httpclient" + "github.com/grafana/grafana/pkg/setting" "github.com/grafana/grafana/pkg/tsdb/azuremonitor/azcredentials" ) @@ -139,7 +140,7 @@ func (ds *DataSource) HTTPClientOptions() (*sdkhttpclient.Options, error) { } } - if ds.JsonData != nil && ds.JsonData.Get("sigV4Auth").MustBool(false) { + if ds.JsonData != nil && ds.JsonData.Get("sigV4Auth").MustBool(false) && setting.SigV4AuthEnabled { opts.SigV4 = &sdkhttpclient.SigV4Config{ Service: awsServiceNamespace(ds.Type), Region: ds.JsonData.Get("sigV4Region").MustString(), diff --git a/pkg/models/datasource_cache_test.go b/pkg/models/datasource_cache_test.go index fcb79e0d5fb..149b50bddf4 100644 --- a/pkg/models/datasource_cache_test.go +++ b/pkg/models/datasource_cache_test.go @@ -296,6 +296,12 @@ func TestDataSource_GetHttpTransport(t *testing.T) { }) clearDSProxyCache(t) + origSigV4Enabled := setting.SigV4AuthEnabled + setting.SigV4AuthEnabled = true + t.Cleanup(func() { + setting.SigV4AuthEnabled = origSigV4Enabled + }) + json, err := simplejson.NewJson([]byte(`{ "sigV4Auth": true }`)) require.NoError(t, err)