mirror of https://github.com/grafana/grafana
Began work on auth_proxy feature (#1932), and began work on testing http api, and auth middleware
parent
e7ac367392
commit
d1e9b6d6ae
@ -0,0 +1,40 @@ |
||||
package middleware |
||||
|
||||
import ( |
||||
"net/http" |
||||
"net/http/httptest" |
||||
"testing" |
||||
|
||||
"github.com/Unknwon/macaron" |
||||
"github.com/macaron-contrib/session" |
||||
. "github.com/smartystreets/goconvey/convey" |
||||
) |
||||
|
||||
func TestMiddlewareContext(t *testing.T) { |
||||
|
||||
Convey("Given grafana context", t, func() { |
||||
m := macaron.New() |
||||
m.Use(GetContextHandler()) |
||||
m.Use(Sessioner(&session.Options{})) |
||||
|
||||
var context *Context |
||||
|
||||
m.Get("/", func(c *Context) { |
||||
context = c |
||||
}) |
||||
|
||||
resp := httptest.NewRecorder() |
||||
req, err := http.NewRequest("GET", "/", nil) |
||||
So(err, ShouldBeNil) |
||||
|
||||
m.ServeHTTP(resp, req) |
||||
|
||||
Convey("Should be able to get grafana context in handlers", func() { |
||||
So(context, ShouldNotBeNil) |
||||
}) |
||||
|
||||
Convey("should return 200", func() { |
||||
So(resp.Code, ShouldEqual, 200) |
||||
}) |
||||
}) |
||||
} |
||||
Loading…
Reference in new issue