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
Этот коммит содержится в:
@@ -124,19 +124,23 @@ func testCreatePostWithOutgoingHook(
|
||||
team := th.BasicTeam
|
||||
channel := th.BasicChannel
|
||||
|
||||
enableOutgoingHooks := utils.Cfg.ServiceSettings.EnableOutgoingWebhooks
|
||||
enableAdminOnlyHooks := utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations
|
||||
allowedInternalConnections := *utils.Cfg.ServiceSettings.AllowedUntrustedInternalConnections
|
||||
enableOutgoingHooks := th.App.Config().ServiceSettings.EnableOutgoingWebhooks
|
||||
enableAdminOnlyHooks := th.App.Config().ServiceSettings.EnableOnlyAdminIntegrations
|
||||
allowedInternalConnections := *th.App.Config().ServiceSettings.AllowedUntrustedInternalConnections
|
||||
defer func() {
|
||||
utils.Cfg.ServiceSettings.EnableOutgoingWebhooks = enableOutgoingHooks
|
||||
utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations = enableAdminOnlyHooks
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = enableOutgoingHooks })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOnlyAdminIntegrations = enableAdminOnlyHooks })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
utils.Cfg.ServiceSettings.AllowedUntrustedInternalConnections = &allowedInternalConnections
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.ServiceSettings.AllowedUntrustedInternalConnections = &allowedInternalConnections
|
||||
})
|
||||
}()
|
||||
utils.Cfg.ServiceSettings.EnableOutgoingWebhooks = true
|
||||
*utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations = true
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = true })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
*utils.Cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost 127.0.0.1"
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost 127.0.0.1"
|
||||
})
|
||||
|
||||
var hook *model.OutgoingWebhook
|
||||
var post *model.Post
|
||||
@@ -375,18 +379,18 @@ func TestUpdatePost(t *testing.T) {
|
||||
|
||||
isLicensed := utils.IsLicensed()
|
||||
license := utils.License()
|
||||
allowEditPost := *utils.Cfg.ServiceSettings.AllowEditPost
|
||||
allowEditPost := *th.App.Config().ServiceSettings.AllowEditPost
|
||||
defer func() {
|
||||
utils.SetIsLicensed(isLicensed)
|
||||
utils.SetLicense(license)
|
||||
*utils.Cfg.ServiceSettings.AllowEditPost = allowEditPost
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = allowEditPost })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
}()
|
||||
utils.SetIsLicensed(true)
|
||||
utils.SetLicense(&model.License{Features: &model.Features{}})
|
||||
utils.License().Features.SetDefaults()
|
||||
|
||||
*utils.Cfg.ServiceSettings.AllowEditPost = model.ALLOW_EDIT_POST_ALWAYS
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = model.ALLOW_EDIT_POST_ALWAYS })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
post := &model.Post{ChannelId: channel.Id, Message: "zz" + model.NewId() + "a"}
|
||||
@@ -455,18 +459,18 @@ func TestPatchPost(t *testing.T) {
|
||||
|
||||
isLicensed := utils.IsLicensed()
|
||||
license := utils.License()
|
||||
allowEditPost := *utils.Cfg.ServiceSettings.AllowEditPost
|
||||
allowEditPost := *th.App.Config().ServiceSettings.AllowEditPost
|
||||
defer func() {
|
||||
utils.SetIsLicensed(isLicensed)
|
||||
utils.SetLicense(license)
|
||||
*utils.Cfg.ServiceSettings.AllowEditPost = allowEditPost
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = allowEditPost })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
}()
|
||||
utils.SetIsLicensed(true)
|
||||
utils.SetLicense(&model.License{Features: &model.Features{}})
|
||||
utils.License().Features.SetDefaults()
|
||||
|
||||
*utils.Cfg.ServiceSettings.AllowEditPost = model.ALLOW_EDIT_POST_ALWAYS
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = model.ALLOW_EDIT_POST_ALWAYS })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
post := &model.Post{
|
||||
|
||||
Ссылка в новой задаче
Block a user