API: Cache-Control (browser caching) for datasource resources: part 2 (#63060)
* Check if header string contains "public" or "private" target values
This commit is contained in:
@@ -158,15 +158,15 @@ func TestMiddlewareContext(t *testing.T) {
|
||||
|
||||
middlewareScenario(t, "middleware should pass cache-control on resources with private cache control", func(t *testing.T, sc *scenarioContext) {
|
||||
sc = sc.fakeReq("GET", "/api/datasources/1/resources/foo")
|
||||
sc.resp.Header().Add("Cache-Control", "private")
|
||||
sc.resp.Header().Add("Cache-Control", "private, max-age=86400")
|
||||
sc.resp.Header().Add("X-Grafana-Cache", "true")
|
||||
sc.exec()
|
||||
assert.Equal(t, "private", sc.resp.Header().Get("Cache-Control"))
|
||||
assert.Equal(t, "private, max-age=86400", sc.resp.Header().Get("Cache-Control"))
|
||||
})
|
||||
|
||||
middlewareScenario(t, "middleware should not pass cache-control on resources with public cache control", func(t *testing.T, sc *scenarioContext) {
|
||||
sc = sc.fakeReq("GET", "/api/datasources/1/resources/foo")
|
||||
sc.resp.Header().Add("Cache-Control", "public")
|
||||
sc.resp.Header().Add("Cache-Control", "public, max-age=86400, private")
|
||||
sc.resp.Header().Add("X-Grafana-Cache", "true")
|
||||
sc.exec()
|
||||
assert.Equal(t, noStore, sc.resp.Header().Get("Cache-Control"))
|
||||
|
||||
Reference in New Issue
Block a user