|
@@ -49,7 +49,7 @@ func TestMiddlewareContext(t *testing.T) {
|
|
|
So(sc.resp.Header().Get("Expires"), ShouldBeEmpty)
|
|
So(sc.resp.Header().Get("Expires"), ShouldBeEmpty)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- middlewareScenario(t, "middleware should add Cache-Control header for GET requests with html response", func(sc *scenarioContext) {
|
|
|
|
|
|
|
+ middlewareScenario(t, "middleware should add Cache-Control header for requests with html response", func(sc *scenarioContext) {
|
|
|
sc.handler(func(c *m.ReqContext) {
|
|
sc.handler(func(c *m.ReqContext) {
|
|
|
data := &dtos.IndexViewData{
|
|
data := &dtos.IndexViewData{
|
|
|
User: &dtos.CurrentUser{},
|
|
User: &dtos.CurrentUser{},
|
|
@@ -65,6 +65,17 @@ func TestMiddlewareContext(t *testing.T) {
|
|
|
So(sc.resp.Header().Get("Expires"), ShouldEqual, "-1")
|
|
So(sc.resp.Header().Get("Expires"), ShouldEqual, "-1")
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ middlewareScenario(t, "middleware should add X-Frame-Options header with deny for request when not allowing embedding", func(sc *scenarioContext) {
|
|
|
|
|
+ sc.fakeReq("GET", "/api/search").exec()
|
|
|
|
|
+ So(sc.resp.Header().Get("X-Frame-Options"), ShouldEqual, "deny")
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ middlewareScenario(t, "middleware should not add X-Frame-Options header for request when allowing embedding", func(sc *scenarioContext) {
|
|
|
|
|
+ setting.AllowEmbedding = true
|
|
|
|
|
+ sc.fakeReq("GET", "/api/search").exec()
|
|
|
|
|
+ So(sc.resp.Header().Get("X-Frame-Options"), ShouldBeEmpty)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
middlewareScenario(t, "Invalid api key", func(sc *scenarioContext) {
|
|
middlewareScenario(t, "Invalid api key", func(sc *scenarioContext) {
|
|
|
sc.apiKey = "invalid_key_test"
|
|
sc.apiKey = "invalid_key_test"
|
|
|
sc.fakeReq("GET", "/").exec()
|
|
sc.fakeReq("GET", "/").exec()
|