summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/apitestlib.go9
-rw-r--r--api/command_loadtest_test.go112
-rw-r--r--api/file_test.go42
-rw-r--r--api/post_test.go32
-rw-r--r--api/user_test.go79
-rw-r--r--api/webhook_test.go65
6 files changed, 36 insertions, 303 deletions
diff --git a/api/apitestlib.go b/api/apitestlib.go
index 5fc94cfec..b43bb2886 100644
--- a/api/apitestlib.go
+++ b/api/apitestlib.go
@@ -22,7 +22,8 @@ import (
)
type TestHelper struct {
- App *app.App
+ App *app.App
+ originalConfig *model.Config
BasicClient *model.Client
BasicTeam *model.Team
@@ -76,6 +77,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 })
@@ -372,6 +374,11 @@ func GenerateTestTeamName() string {
}
func (me *TestHelper) TearDown() {
+ me.App.UpdateConfig(func(cfg *model.Config) {
+ *cfg = *me.originalConfig
+ })
+ utils.SetDefaultRolesBasedOnConfig()
+
me.App.Shutdown()
if err := recover(); err != nil {
StopTestStore()
diff --git a/api/command_loadtest_test.go b/api/command_loadtest_test.go
index 62545ae64..e5f95881d 100644
--- a/api/command_loadtest_test.go
+++ b/api/command_loadtest_test.go
@@ -18,12 +18,6 @@ func TestLoadTestHelpCommands(t *testing.T) {
Client := th.BasicClient
channel := th.BasicChannel
- // enable testing to use /test but don't save it since we don't want to overwrite config.json
- enableTesting := th.App.Config().ServiceSettings.EnableTesting
- defer func() {
- th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = enableTesting })
- }()
-
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
rs := Client.Must(Client.Command(channel.Id, "/test help")).Data.(*model.CommandResponse)
@@ -41,12 +35,6 @@ func TestLoadTestSetupCommands(t *testing.T) {
Client := th.BasicClient
channel := th.BasicChannel
- // enable testing to use /test but don't save it since we don't want to overwrite config.json
- enableTesting := th.App.Config().ServiceSettings.EnableTesting
- defer func() {
- th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = enableTesting })
- }()
-
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
rs := Client.Must(Client.Command(channel.Id, "/test setup fuzz 1 1 1")).Data.(*model.CommandResponse)
@@ -64,12 +52,6 @@ func TestLoadTestUsersCommands(t *testing.T) {
Client := th.BasicClient
channel := th.BasicChannel
- // enable testing to use /test but don't save it since we don't want to overwrite config.json
- enableTesting := th.App.Config().ServiceSettings.EnableTesting
- defer func() {
- th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = enableTesting })
- }()
-
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
rs := Client.Must(Client.Command(channel.Id, "/test users fuzz 1 2")).Data.(*model.CommandResponse)
@@ -87,12 +69,6 @@ func TestLoadTestChannelsCommands(t *testing.T) {
Client := th.BasicClient
channel := th.BasicChannel
- // enable testing to use /test but don't save it since we don't want to overwrite config.json
- enableTesting := th.App.Config().ServiceSettings.EnableTesting
- defer func() {
- th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = enableTesting })
- }()
-
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
rs := Client.Must(Client.Command(channel.Id, "/test channels fuzz 1 2")).Data.(*model.CommandResponse)
@@ -110,12 +86,6 @@ func TestLoadTestPostsCommands(t *testing.T) {
Client := th.BasicClient
channel := th.BasicChannel
- // enable testing to use /test but don't save it since we don't want to overwrite config.json
- enableTesting := th.App.Config().ServiceSettings.EnableTesting
- defer func() {
- th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = enableTesting })
- }()
-
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
rs := Client.Must(Client.Command(channel.Id, "/test posts fuzz 2 3 2")).Data.(*model.CommandResponse)
@@ -125,85 +95,3 @@ func TestLoadTestPostsCommands(t *testing.T) {
time.Sleep(2 * time.Second)
}
-
-func TestLoadTestUrlCommands(t *testing.T) {
- //th := Setup().InitBasic()
- //Client := th.BasicClient
- //channel := th.BasicChannel
-
- // enable testing to use /loadtest but don't save it since we don't want to overwrite config.json
- //enableTesting := utils.Cfg.ServiceSettings.EnableTesting
- //defer func() {
- // utils.Cfg.ServiceSettings.EnableTesting = enableTesting
- //}()
-
- //utils.Cfg.ServiceSettings.EnableTesting = true
-
- //command := "/loadtest url "
- //if r := Client.Must(Client.Command(channel.Id, command, false)).Data.(*model.CommandResponse); r.Text != "Command must contain a url" {
- // t.Fatal("/loadtest url with no url should've failed")
- //}
- //
- //command = "/loadtest url http://missingfiletonwhere/path/asdf/qwerty"
- //if r := Client.Must(Client.Command(channel.Id, command, false)).Data.(*model.CommandResponse); r.Text != "Unable to get file" {
- // t.Log(r.Text)
- // t.Fatal("/loadtest url with invalid url should've failed")
- //}
- //
- //command = "/loadtest url https://raw.githubusercontent.com/mattermost/mattermost-server/master/README.md"
- //if r := Client.Must(Client.Command(channel.Id, command, false)).Data.(*model.CommandResponse); r.Text != "Loaded data" {
- // t.Fatal("/loadtest url for README.md should've executed")
- //}
-
- // Removing these tests since they break compatibilty with previous release branches because the url pulls from github master
-
- // command = "/loadtest url test-emoticons1.md"
- // if r := Client.Must(Client.Command(channel.Id, command, false)).Data.(*model.CommandResponse); r.Text != "Loading data..." {
- // t.Fatal("/loadtest url for test-emoticons.md should've executed")
- // }
-
- // command = "/loadtest url test-emoticons1"
- // if r := Client.Must(Client.Command(channel.Id, command, false)).Data.(*model.CommandResponse); r.Text != "Loading data..." {
- // t.Fatal("/loadtest url for test-emoticons should've executed")
- // }
-
- // posts := Client.Must(Client.GetPosts(channel.Id, 0, 5, "")).Data.(*model.PostList)
- // // note that this may make more than 3 posts if files are too long to fit in an individual post
- // if len(posts.Order) < 3 {
- // t.Fatal("/loadtest url made too few posts, perhaps there needs to be a delay before GetPosts in the test?")
- // }
-
- //time.Sleep(2 * time.Second)
-}
-
-func TestLoadTestJsonCommands(t *testing.T) {
- //th := Setup().InitBasic()
- //Client := th.BasicClient
- //channel := th.BasicChannel
-
- // enable testing to use /loadtest but don't save it since we don't want to overwrite config.json
- //enableTesting := utils.Cfg.ServiceSettings.EnableTesting
- //defer func() {
- // utils.Cfg.ServiceSettings.EnableTesting = enableTesting
- //}()
-
- //utils.Cfg.ServiceSettings.EnableTesting = true
-
- //command := "/loadtest json "
- //if r := Client.Must(Client.Command(channel.Id, command, false)).Data.(*model.CommandResponse); r.Text != "Command must contain a url" {
- // t.Fatal("/loadtest url with no url should've failed")
- //}
- //
- //command = "/loadtest json http://missingfiletonwhere/path/asdf/qwerty"
- //if r := Client.Must(Client.Command(channel.Id, command, false)).Data.(*model.CommandResponse); r.Text != "Unable to get file" {
- // t.Log(r.Text)
- // t.Fatal("/loadtest url with invalid url should've failed")
- //}
- //
- //command = "/loadtest json test-slack-attachments"
- //if r := Client.Must(Client.Command(channel.Id, command, false)).Data.(*model.CommandResponse); r.Text != "Loaded data" {
- // t.Fatal("/loadtest json should've executed")
- //}
-
- //time.Sleep(2 * time.Second)
-}
diff --git a/api/file_test.go b/api/file_test.go
index 31eb3daef..cdf06c04d 100644
--- a/api/file_test.go
+++ b/api/file_test.go
@@ -136,7 +136,7 @@ func TestUploadFile(t *testing.T) {
// Wait a bit for files to ready
time.Sleep(2 * time.Second)
- if err := cleanupTestFile(info); err != nil {
+ if err := cleanupTestFile(info, &th.App.Config().FileSettings); err != nil {
t.Fatal(err)
}
}
@@ -206,7 +206,7 @@ func TestGetFileInfo(t *testing.T) {
t.Fatal("other user got incorrect file")
}
- if err := cleanupTestFile(store.Must(th.App.Srv.Store.FileInfo().Get(fileId)).(*model.FileInfo)); err != nil {
+ if err := cleanupTestFile(store.Must(th.App.Srv.Store.FileInfo().Get(fileId)).(*model.FileInfo), &th.App.Config().FileSettings); err != nil {
t.Fatal(err)
}
}
@@ -289,7 +289,7 @@ func TestGetFile(t *testing.T) {
body.Close()
}
- if err := cleanupTestFile(store.Must(th.App.Srv.Store.FileInfo().Get(fileId)).(*model.FileInfo)); err != nil {
+ if err := cleanupTestFile(store.Must(th.App.Srv.Store.FileInfo().Get(fileId)).(*model.FileInfo), &th.App.Config().FileSettings); err != nil {
t.Fatal(err)
}
}
@@ -346,7 +346,7 @@ func TestGetFileThumbnail(t *testing.T) {
body.Close()
}
- if err := cleanupTestFile(store.Must(th.App.Srv.Store.FileInfo().Get(fileId)).(*model.FileInfo)); err != nil {
+ if err := cleanupTestFile(store.Must(th.App.Srv.Store.FileInfo().Get(fileId)).(*model.FileInfo), &th.App.Config().FileSettings); err != nil {
t.Fatal(err)
}
}
@@ -403,7 +403,7 @@ func TestGetFilePreview(t *testing.T) {
body.Close()
}
- if err := cleanupTestFile(store.Must(th.App.Srv.Store.FileInfo().Get(fileId)).(*model.FileInfo)); err != nil {
+ if err := cleanupTestFile(store.Must(th.App.Srv.Store.FileInfo().Get(fileId)).(*model.FileInfo), &th.App.Config().FileSettings); err != nil {
t.Fatal(err)
}
}
@@ -471,7 +471,7 @@ func TestGetPublicFile(t *testing.T) {
t.Fatal("should've failed to get image with public link after salt changed")
}
- if err := cleanupTestFile(store.Must(th.App.Srv.Store.FileInfo().Get(fileId)).(*model.FileInfo)); err != nil {
+ if err := cleanupTestFile(store.Must(th.App.Srv.Store.FileInfo().Get(fileId)).(*model.FileInfo), &th.App.Config().FileSettings); err != nil {
t.Fatal(err)
}
}
@@ -548,7 +548,7 @@ func TestGetPublicFileOld(t *testing.T) {
t.Fatal("should've failed to get image with public link after salt changed")
}
- if err := cleanupTestFile(store.Must(th.App.Srv.Store.FileInfo().Get(fileId)).(*model.FileInfo)); err != nil {
+ if err := cleanupTestFile(store.Must(th.App.Srv.Store.FileInfo().Get(fileId)).(*model.FileInfo), &th.App.Config().FileSettings); err != nil {
t.Fatal(err)
}
}
@@ -623,7 +623,7 @@ func TestGetPublicLink(t *testing.T) {
// Wait a bit for files to ready
time.Sleep(2 * time.Second)
- if err := cleanupTestFile(store.Must(th.App.Srv.Store.FileInfo().Get(fileId)).(*model.FileInfo)); err != nil {
+ if err := cleanupTestFile(store.Must(th.App.Srv.Store.FileInfo().Get(fileId)).(*model.FileInfo), &th.App.Config().FileSettings); err != nil {
t.Fatal(err)
}
}
@@ -899,19 +899,19 @@ func s3New(endpoint, accessKey, secretKey string, secure bool, signV2 bool, regi
return s3.NewWithCredentials(endpoint, creds, secure, region)
}
-func cleanupTestFile(info *model.FileInfo) error {
- if *utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 {
- endpoint := utils.Cfg.FileSettings.AmazonS3Endpoint
- accessKey := utils.Cfg.FileSettings.AmazonS3AccessKeyId
- secretKey := utils.Cfg.FileSettings.AmazonS3SecretAccessKey
- secure := *utils.Cfg.FileSettings.AmazonS3SSL
- signV2 := *utils.Cfg.FileSettings.AmazonS3SignV2
- region := utils.Cfg.FileSettings.AmazonS3Region
+func cleanupTestFile(info *model.FileInfo, settings *model.FileSettings) error {
+ if *settings.DriverName == model.IMAGE_DRIVER_S3 {
+ endpoint := settings.AmazonS3Endpoint
+ accessKey := settings.AmazonS3AccessKeyId
+ secretKey := settings.AmazonS3SecretAccessKey
+ secure := *settings.AmazonS3SSL
+ signV2 := *settings.AmazonS3SignV2
+ region := settings.AmazonS3Region
s3Clnt, err := s3New(endpoint, accessKey, secretKey, secure, signV2, region)
if err != nil {
return err
}
- bucket := utils.Cfg.FileSettings.AmazonS3Bucket
+ bucket := settings.AmazonS3Bucket
if err := s3Clnt.RemoveObject(bucket, info.Path); err != nil {
return err
}
@@ -927,19 +927,19 @@ func cleanupTestFile(info *model.FileInfo) error {
return err
}
}
- } else if *utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_LOCAL {
- if err := os.Remove(utils.Cfg.FileSettings.Directory + info.Path); err != nil {
+ } else if *settings.DriverName == model.IMAGE_DRIVER_LOCAL {
+ if err := os.Remove(settings.Directory + info.Path); err != nil {
return err
}
if info.ThumbnailPath != "" {
- if err := os.Remove(utils.Cfg.FileSettings.Directory + info.ThumbnailPath); err != nil {
+ if err := os.Remove(settings.Directory + info.ThumbnailPath); err != nil {
return err
}
}
if info.PreviewPath != "" {
- if err := os.Remove(utils.Cfg.FileSettings.Directory + info.PreviewPath); err != nil {
+ if err := os.Remove(settings.Directory + info.PreviewPath); err != nil {
return err
}
}
diff --git a/api/post_test.go b/api/post_test.go
index 901a7c6d0..342bd03ae 100644
--- a/api/post_test.go
+++ b/api/post_test.go
@@ -241,16 +241,8 @@ func testCreatePostWithOutgoingHook(
user := th.SystemAdminUser
channel := th.CreateChannel(Client, team)
- enableOutgoingHooks := th.App.Config().ServiceSettings.EnableOutgoingWebhooks
- allowedInternalConnections := *th.App.Config().ServiceSettings.AllowedUntrustedInternalConnections
- defer func() {
- th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = enableOutgoingHooks })
- th.App.UpdateConfig(func(cfg *model.Config) {
- cfg.ServiceSettings.AllowedUntrustedInternalConnections = &allowedInternalConnections
- })
- }()
- th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true })
th.App.UpdateConfig(func(cfg *model.Config) {
+ cfg.ServiceSettings.EnableOutgoingWebhooks = true
*cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost 127.0.0.1"
})
@@ -406,13 +398,6 @@ func TestUpdatePost(t *testing.T) {
Client := th.BasicClient
channel1 := th.BasicChannel
- allowEditPost := *th.App.Config().ServiceSettings.AllowEditPost
- postEditTimeLimit := *th.App.Config().ServiceSettings.PostEditTimeLimit
- defer func() {
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = allowEditPost })
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.PostEditTimeLimit = postEditTimeLimit })
- }()
-
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = model.ALLOW_EDIT_POST_ALWAYS })
post1 := &model.Post{ChannelId: channel1.Id, Message: "zz" + model.NewId() + "a"}
@@ -981,11 +966,6 @@ func TestDeletePosts(t *testing.T) {
channel1 := th.BasicChannel
team1 := th.BasicTeam
- restrictPostDelete := *th.App.Config().ServiceSettings.RestrictPostDelete
- defer func() {
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.RestrictPostDelete = restrictPostDelete })
- utils.SetDefaultRolesBasedOnConfig()
- }()
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.RestrictPostDelete = model.PERMISSIONS_DELETE_POST_ALL })
utils.SetDefaultRolesBasedOnConfig()
@@ -1482,16 +1462,8 @@ func TestGetOpenGraphMetadata(t *testing.T) {
Client := th.BasicClient
- enableLinkPreviews := *th.App.Config().ServiceSettings.EnableLinkPreviews
- allowedInternalConnections := *th.App.Config().ServiceSettings.AllowedUntrustedInternalConnections
- defer func() {
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableLinkPreviews = enableLinkPreviews })
- th.App.UpdateConfig(func(cfg *model.Config) {
- cfg.ServiceSettings.AllowedUntrustedInternalConnections = &allowedInternalConnections
- })
- }()
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableLinkPreviews = true })
th.App.UpdateConfig(func(cfg *model.Config) {
+ *cfg.ServiceSettings.EnableLinkPreviews = true
*cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost 127.0.0.1"
})
diff --git a/api/user_test.go b/api/user_test.go
index c339d3346..a0ffe9fd9 100644
--- a/api/user_test.go
+++ b/api/user_test.go
@@ -89,18 +89,11 @@ func TestLogin(t *testing.T) {
Client := th.BasicClient
- enableSignInWithEmail := *th.App.Config().EmailSettings.EnableSignInWithEmail
- enableSignInWithUsername := *th.App.Config().EmailSettings.EnableSignInWithUsername
- enableLdap := *th.App.Config().LdapSettings.Enable
- defer func() {
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.EmailSettings.EnableSignInWithEmail = enableSignInWithEmail })
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.EmailSettings.EnableSignInWithUsername = enableSignInWithUsername })
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.LdapSettings.Enable = enableLdap })
- }()
-
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.EmailSettings.EnableSignInWithEmail = false })
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.EmailSettings.EnableSignInWithUsername = false })
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.LdapSettings.Enable = false })
+ th.App.UpdateConfig(func(cfg *model.Config) {
+ *cfg.EmailSettings.EnableSignInWithEmail = false
+ *cfg.EmailSettings.EnableSignInWithUsername = false
+ *cfg.LdapSettings.Enable = false
+ })
team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
rteam, _ := Client.CreateTeam(&team)
@@ -272,12 +265,6 @@ func TestPasswordGuessLockout(t *testing.T) {
user := th.BasicUser
Client.Must(Client.Logout())
- enableSignInWithEmail := *th.App.Config().EmailSettings.EnableSignInWithEmail
- passwordAttempts := *th.App.Config().ServiceSettings.MaximumLoginAttempts
- defer func() {
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.EmailSettings.EnableSignInWithEmail = enableSignInWithEmail })
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.MaximumLoginAttempts = passwordAttempts })
- }()
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.EmailSettings.EnableSignInWithEmail = true })
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.MaximumLoginAttempts = 2 })
@@ -410,12 +397,6 @@ func TestGetUser(t *testing.T) {
t.Fatal("shouldn't exist")
}
- 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 })
@@ -517,11 +498,6 @@ func TestGetProfiles(t *testing.T) {
th.BasicClient.Must(th.BasicClient.CreateDirectChannel(th.BasicUser2.Id))
- prevShowEmail := th.App.Config().PrivacySettings.ShowEmailAddress
- defer func() {
- th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = prevShowEmail })
- }()
-
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = true })
if result, err := th.BasicClient.GetProfiles(0, 100, ""); err != nil {
@@ -572,11 +548,6 @@ func TestGetProfilesByIds(t *testing.T) {
th := Setup().InitBasic()
defer th.TearDown()
- prevShowEmail := th.App.Config().PrivacySettings.ShowEmailAddress
- defer func() {
- th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = prevShowEmail })
- }()
-
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = true })
if result, err := th.BasicClient.GetProfilesByIds([]string{th.BasicUser.Id}); err != nil {
@@ -960,10 +931,6 @@ func TestUserUpdatePassword(t *testing.T) {
}
// 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
@@ -1887,11 +1854,9 @@ func TestUpdateMfa(t *testing.T) {
isLicensed := utils.IsLicensed()
license := utils.License()
- enableMfa := *th.App.Config().ServiceSettings.EnableMultifactorAuthentication
defer func() {
utils.SetIsLicensed(isLicensed)
utils.SetLicense(license)
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableMultifactorAuthentication = enableMfa })
}()
utils.SetIsLicensed(false)
utils.SetLicense(&model.License{Features: &model.Features{}})
@@ -2059,11 +2024,6 @@ func TestGetProfilesInChannel(t *testing.T) {
Client := th.BasicClient
- prevShowEmail := th.App.Config().PrivacySettings.ShowEmailAddress
- defer func() {
- th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = prevShowEmail })
- }()
-
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = true })
if result, err := Client.GetProfilesInChannel(th.BasicChannel.Id, 0, 100, ""); err != nil {
@@ -2133,11 +2093,6 @@ func TestGetProfilesNotInChannel(t *testing.T) {
Client := th.BasicClient
- prevShowEmail := th.App.Config().PrivacySettings.ShowEmailAddress
- defer func() {
- th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = prevShowEmail })
- }()
-
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = true })
if result, err := Client.GetProfilesNotInChannel(th.BasicChannel.Id, 0, 100, ""); err != nil {
@@ -2359,12 +2314,6 @@ func TestSearchUsers(t *testing.T) {
}
}
- 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 })
@@ -2653,10 +2602,6 @@ func TestAutocompleteUsers(t *testing.T) {
}
}
- 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 })
privacyUser := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1", FirstName: model.NewId(), LastName: "Jimmers"}
@@ -2712,13 +2657,6 @@ func TestGetByUsername(t *testing.T) {
}
}
- 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 })
@@ -2749,13 +2687,6 @@ func TestGetByEmail(t *testing.T) {
t.Fatal("Failed to get user by email")
}
- 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 })
diff --git a/api/webhook_test.go b/api/webhook_test.go
index 6aa857af8..285650b5c 100644
--- a/api/webhook_test.go
+++ b/api/webhook_test.go
@@ -25,13 +25,6 @@ func TestCreateIncomingHook(t *testing.T) {
user2 := th.CreateUser(Client)
th.LinkUserToTeam(user2, team)
- 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()
@@ -139,14 +132,6 @@ func TestUpdateIncomingHook(t *testing.T) {
th.LinkUserToTeam(user3, team2)
th.UpdateUserToTeamAdmin(user3, team2)
- 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()
@@ -338,13 +323,6 @@ func TestListIncomingHooks(t *testing.T) {
user2 := th.CreateUser(Client)
th.LinkUserToTeam(user2, team)
- 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()
@@ -397,13 +375,6 @@ func TestDeleteIncomingHook(t *testing.T) {
user2 := th.CreateUser(Client)
th.LinkUserToTeam(user2, team)
- 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()
@@ -475,13 +446,6 @@ func TestCreateOutgoingHook(t *testing.T) {
user3 := th.CreateUser(Client)
th.LinkUserToTeam(user3, team2)
- 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()
@@ -586,13 +550,6 @@ func TestListOutgoingHooks(t *testing.T) {
user2 := th.CreateUser(Client)
th.LinkUserToTeam(user2, team)
- 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()
@@ -651,14 +608,6 @@ func TestUpdateOutgoingHook(t *testing.T) {
user3 := th.CreateUser(Client)
th.LinkUserToTeam(user3, team2)
- 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()
@@ -829,13 +778,6 @@ func TestDeleteOutgoingHook(t *testing.T) {
user2 := th.CreateUser(Client)
th.LinkUserToTeam(user2, team)
- 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()
@@ -905,13 +847,6 @@ func TestRegenOutgoingHookToken(t *testing.T) {
user3 := th.CreateUser(Client)
th.LinkUserToTeam(user3, team2)
- 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()