Settings: Rename constants/variables to follow Go naming standards (#28002)

* settings: Rename constants/variables to follow Go naming standards
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
Arve Knudsen
2020-10-02 15:45:45 +02:00
committed by GitHub
parent a5e12f653d
commit a078e40238
23 changed files with 62 additions and 62 deletions

View File

@@ -267,7 +267,7 @@ func rotateEndOfRequestFunc(ctx *models.ReqContext, authTokenService models.User
}
func WriteSessionCookie(ctx *models.ReqContext, value string, maxLifetime time.Duration) {
if setting.Env == setting.DEV {
if setting.Env == setting.Dev {
ctx.Logger.Info("New token", "unhashed token", value)
}
@@ -304,7 +304,8 @@ func AddDefaultResponseHeaders() macaron.Handler {
// AddSecurityHeaders adds various HTTP(S) response headers that enable various security protections behaviors in the client's browser.
func AddSecurityHeaders(w macaron.ResponseWriter) {
if (setting.Protocol == setting.HTTPS || setting.Protocol == setting.HTTP2) && setting.StrictTransportSecurity {
if (setting.Protocol == setting.HTTPSScheme || setting.Protocol == setting.HTTP2Scheme) &&
setting.StrictTransportSecurity {
strictHeaderValues := []string{fmt.Sprintf("max-age=%v", setting.StrictTransportSecurityMaxAge)}
if setting.StrictTransportSecurityPreload {
strictHeaderValues = append(strictHeaderValues, "preload")

View File

@@ -44,7 +44,7 @@ func resetGetTime() {
}
func TestMiddleWareSecurityHeaders(t *testing.T) {
setting.ERR_TEMPLATE_NAME = errorTemplate
setting.ErrTemplateName = errorTemplate
Convey("Given the grafana middleware", t, func() {
middlewareScenario(t, "middleware should get correct x-xss-protection header", func(sc *scenarioContext) {
@@ -61,7 +61,7 @@ func TestMiddleWareSecurityHeaders(t *testing.T) {
middlewareScenario(t, "middleware should add correct Strict-Transport-Security header", func(sc *scenarioContext) {
setting.StrictTransportSecurity = true
setting.Protocol = setting.HTTPS
setting.Protocol = setting.HTTPSScheme
setting.StrictTransportSecurityMaxAge = 64000
sc.fakeReq("GET", "/api/").exec()
So(sc.resp.Header().Get("Strict-Transport-Security"), ShouldEqual, "max-age=64000")
@@ -76,7 +76,7 @@ func TestMiddleWareSecurityHeaders(t *testing.T) {
}
func TestMiddlewareContext(t *testing.T) {
setting.ERR_TEMPLATE_NAME = errorTemplate
setting.ErrTemplateName = errorTemplate
Convey("Given the grafana middleware", t, func() {
middlewareScenario(t, "middleware should add context to injector", func(sc *scenarioContext) {

View File

@@ -130,7 +130,7 @@ func Recovery() macaron.Handler {
c.Data["AppSubUrl"] = setting.AppSubUrl
c.Data["Theme"] = setting.DefaultTheme
if setting.Env == setting.DEV {
if setting.Env == setting.Dev {
if theErr, ok := err.(error); ok {
c.Data["Title"] = theErr.Error()
}
@@ -152,7 +152,7 @@ func Recovery() macaron.Handler {
c.JSON(500, resp)
} else {
c.HTML(500, setting.ERR_TEMPLATE_NAME)
c.HTML(500, setting.ErrTemplateName)
}
}
}()

View File

@@ -14,7 +14,7 @@ import (
)
func TestRecoveryMiddleware(t *testing.T) {
setting.ERR_TEMPLATE_NAME = "error-template"
setting.ErrTemplateName = "error-template"
Convey("Given an api route that panics", t, func() {
apiURL := "/api/whatever"