Chore: Remove unused Go code (#28852)
* Chore: Remove more unused Go code Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
@@ -9,9 +9,17 @@ import (
|
||||
"github.com/grafana/grafana/pkg/components/securejsondata"
|
||||
)
|
||||
|
||||
// clearPluginSettingDecryptionCache clears the datasource decryption cache.
|
||||
func clearPluginSettingDecryptionCache() {
|
||||
pluginSettingDecryptionCache.Lock()
|
||||
defer pluginSettingDecryptionCache.Unlock()
|
||||
|
||||
pluginSettingDecryptionCache.cache = make(map[int64]cachedDecryptedJSON)
|
||||
}
|
||||
|
||||
func TestPluginSettingDecryptionCache(t *testing.T) {
|
||||
t.Run("When plugin settings hasn't been updated, encrypted JSON should be fetched from cache", func(t *testing.T) {
|
||||
ClearPluginSettingDecryptionCache()
|
||||
clearPluginSettingDecryptionCache()
|
||||
|
||||
ps := PluginSetting{
|
||||
Id: 1,
|
||||
@@ -22,7 +30,7 @@ func TestPluginSettingDecryptionCache(t *testing.T) {
|
||||
}
|
||||
|
||||
// Populate cache
|
||||
password, ok := ps.DecryptedValue("password")
|
||||
password, ok := ps.DecryptedValues()["password"]
|
||||
require.Equal(t, "password", password)
|
||||
require.True(t, ok)
|
||||
|
||||
@@ -35,7 +43,7 @@ func TestPluginSettingDecryptionCache(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("When plugin settings is updated, encrypted JSON should not be fetched from cache", func(t *testing.T) {
|
||||
ClearPluginSettingDecryptionCache()
|
||||
clearPluginSettingDecryptionCache()
|
||||
|
||||
ps := PluginSetting{
|
||||
Id: 1,
|
||||
@@ -46,7 +54,7 @@ func TestPluginSettingDecryptionCache(t *testing.T) {
|
||||
}
|
||||
|
||||
// Populate cache
|
||||
password, ok := ps.DecryptedValue("password")
|
||||
password, ok := ps.DecryptedValues()["password"]
|
||||
require.Equal(t, "password", password)
|
||||
require.True(t, ok)
|
||||
|
||||
@@ -55,7 +63,7 @@ func TestPluginSettingDecryptionCache(t *testing.T) {
|
||||
})
|
||||
ps.Updated = time.Now()
|
||||
|
||||
password, ok = ps.DecryptedValue("password")
|
||||
password, ok = ps.DecryptedValues()["password"]
|
||||
require.Empty(t, password)
|
||||
require.True(t, ok)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user