encoding_test.go 550 B

1234567891011121314151617181920212223242526
  1. package util
  2. import (
  3. "testing"
  4. . "github.com/smartystreets/goconvey/convey"
  5. )
  6. func TestEncoding(t *testing.T) {
  7. Convey("When generating base64 header", t, func() {
  8. result := GetBasicAuthHeader("grafana", "1234")
  9. So(result, ShouldEqual, "Basic Z3JhZmFuYToxMjM0")
  10. })
  11. Convey("When decoding basic auth header", t, func() {
  12. header := GetBasicAuthHeader("grafana", "1234")
  13. username, password, err := DecodeBasicAuthHeader(header)
  14. So(err, ShouldBeNil)
  15. So(username, ShouldEqual, "grafana")
  16. So(password, ShouldEqual, "1234")
  17. })
  18. }