summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/admin_test.go5
-rw-r--r--api/api_test.go7
-rw-r--r--api/apitestlib.go14
-rw-r--r--api/file_test.go6
-rw-r--r--api/user.go4
-rw-r--r--api/user_test.go2
6 files changed, 14 insertions, 24 deletions
diff --git a/api/admin_test.go b/api/admin_test.go
index a9d59000d..d916e8c4b 100644
--- a/api/admin_test.go
+++ b/api/admin_test.go
@@ -10,7 +10,6 @@ import (
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/store"
- "github.com/mattermost/mattermost-server/utils"
)
func TestGetLogs(t *testing.T) {
@@ -139,13 +138,13 @@ func TestSaveConfig(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
defer th.TearDown()
- if _, err := th.BasicClient.SaveConfig(utils.Cfg); err == nil {
+ if _, err := th.BasicClient.SaveConfig(th.App.Config()); err == nil {
t.Fatal("Shouldn't have permissions")
}
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableOpenServer = false })
- if _, err := th.SystemAdminClient.SaveConfig(utils.Cfg); err != nil {
+ if _, err := th.SystemAdminClient.SaveConfig(th.App.Config()); err != nil {
t.Fatal(err)
}
diff --git a/api/api_test.go b/api/api_test.go
index 3d4f5f156..d447fc9bd 100644
--- a/api/api_test.go
+++ b/api/api_test.go
@@ -16,20 +16,15 @@ import (
func TestMain(m *testing.M) {
flag.Parse()
+ utils.TranslationsPreInit()
// In the case where a dev just wants to run a single test, it's faster to just use the default
// store.
if filter := flag.Lookup("test.run").Value.String(); filter != "" && filter != "." {
- utils.TranslationsPreInit()
- utils.LoadConfig("config.json")
l4g.Info("-test.run used, not creating temporary containers")
os.Exit(m.Run())
}
- utils.TranslationsPreInit()
- utils.LoadConfig("config.json")
- utils.InitTranslations(utils.Cfg.LocalizationSettings)
-
status := 0
container, settings, err := storetest.NewMySQLContainer()
diff --git a/api/apitestlib.go b/api/apitestlib.go
index 266ca95fc..0548f7843 100644
--- a/api/apitestlib.go
+++ b/api/apitestlib.go
@@ -64,12 +64,6 @@ func StopTestStore() {
}
func setupTestHelper(enterprise bool) *TestHelper {
- if utils.T == nil {
- utils.TranslationsPreInit()
- }
- utils.LoadConfig("config.json")
- utils.InitTranslations(utils.Cfg.LocalizationSettings)
-
var options []app.Option
if testStore != nil {
options = append(options, app.StoreOverride(testStore))
@@ -80,9 +74,11 @@ func setupTestHelper(enterprise bool) *TestHelper {
}
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 })
- th.App.UpdateConfig(func(cfg *model.Config) { cfg.EmailSettings.SendEmailNotifications = true })
+ th.App.UpdateConfig(func(cfg *model.Config) {
+ *cfg.TeamSettings.MaxUsersPerTeam = 50
+ *cfg.RateLimitSettings.Enable = false
+ cfg.EmailSettings.SendEmailNotifications = true
+ })
utils.DisableDebugLogForTest()
prevListenAddress := *th.App.Config().ServiceSettings.ListenAddress
if testStore != nil {
diff --git a/api/file_test.go b/api/file_test.go
index cdf06c04d..8b04c732c 100644
--- a/api/file_test.go
+++ b/api/file_test.go
@@ -517,7 +517,7 @@ func TestGetPublicFileOld(t *testing.T) {
// reconstruct old style of link
siteURL := fmt.Sprintf("http://localhost:%v", th.App.Srv.ListenAddr.Port)
- link := generatePublicLinkOld(siteURL, th.BasicTeam.Id, channel.Id, th.BasicUser.Id, fileId+"/test.png")
+ link := generatePublicLinkOld(siteURL, th.BasicTeam.Id, channel.Id, th.BasicUser.Id, fileId+"/test.png", *th.App.Config().FileSettings.PublicLinkSalt)
// Wait a bit for files to ready
time.Sleep(2 * time.Second)
@@ -553,8 +553,8 @@ func TestGetPublicFileOld(t *testing.T) {
}
}
-func generatePublicLinkOld(siteURL, teamId, channelId, userId, filename string) string {
- hash := app.GeneratePublicLinkHash(filename, *utils.Cfg.FileSettings.PublicLinkSalt)
+func generatePublicLinkOld(siteURL, teamId, channelId, userId, filename, salt string) string {
+ hash := app.GeneratePublicLinkHash(filename, salt)
return fmt.Sprintf("%s%s/public/files/get/%s/%s/%s/%s?h=%s", siteURL, model.API_URL_SUFFIX_V3, teamId, channelId, userId, filename, hash)
}
diff --git a/api/user.go b/api/user.go
index 1060d1bda..e1fa63bfa 100644
--- a/api/user.go
+++ b/api/user.go
@@ -326,7 +326,7 @@ func getUser(c *Context, w http.ResponseWriter, r *http.Request) {
if c.HandleEtag(etag, "Get User", w, r) {
return
} else {
- app.SanitizeProfile(user, c.IsSystemAdmin())
+ c.App.SanitizeProfile(user, c.IsSystemAdmin())
w.Header().Set(model.HEADER_ETAG_SERVER, etag)
w.Write([]byte(user.ToJson()))
return
@@ -560,7 +560,7 @@ func getProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
}
var img []byte
- img, readFailed, err = app.GetProfileImage(user)
+ img, readFailed, err = c.App.GetProfileImage(user)
if err != nil {
c.Err = err
return
diff --git a/api/user_test.go b/api/user_test.go
index a0ffe9fd9..05b6a844f 100644
--- a/api/user_test.go
+++ b/api/user_test.go
@@ -643,7 +643,7 @@ func TestUserCreateImage(t *testing.T) {
Client := th.BasicClient
- b, err := app.CreateProfileImage("Corey Hulen", "eo1zkdr96pdj98pjmq8zy35wba")
+ b, err := app.CreateProfileImage("Corey Hulen", "eo1zkdr96pdj98pjmq8zy35wba", th.App.Config().FileSettings.InitialFont)
if err != nil {
t.Fatal(err)
}