Auth: Separate anonymous settings to its own struct (#97791)
separate anonymous settings to its own struct
This commit is contained in:
@@ -157,7 +157,7 @@ func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.Fro
|
||||
}
|
||||
}
|
||||
|
||||
hideVersion := hs.Cfg.AnonymousHideVersion && !c.IsSignedIn
|
||||
hideVersion := hs.Cfg.Anonymous.HideVersion && !c.IsSignedIn
|
||||
version := setting.BuildVersion
|
||||
commit := setting.BuildCommit
|
||||
commitShort := getShortCommitHash(setting.BuildCommit, 10)
|
||||
@@ -266,8 +266,8 @@ func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.Fro
|
||||
},
|
||||
|
||||
FeatureToggles: featureToggles,
|
||||
AnonymousEnabled: hs.Cfg.AnonymousEnabled,
|
||||
AnonymousDeviceLimit: hs.Cfg.AnonymousDeviceLimit,
|
||||
AnonymousEnabled: hs.Cfg.Anonymous.Enabled,
|
||||
AnonymousDeviceLimit: hs.Cfg.Anonymous.DeviceLimit,
|
||||
RendererAvailable: hs.RenderService.IsAvailable(c.Req.Context()),
|
||||
RendererVersion: hs.RenderService.Version(),
|
||||
RendererDefaultImageWidth: hs.Cfg.RendererDefaultImageWidth,
|
||||
|
||||
@@ -160,7 +160,7 @@ func TestHTTPServer_GetFrontendSettings_hideVersionAnonymous(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
hs.Cfg.AnonymousHideVersion = test.hideVersion
|
||||
hs.Cfg.Anonymous.HideVersion = test.hideVersion
|
||||
expected := test.expected
|
||||
|
||||
recorder := httptest.NewRecorder()
|
||||
|
||||
@@ -61,7 +61,7 @@ func TestHealthAPI_VersionEnterprise(t *testing.T) {
|
||||
|
||||
func TestHealthAPI_AnonymousHideVersion(t *testing.T) {
|
||||
m, hs := setupHealthAPITestEnvironment(t)
|
||||
hs.Cfg.AnonymousHideVersion = true
|
||||
hs.Cfg.Anonymous.HideVersion = true
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/api/health", nil)
|
||||
rec := httptest.NewRecorder()
|
||||
@@ -80,7 +80,7 @@ func TestHealthAPI_DatabaseHealthy(t *testing.T) {
|
||||
const cacheKey = "db-healthy"
|
||||
|
||||
m, hs := setupHealthAPITestEnvironment(t)
|
||||
hs.Cfg.AnonymousHideVersion = true
|
||||
hs.Cfg.Anonymous.HideVersion = true
|
||||
|
||||
healthy, found := hs.CacheService.Get(cacheKey)
|
||||
require.False(t, found)
|
||||
@@ -107,7 +107,7 @@ func TestHealthAPI_DatabaseUnhealthy(t *testing.T) {
|
||||
const cacheKey = "db-healthy"
|
||||
|
||||
m, hs := setupHealthAPITestEnvironment(t)
|
||||
hs.Cfg.AnonymousHideVersion = true
|
||||
hs.Cfg.Anonymous.HideVersion = true
|
||||
hs.SQLStore.(*dbtest.FakeDB).ExpectedError = errors.New("bad")
|
||||
|
||||
healthy, found := hs.CacheService.Get(cacheKey)
|
||||
@@ -135,7 +135,7 @@ func TestHealthAPI_DatabaseHealthCached(t *testing.T) {
|
||||
const cacheKey = "db-healthy"
|
||||
|
||||
m, hs := setupHealthAPITestEnvironment(t)
|
||||
hs.Cfg.AnonymousHideVersion = true
|
||||
hs.Cfg.Anonymous.HideVersion = true
|
||||
|
||||
// Mock unhealthy database in cache.
|
||||
hs.CacheService.Set(cacheKey, false, 5*time.Minute)
|
||||
|
||||
@@ -716,7 +716,7 @@ func (hs *HTTPServer) apiHealthHandler(ctx *web.Context) {
|
||||
data := healthResponse{
|
||||
Database: "ok",
|
||||
}
|
||||
if !hs.Cfg.AnonymousHideVersion {
|
||||
if !hs.Cfg.Anonymous.HideVersion {
|
||||
data.Version = hs.Cfg.BuildVersion
|
||||
data.Commit = hs.Cfg.BuildCommit
|
||||
if hs.Cfg.EnterpriseBuildCommit != "NA" && hs.Cfg.EnterpriseBuildCommit != "" {
|
||||
|
||||
Reference in New Issue
Block a user