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/encoding_test.go

29 lines
794 B

package util
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestEncoding(t *testing.T) {
Convey("When generating base64 header", t, func() {
result := GetBasicAuthHeader("grafana", "1234")
So(result, ShouldEqual, "Basic Z3JhZmFuYToxMjM0")
})
Convey("When decoding basic auth header", t, func() {
header := GetBasicAuthHeader("grafana", "1234")
username, password, err := DecodeBasicAuthHeader(header)
So(err, ShouldBeNil)
So(username, ShouldEqual, "grafana")
So(password, ShouldEqual, "1234")
})
Convey("When encoding password", t, func() {
encodedPassword := EncodePassword("iamgod", "pepper")
So(encodedPassword, ShouldEqual, "e59c568621e57756495a468f47c74e07c911b037084dd464bb2ed72410970dc849cabd71b48c394faf08a5405dae53741ce9")
})
}