The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/util/encryption_test.go

29 lines
667 B

package util
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestEncryption(t *testing.T) {
Convey("When getting encryption key", t, func() {
key := encryptionKeyToBytes("secret", "salt")
So(len(key), ShouldEqual, 32)
key = encryptionKeyToBytes("a very long secret key that is larger then 32bytes", "salt")
So(len(key), ShouldEqual, 32)
})
Convey("When decrypting basic payload", t, func() {
encrypted, encryptErr := Encrypt([]byte("grafana"), "1234")
decrypted, decryptErr := Decrypt(encrypted, "1234")
So(encryptErr, ShouldBeNil)
So(decryptErr, ShouldBeNil)
So(string(decrypted), ShouldEqual, "grafana")
})
}