|
|
|
|
@ -1,7 +1,6 @@ |
|
|
|
|
package authproxy |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"encoding/base32" |
|
|
|
|
"errors" |
|
|
|
|
"fmt" |
|
|
|
|
"net/http" |
|
|
|
|
@ -79,7 +78,7 @@ func TestMiddlewareContext(t *testing.T) { |
|
|
|
|
|
|
|
|
|
Convey("with a simple cache key", func() { |
|
|
|
|
// Set cache key
|
|
|
|
|
key := fmt.Sprintf(CachePrefix, base32.StdEncoding.EncodeToString([]byte(name))) |
|
|
|
|
key := fmt.Sprintf(CachePrefix, HashCacheKey(name)) |
|
|
|
|
err := store.Set(key, int64(33), 0) |
|
|
|
|
So(err, ShouldBeNil) |
|
|
|
|
|
|
|
|
|
@ -88,7 +87,7 @@ func TestMiddlewareContext(t *testing.T) { |
|
|
|
|
id, err := auth.Login() |
|
|
|
|
So(err, ShouldBeNil) |
|
|
|
|
|
|
|
|
|
So(auth.getKey(), ShouldEqual, "auth-proxy-sync-ttl:NVQXE23FNRXWO===") |
|
|
|
|
So(auth.getKey(), ShouldEqual, "auth-proxy-sync-ttl:0a7f3374e9659b10980fd66247b0cf2f") |
|
|
|
|
So(id, ShouldEqual, 33) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
@ -97,7 +96,7 @@ func TestMiddlewareContext(t *testing.T) { |
|
|
|
|
group := "grafana-core-team" |
|
|
|
|
req.Header.Add("X-WEBAUTH-GROUPS", group) |
|
|
|
|
|
|
|
|
|
key := fmt.Sprintf(CachePrefix, base32.StdEncoding.EncodeToString([]byte(name+"-"+group))) |
|
|
|
|
key := fmt.Sprintf(CachePrefix, HashCacheKey(name+"-"+group)) |
|
|
|
|
err := store.Set(key, int64(33), 0) |
|
|
|
|
So(err, ShouldBeNil) |
|
|
|
|
|
|
|
|
|
@ -105,7 +104,7 @@ func TestMiddlewareContext(t *testing.T) { |
|
|
|
|
|
|
|
|
|
id, err := auth.Login() |
|
|
|
|
So(err, ShouldBeNil) |
|
|
|
|
So(auth.getKey(), ShouldEqual, "auth-proxy-sync-ttl:NVQXE23FNRXWOLLHOJQWMYLOMEWWG33SMUWXIZLBNU======") |
|
|
|
|
So(auth.getKey(), ShouldEqual, "auth-proxy-sync-ttl:14f69b7023baa0ac98c96b31cec07bc0") |
|
|
|
|
So(id, ShouldEqual, 33) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|