Chore: Refactor securedata to remove global encryption calls from dashboard snapshots (#38714)

* Add encryption service

* Add tests for encryption service

* Inject encryption service into http server

* Replace encryption global function usage in login tests

* Migrate to Wire

* Move Encryption bindings to OSS Wire set

* Chore: Refactor securedata to remove global encryption calls from dashboard snapshots

* Fix dashboard snapshot tests

* Remove no longer user test

* Add dashboard snapshots service tests

* Refactor service initialization

* Set up dashboard snapshots service as a background service

Co-authored-by: Tania B <yalyna.ts@gmail.com>
Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
This commit is contained in:
Joan López de la Franca Beltran
2021-09-01 13:05:15 +02:00
committed by GitHub
co-authored by Tania B Emil Tullstedt
parent a4e253bcf9
commit 6cfb640a0b
10 changed files with 209 additions and 143 deletions
+3 -13
View File
@@ -3,7 +3,6 @@ package models
import (
"time"
"github.com/grafana/grafana/pkg/components/securedata"
"github.com/grafana/grafana/pkg/components/simplejson"
)
@@ -24,18 +23,7 @@ type DashboardSnapshot struct {
Updated time.Time
Dashboard *simplejson.Json
DashboardEncrypted securedata.SecureData
}
func (ds *DashboardSnapshot) DashboardJSON() (*simplejson.Json, error) {
if ds.DashboardEncrypted != nil {
decrypted, err := ds.DashboardEncrypted.Decrypt()
if err != nil {
return nil, err
}
return simplejson.NewJson(decrypted)
}
return ds.Dashboard, nil
DashboardEncrypted []byte
}
// DashboardSnapshotDTO without dashboard map
@@ -72,6 +60,8 @@ type CreateDashboardSnapshotCommand struct {
OrgId int64 `json:"-"`
UserId int64 `json:"-"`
DashboardEncrypted []byte `json:"-"`
Result *DashboardSnapshot
}