mirror of
https://github.com/grafana/grafana.git
synced 2025-01-23 23:13:52 -06:00
62689ec804
* Add secrets service * Revert accidental changes in util encryption * Make minor changes Move functional options to models Revert renaming types to models * Add context * Minor change in GetDataKey * Use CreateDataKeyWithDBSession in CreateDataKey * Handle empty DEK name in DeleteDataKey * Rename defaultProvider * Remove secrets store service
33 lines
746 B
Go
33 lines
746 B
Go
package secrets
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/grafana/grafana/pkg/bus"
|
|
"github.com/grafana/grafana/pkg/services/encryption/ossencryption"
|
|
"github.com/grafana/grafana/pkg/services/sqlstore"
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
"github.com/stretchr/testify/require"
|
|
"gopkg.in/ini.v1"
|
|
)
|
|
|
|
func SetupTestService(t *testing.T) SecretsService {
|
|
t.Helper()
|
|
defaultKey := "SdlklWklckeLS"
|
|
if len(setting.SecretKey) > 0 {
|
|
defaultKey = setting.SecretKey
|
|
}
|
|
raw, err := ini.Load([]byte(`
|
|
[security]
|
|
secret_key = ` + defaultKey))
|
|
require.NoError(t, err)
|
|
settings := &setting.OSSImpl{Cfg: &setting.Cfg{Raw: raw}}
|
|
|
|
return ProvideSecretsService(
|
|
sqlstore.InitTestDB(t),
|
|
bus.New(),
|
|
ossencryption.ProvideService(),
|
|
settings,
|
|
)
|
|
}
|