func mockAuthorization(subject string, token *jwt.Token) func(h chd.ContextHandler) chd.ContextHandler { return func(h chd.ContextHandler) chd.ContextHandler { return chd.ContextHandlerFunc(func(ctx context.Context, rw http.ResponseWriter, req *http.Request) { claims := hjwt.NewClaimsCarrier(uuid.New(), "hydra", subject, "tests", time.Now().Add(time.Hour), time.Now(), time.Now()) ctx = authcon.NewContextFromAuthValues(ctx, claims, token, []policy.Policy{}) h.ServeHTTPContext(ctx, rw, req) }) } }
func mockAuthorization(c test) func(h hcon.ContextHandler) hcon.ContextHandler { return func(h hcon.ContextHandler) hcon.ContextHandler { return hcon.ContextHandlerFunc(func(ctx context.Context, rw http.ResponseWriter, req *http.Request) { claims := hjwt.NewClaimsCarrier(uuid.New(), "hydra", c.subject, "tests", time.Now(), time.Now()) ctx = hcon.NewContextFromAuthValues(ctx, claims, &c.token, c.policies) h.ServeHTTPContext(ctx, rw, req) }) } }
func mockContext(c test) func(chd.ContextHandler) chd.ContextHandler { return func(next chd.ContextHandler) chd.ContextHandler { return chd.ContextHandlerFunc(func(ctx context.Context, rw http.ResponseWriter, req *http.Request) { claims := hjwt.NewClaimsCarrier(uuid.New(), "hydra", c.subject, "tests", time.Now().Add(time.Hour), time.Now(), time.Now()) ctx = authcon.NewContextFromAuthValues(ctx, claims, c.token, c.policies) next.ServeHTTPContext(ctx, rw, req) }) } }