From 08b7b1c4144f18a9dbf52bfe0eb9182f2b4eba4a Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 23 Oct 2017 02:39:51 -0700 Subject: Reduce cfg boilerplate (#7689) * reduce cfg boilerplate * fix compile error * user test fix * another test fix * simplify diagnostics / testing --- api4/apitestlib.go | 9 +++++- api4/user_test.go | 82 +++------------------------------------------------- api4/webhook_test.go | 77 ------------------------------------------------ 3 files changed, 12 insertions(+), 156 deletions(-) (limited to 'api4') diff --git a/api4/apitestlib.go b/api4/apitestlib.go index 3e093df56..54b142c4b 100644 --- a/api4/apitestlib.go +++ b/api4/apitestlib.go @@ -32,7 +32,8 @@ import ( ) type TestHelper struct { - App *app.App + App *app.App + originalConfig *model.Config Client *model.Client4 BasicUser *model.User @@ -86,6 +87,7 @@ func setupTestHelper(enterprise bool) *TestHelper { th := &TestHelper{ App: app.New(options...), } + th.originalConfig = th.App.Config().Clone() th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.MaxUsersPerTeam = 50 }) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.RateLimitSettings.Enable = false }) @@ -177,6 +179,11 @@ func (me *TestHelper) TearDown() { wg.Wait() + me.App.UpdateConfig(func(cfg *model.Config) { + *cfg = *me.originalConfig + }) + utils.SetDefaultRolesBasedOnConfig() + me.App.Shutdown() utils.EnableDebugLogForTest() diff --git a/api4/user_test.go b/api4/user_test.go index 59057f347..664b7375a 100644 --- a/api4/user_test.go +++ b/api4/user_test.go @@ -63,12 +63,6 @@ func TestCreateUser(t *testing.T) { CheckErrorMessage(t, resp, "model.user.is_valid.email.app_error") CheckBadRequestStatus(t, resp) - openServer := *th.App.Config().TeamSettings.EnableOpenServer - canCreateAccount := th.App.Config().TeamSettings.EnableUserCreation - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableOpenServer = openServer }) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.EnableUserCreation = canCreateAccount }) - }() th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableOpenServer = false }) th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.EnableUserCreation = false }) @@ -185,15 +179,13 @@ func TestCreateUserWithHash(t *testing.T) { data := model.MapToJson(props) hash := utils.HashSha256(fmt.Sprintf("%v:%v", data, th.App.Config().EmailSettings.InviteSalt)) - canCreateAccount := th.App.Config().TeamSettings.EnableUserCreation - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.EnableUserCreation = canCreateAccount }) - }() th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.EnableUserCreation = false }) _, resp := Client.CreateUserWithHash(&user, hash, data) CheckNotImplementedStatus(t, resp) CheckErrorMessage(t, resp, "api.user.create_user.signup_email_disabled.app_error") + + th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.EnableUserCreation = true }) }) t.Run("EnableOpenServerDisable", func(t *testing.T) { @@ -208,10 +200,6 @@ func TestCreateUserWithHash(t *testing.T) { data := model.MapToJson(props) hash := utils.HashSha256(fmt.Sprintf("%v:%v", data, th.App.Config().EmailSettings.InviteSalt)) - openServer := *th.App.Config().TeamSettings.EnableOpenServer - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableOpenServer = openServer }) - }() th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableOpenServer = false }) ruser, resp := Client.CreateUserWithHash(&user, hash, data) @@ -291,10 +279,6 @@ func TestCreateUserWithInviteId(t *testing.T) { t.Run("EnableUserCreationDisable", func(t *testing.T) { user := model.User{Email: GenerateTestEmail(), Nickname: "Corey Hulen", Password: "hello1", Username: GenerateTestUsername(), Roles: model.ROLE_SYSTEM_ADMIN.Id + " " + model.ROLE_SYSTEM_USER.Id} - canCreateAccount := th.App.Config().TeamSettings.EnableUserCreation - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.EnableUserCreation = canCreateAccount }) - }() th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.EnableUserCreation = false }) inviteId := th.BasicTeam.InviteId @@ -302,15 +286,13 @@ func TestCreateUserWithInviteId(t *testing.T) { _, resp := Client.CreateUserWithInviteId(&user, inviteId) CheckNotImplementedStatus(t, resp) CheckErrorMessage(t, resp, "api.user.create_user.signup_email_disabled.app_error") + + th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.EnableUserCreation = true }) }) t.Run("EnableOpenServerDisable", func(t *testing.T) { user := model.User{Email: GenerateTestEmail(), Nickname: "Corey Hulen", Password: "hello1", Username: GenerateTestUsername(), Roles: model.ROLE_SYSTEM_ADMIN.Id + " " + model.ROLE_SYSTEM_USER.Id} - openServer := *th.App.Config().TeamSettings.EnableOpenServer - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableOpenServer = openServer }) - }() th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableOpenServer = false }) inviteId := th.BasicTeam.InviteId @@ -380,12 +362,6 @@ func TestGetUser(t *testing.T) { CheckNotFoundStatus(t, resp) // Check against privacy config settings - emailPrivacy := th.App.Config().PrivacySettings.ShowEmailAddress - namePrivacy := th.App.Config().PrivacySettings.ShowFullName - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = emailPrivacy }) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = namePrivacy }) - }() th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = false }) th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = false }) @@ -441,12 +417,6 @@ func TestGetUserByUsername(t *testing.T) { CheckNotFoundStatus(t, resp) // Check against privacy config settings - emailPrivacy := th.App.Config().PrivacySettings.ShowEmailAddress - namePrivacy := th.App.Config().PrivacySettings.ShowFullName - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = emailPrivacy }) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = namePrivacy }) - }() th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = false }) th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = false }) @@ -505,12 +475,6 @@ func TestGetUserByEmail(t *testing.T) { CheckNotFoundStatus(t, resp) // Check against privacy config settings - emailPrivacy := th.App.Config().PrivacySettings.ShowEmailAddress - namePrivacy := th.App.Config().PrivacySettings.ShowFullName - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = emailPrivacy }) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = namePrivacy }) - }() th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = false }) th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = false }) @@ -672,12 +636,6 @@ func TestSearchUsers(t *testing.T) { search.Term = th.BasicUser.Username - emailPrivacy := th.App.Config().PrivacySettings.ShowEmailAddress - namePrivacy := th.App.Config().PrivacySettings.ShowFullName - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = emailPrivacy }) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = namePrivacy }) - }() th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = false }) th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = false }) @@ -830,10 +788,6 @@ func TestAutocompleteUsers(t *testing.T) { CheckNoError(t, resp) // Check against privacy config settings - namePrivacy := th.App.Config().PrivacySettings.ShowFullName - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = namePrivacy }) - }() th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = false }) th.LoginBasic() @@ -1739,10 +1693,6 @@ func TestUpdateUserPassword(t *testing.T) { th.LoginBasic() // Test lockout - passwordAttempts := *th.App.Config().ServiceSettings.MaximumLoginAttempts - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.MaximumLoginAttempts = passwordAttempts }) - }() th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.MaximumLoginAttempts = 2 }) // Fail twice @@ -2181,10 +2131,6 @@ func TestSwitchAccount(t *testing.T) { defer th.TearDown() Client := th.Client - enableGitLab := th.App.Config().GitLabSettings.Enable - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { cfg.GitLabSettings.Enable = enableGitLab }) - }() th.App.UpdateConfig(func(cfg *model.Config) { cfg.GitLabSettings.Enable = true }) Client.Logout() @@ -2275,10 +2221,6 @@ func TestCreateUserAccessToken(t *testing.T) { testDescription := "test token" - enableUserAccessTokens := *th.App.Config().ServiceSettings.EnableUserAccessTokens - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableUserAccessTokens = enableUserAccessTokens }) - }() th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableUserAccessTokens = true }) _, resp := Client.CreateUserAccessToken(th.BasicUser.Id, testDescription) @@ -2360,10 +2302,6 @@ func TestGetUserAccessToken(t *testing.T) { testDescription := "test token" - enableUserAccessTokens := *th.App.Config().ServiceSettings.EnableUserAccessTokens - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableUserAccessTokens = enableUserAccessTokens }) - }() th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableUserAccessTokens = true }) _, resp := Client.GetUserAccessToken("123") @@ -2431,10 +2369,6 @@ func TestRevokeUserAccessToken(t *testing.T) { testDescription := "test token" - enableUserAccessTokens := *th.App.Config().ServiceSettings.EnableUserAccessTokens - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableUserAccessTokens = enableUserAccessTokens }) - }() th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableUserAccessTokens = true }) th.App.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_USER_ACCESS_TOKEN.Id) @@ -2572,10 +2506,6 @@ func TestUserAccessTokenInactiveUser(t *testing.T) { testDescription := "test token" - enableUserAccessTokens := *th.App.Config().ServiceSettings.EnableUserAccessTokens - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableUserAccessTokens = enableUserAccessTokens }) - }() th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableUserAccessTokens = true }) th.App.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_USER_ACCESS_TOKEN.Id) @@ -2599,10 +2529,6 @@ func TestUserAccessTokenDisableConfig(t *testing.T) { testDescription := "test token" - enableUserAccessTokens := *th.App.Config().ServiceSettings.EnableUserAccessTokens - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableUserAccessTokens = enableUserAccessTokens }) - }() th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableUserAccessTokens = true }) th.App.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_USER_ACCESS_TOKEN.Id) diff --git a/api4/webhook_test.go b/api4/webhook_test.go index 6740ee097..71aa7b9b3 100644 --- a/api4/webhook_test.go +++ b/api4/webhook_test.go @@ -19,13 +19,6 @@ func TestCreateIncomingWebhook(t *testing.T) { defer th.TearDown() Client := th.Client - enableIncomingHooks := th.App.Config().ServiceSettings.EnableIncomingWebhooks - enableAdminOnlyHooks := th.App.Config().ServiceSettings.EnableOnlyAdminIntegrations - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = enableIncomingHooks }) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOnlyAdminIntegrations = enableAdminOnlyHooks }) - utils.SetDefaultRolesBasedOnConfig() - }() th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true }) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = true }) utils.SetDefaultRolesBasedOnConfig() @@ -76,13 +69,6 @@ func TestGetIncomingWebhooks(t *testing.T) { defer th.TearDown() Client := th.Client - enableIncomingHooks := th.App.Config().ServiceSettings.EnableIncomingWebhooks - enableAdminOnlyHooks := th.App.Config().ServiceSettings.EnableOnlyAdminIntegrations - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = enableIncomingHooks }) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOnlyAdminIntegrations = enableAdminOnlyHooks }) - utils.SetDefaultRolesBasedOnConfig() - }() th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true }) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = true }) utils.SetDefaultRolesBasedOnConfig() @@ -158,13 +144,6 @@ func TestGetIncomingWebhook(t *testing.T) { defer th.TearDown() Client := th.SystemAdminClient - enableIncomingHooks := th.App.Config().ServiceSettings.EnableIncomingWebhooks - enableAdminOnlyHooks := th.App.Config().ServiceSettings.EnableOnlyAdminIntegrations - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = enableIncomingHooks }) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOnlyAdminIntegrations = enableAdminOnlyHooks }) - utils.SetDefaultRolesBasedOnConfig() - }() th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true }) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = true }) utils.SetDefaultRolesBasedOnConfig() @@ -206,13 +185,6 @@ func TestDeleteIncomingWebhook(t *testing.T) { defer th.TearDown() Client := th.SystemAdminClient - enableIncomingHooks := th.App.Config().ServiceSettings.EnableIncomingWebhooks - enableAdminOnlyHooks := th.App.Config().ServiceSettings.EnableOnlyAdminIntegrations - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = enableIncomingHooks }) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOnlyAdminIntegrations = enableAdminOnlyHooks }) - utils.SetDefaultRolesBasedOnConfig() - }() th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true }) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = true }) utils.SetDefaultRolesBasedOnConfig() @@ -266,13 +238,6 @@ func TestCreateOutgoingWebhook(t *testing.T) { defer th.TearDown() Client := th.Client - enableOutgoingHooks := th.App.Config().ServiceSettings.EnableOutgoingWebhooks - enableAdminOnlyHooks := th.App.Config().ServiceSettings.EnableOnlyAdminIntegrations - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = enableOutgoingHooks }) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOnlyAdminIntegrations = enableAdminOnlyHooks }) - utils.SetDefaultRolesBasedOnConfig() - }() th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true }) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = true }) utils.SetDefaultRolesBasedOnConfig() @@ -319,13 +284,6 @@ func TestGetOutgoingWebhooks(t *testing.T) { defer th.TearDown() Client := th.Client - enableOutgoingHooks := th.App.Config().ServiceSettings.EnableOutgoingWebhooks - enableAdminOnlyHooks := th.App.Config().ServiceSettings.EnableOnlyAdminIntegrations - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = enableOutgoingHooks }) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOnlyAdminIntegrations = enableAdminOnlyHooks }) - utils.SetDefaultRolesBasedOnConfig() - }() th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true }) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = true }) utils.SetDefaultRolesBasedOnConfig() @@ -424,13 +382,6 @@ func TestGetOutgoingWebhook(t *testing.T) { defer th.TearDown() Client := th.Client - enableOutgoingHooks := th.App.Config().ServiceSettings.EnableOutgoingWebhooks - enableAdminOnlyHooks := th.App.Config().ServiceSettings.EnableOnlyAdminIntegrations - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = enableOutgoingHooks }) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOnlyAdminIntegrations = enableAdminOnlyHooks }) - utils.SetDefaultRolesBasedOnConfig() - }() th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true }) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = true }) utils.SetDefaultRolesBasedOnConfig() @@ -463,13 +414,6 @@ func TestUpdateIncomingHook(t *testing.T) { defer th.TearDown() Client := th.Client - enableIncomingHooks := th.App.Config().ServiceSettings.EnableIncomingWebhooks - enableAdminOnlyHooks := th.App.Config().ServiceSettings.EnableOnlyAdminIntegrations - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = enableIncomingHooks }) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOnlyAdminIntegrations = enableAdminOnlyHooks }) - utils.SetDefaultRolesBasedOnConfig() - }() th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true }) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = true }) utils.SetDefaultRolesBasedOnConfig() @@ -632,13 +576,6 @@ func TestRegenOutgoingHookToken(t *testing.T) { defer th.TearDown() Client := th.Client - enableOutgoingHooks := th.App.Config().ServiceSettings.EnableOutgoingWebhooks - enableAdminOnlyHooks := th.App.Config().ServiceSettings.EnableOnlyAdminIntegrations - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = enableOutgoingHooks }) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOnlyAdminIntegrations = enableAdminOnlyHooks }) - utils.SetDefaultRolesBasedOnConfig() - }() th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true }) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = true }) utils.SetDefaultRolesBasedOnConfig() @@ -673,13 +610,6 @@ func TestUpdateOutgoingHook(t *testing.T) { defer th.TearDown() Client := th.Client - enableOutgoingHooks := th.App.Config().ServiceSettings.EnableOutgoingWebhooks - enableAdminOnlyHooks := th.App.Config().ServiceSettings.EnableOnlyAdminIntegrations - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = enableOutgoingHooks }) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOnlyAdminIntegrations = enableAdminOnlyHooks }) - utils.SetDefaultRolesBasedOnConfig() - }() th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true }) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = true }) utils.SetDefaultRolesBasedOnConfig() @@ -840,13 +770,6 @@ func TestDeleteOutgoingHook(t *testing.T) { defer th.TearDown() Client := th.SystemAdminClient - enableIncomingHooks := th.App.Config().ServiceSettings.EnableIncomingWebhooks - enableAdminOnlyHooks := th.App.Config().ServiceSettings.EnableOnlyAdminIntegrations - defer func() { - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = enableIncomingHooks }) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOnlyAdminIntegrations = enableAdminOnlyHooks }) - utils.SetDefaultRolesBasedOnConfig() - }() th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true }) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = true }) utils.SetDefaultRolesBasedOnConfig() -- cgit v1.2.3-1-g7c22