MM-10658 Change config fields to pointers (#9033)
* MM 10658 Change config fields to pointers (#8898) * Change fields of config structs to pointers and set defaults MM-10658 https://github.com/mattermost/mattermost-server/issues/8841 * Fix tests that go broken during switching config structs to pointers MM-10658 https://github.com/mattermost/mattermost-server/issues/8841 * Apply changes of current master while switching config structs to pointers MM-10658 https://github.com/mattermost/mattermost-server/issues/8841 * Fix new config pointer uses * Fix app tests * Fix mail test * remove debugging statement * fix TestUpdateConfig * assign config consistently * initialize AmazonS3Region in TestS3TestConnection * initialize fields for TestEmailTest * fix TestCheckMandatoryS3Fields
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
0c981aa010
Коммит
2ca222033c
@@ -17,9 +17,9 @@ func TestCreateIncomingWebhook(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnablePostUsernameOverride = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnablePostIconOverride = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnablePostUsernameOverride = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnablePostIconOverride = true })
|
||||
|
||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||
defer func() {
|
||||
@@ -63,13 +63,13 @@ func TestCreateIncomingWebhook(t *testing.T) {
|
||||
_, resp = Client.CreateIncomingWebhook(hook)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnablePostUsernameOverride = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnablePostIconOverride = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnablePostUsernameOverride = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnablePostIconOverride = false })
|
||||
|
||||
_, resp = Client.CreateIncomingWebhook(hook)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableIncomingWebhooks = false })
|
||||
_, resp = Client.CreateIncomingWebhook(hook)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func TestGetIncomingWebhooks(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
|
||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||
defer func() {
|
||||
@@ -158,7 +158,7 @@ func TestGetIncomingWebhook(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.SystemAdminClient
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
|
||||
var resp *model.Response
|
||||
var rhook *model.IncomingWebhook
|
||||
@@ -197,7 +197,7 @@ func TestDeleteIncomingWebhook(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.SystemAdminClient
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
|
||||
var resp *model.Response
|
||||
var rhook *model.IncomingWebhook
|
||||
@@ -248,7 +248,7 @@ func TestCreateOutgoingWebhook(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
|
||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||
defer func() {
|
||||
@@ -288,7 +288,7 @@ func TestCreateOutgoingWebhook(t *testing.T) {
|
||||
_, resp = Client.CreateOutgoingWebhook(hook)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOutgoingWebhooks = false })
|
||||
_, resp = Client.CreateOutgoingWebhook(hook)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
}
|
||||
@@ -298,7 +298,7 @@ func TestGetOutgoingWebhooks(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||
defer func() {
|
||||
th.RestoreDefaultRolePermissions(defaultRolePermissions)
|
||||
@@ -399,7 +399,7 @@ func TestGetOutgoingWebhook(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
|
||||
hook := &model.OutgoingWebhook{ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId, CallbackURLs: []string{"http://nowhere.com"}}
|
||||
|
||||
@@ -429,7 +429,7 @@ func TestUpdateIncomingHook(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
|
||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||
defer func() {
|
||||
@@ -443,8 +443,8 @@ func TestUpdateIncomingHook(t *testing.T) {
|
||||
createdHook, resp := th.SystemAdminClient.CreateIncomingWebhook(hook1)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnablePostUsernameOverride = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnablePostIconOverride = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnablePostUsernameOverride = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnablePostIconOverride = false })
|
||||
|
||||
t.Run("UpdateIncomingHook, overrides disabled", func(t *testing.T) {
|
||||
createdHook.DisplayName = "hook2"
|
||||
@@ -483,8 +483,8 @@ func TestUpdateIncomingHook(t *testing.T) {
|
||||
assert.Equal(t, updatedHook.ChannelId, createdHook.ChannelId)
|
||||
})
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnablePostUsernameOverride = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnablePostIconOverride = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnablePostUsernameOverride = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnablePostIconOverride = true })
|
||||
|
||||
t.Run("UpdateIncomingHook", func(t *testing.T) {
|
||||
createdHook.DisplayName = "hook2"
|
||||
@@ -604,13 +604,13 @@ func TestUpdateIncomingHook(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("IncomingHooksDisabled", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableIncomingWebhooks = false })
|
||||
_, resp := Client.UpdateIncomingWebhook(createdHook)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
CheckErrorMessage(t, resp, "api.incoming_webhook.disabled.app_error")
|
||||
})
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
|
||||
t.Run("PrivateChannel", func(t *testing.T) {
|
||||
privateChannel := th.CreatePrivateChannel()
|
||||
@@ -644,7 +644,7 @@ func TestRegenOutgoingHookToken(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
|
||||
hook := &model.OutgoingWebhook{ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId, CallbackURLs: []string{"http://nowhere.com"}}
|
||||
rhook, resp := th.SystemAdminClient.CreateOutgoingWebhook(hook)
|
||||
@@ -666,7 +666,7 @@ func TestRegenOutgoingHookToken(t *testing.T) {
|
||||
_, resp = Client.RegenOutgoingHookToken(rhook.Id)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOutgoingWebhooks = false })
|
||||
_, resp = th.SystemAdminClient.RegenOutgoingHookToken(rhook.Id)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
}
|
||||
@@ -676,7 +676,7 @@ func TestUpdateOutgoingHook(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||
defer func() {
|
||||
th.RestoreDefaultRolePermissions(defaultRolePermissions)
|
||||
@@ -705,12 +705,12 @@ func TestUpdateOutgoingHook(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("OutgoingHooksDisabled", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOutgoingWebhooks = false })
|
||||
_, resp := th.SystemAdminClient.UpdateOutgoingWebhook(createdHook)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
})
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
t.Run("RetainCreateAt", func(t *testing.T) {
|
||||
hook2 := &model.OutgoingWebhook{ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId,
|
||||
CallbackURLs: []string{"http://nowhere.com"}, TriggerWords: []string{"rats"}}
|
||||
@@ -839,7 +839,7 @@ func TestDeleteOutgoingHook(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.SystemAdminClient
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
|
||||
var resp *model.Response
|
||||
var rhook *model.OutgoingWebhook
|
||||
|
||||
Ссылка в новой задаче
Block a user