Reduce utils.Cfg references (#7650)
* app.UpdateConfig method * test fix * another test fix * the config override option as-was is just error prone, remove it for now * derp
Этот коммит содержится в:
@@ -9,9 +9,8 @@ import (
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"testing"
|
||||
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
func TestGetOpenGraphMetadata(t *testing.T) {
|
||||
@@ -20,14 +19,18 @@ func TestGetOpenGraphMetadata(t *testing.T) {
|
||||
|
||||
Client := th.Client
|
||||
|
||||
enableLinkPreviews := *utils.Cfg.ServiceSettings.EnableLinkPreviews
|
||||
allowedInternalConnections := *utils.Cfg.ServiceSettings.AllowedUntrustedInternalConnections
|
||||
enableLinkPreviews := *th.App.Config().ServiceSettings.EnableLinkPreviews
|
||||
allowedInternalConnections := *th.App.Config().ServiceSettings.AllowedUntrustedInternalConnections
|
||||
defer func() {
|
||||
*utils.Cfg.ServiceSettings.EnableLinkPreviews = enableLinkPreviews
|
||||
utils.Cfg.ServiceSettings.AllowedUntrustedInternalConnections = &allowedInternalConnections
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableLinkPreviews = enableLinkPreviews })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.ServiceSettings.AllowedUntrustedInternalConnections = &allowedInternalConnections
|
||||
})
|
||||
}()
|
||||
*utils.Cfg.ServiceSettings.EnableLinkPreviews = true
|
||||
*utils.Cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost 127.0.0.1"
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableLinkPreviews = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost 127.0.0.1"
|
||||
})
|
||||
|
||||
ogDataCacheMissCount := 0
|
||||
|
||||
@@ -72,7 +75,7 @@ func TestGetOpenGraphMetadata(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
*utils.Cfg.ServiceSettings.EnableLinkPreviews = false
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableLinkPreviews = false })
|
||||
_, resp := Client.OpenGraph(ts.URL + "/og-data/")
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user