grafana/pkg/services/secrets/fakes/fake_service.go
Joan López de la Franca Beltran e43879e55d
Encryption: Add support for multiple data keys per day (#47765)
* Add database migrations

* Use short uids as data key ids

* Add support for manual data key rotation

* Fix duplicated mutex unlocks

* Fix migration

* Manage current data keys per name

* Adjust key re-encryption and test

* Modify rename column migration for MySQL compatibility

* Refactor secrets manager and data keys cache

* Multiple o11y adjustments

* Fix stats query

* Apply suggestions from code review

Co-authored-by: Tania <yalyna.ts@gmail.com>

* Fix linter

* Docs: Rotate data encryption keys API endpoint

Co-authored-by: Tania <yalyna.ts@gmail.com>
2022-05-23 13:13:55 +02:00

60 lines
1.6 KiB
Go

package fakes
import (
"context"
"github.com/grafana/grafana/pkg/services/secrets"
)
type FakeSecretsService struct{}
func NewFakeSecretsService() FakeSecretsService {
return FakeSecretsService{}
}
func (f FakeSecretsService) Encrypt(_ context.Context, payload []byte, _ secrets.EncryptionOptions) ([]byte, error) {
return payload, nil
}
func (f FakeSecretsService) Decrypt(_ context.Context, payload []byte) ([]byte, error) {
return payload, nil
}
func (f FakeSecretsService) EncryptJsonData(_ context.Context, kv map[string]string, _ secrets.EncryptionOptions) (map[string][]byte, error) {
result := make(map[string][]byte, len(kv))
for key, value := range kv {
result[key] = []byte(value)
}
return result, nil
}
func (f FakeSecretsService) DecryptJsonData(_ context.Context, sjd map[string][]byte) (map[string]string, error) {
result := make(map[string]string, len(sjd))
for key, value := range sjd {
result[key] = string(value)
}
return result, nil
}
func (f FakeSecretsService) GetDecryptedValue(_ context.Context, sjd map[string][]byte, key, fallback string) string {
if value, ok := sjd[key]; ok {
return string(value)
}
return fallback
}
func (f FakeSecretsService) RotateDataKeys(_ context.Context) error {
return nil
}
func (f FakeSecretsService) ReEncryptDataKeys(_ context.Context) error {
return nil
}
func (f FakeSecretsService) CurrentProviderID() string {
return "fakeProvider"
}
func (f FakeSecretsService) GetProviders() map[string]secrets.Provider {
return make(map[string]secrets.Provider)
}
func (f FakeSecretsService) RegisterProvider(_ string, _ secrets.Provider) {}