Commit 651dd33b authored by Saturnino Abril's avatar Saturnino Abril Committed by Joram Wilander

set to default value with config is missing (#7320)

parent 4c1f4674
...@@ -91,7 +91,7 @@ func TestGetConfig(t *testing.T) { ...@@ -91,7 +91,7 @@ func TestGetConfig(t *testing.T) {
if cfg.GitLabSettings.Secret != model.FAKE_SETTING && len(cfg.GitLabSettings.Secret) != 0 { if cfg.GitLabSettings.Secret != model.FAKE_SETTING && len(cfg.GitLabSettings.Secret) != 0 {
t.Fatal("did not sanitize properly") t.Fatal("did not sanitize properly")
} }
if cfg.SqlSettings.DataSource != model.FAKE_SETTING { if *cfg.SqlSettings.DataSource != model.FAKE_SETTING {
t.Fatal("did not sanitize properly") t.Fatal("did not sanitize properly")
} }
if cfg.SqlSettings.AtRestEncryptKey != model.FAKE_SETTING { if cfg.SqlSettings.AtRestEncryptKey != model.FAKE_SETTING {
...@@ -114,7 +114,7 @@ func TestReloadConfig(t *testing.T) { ...@@ -114,7 +114,7 @@ func TestReloadConfig(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50 *utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.TeamSettings.EnableOpenServer = true *utils.Cfg.TeamSettings.EnableOpenServer = true
} }
......
...@@ -36,7 +36,7 @@ func SetupEnterprise() *TestHelper { ...@@ -36,7 +36,7 @@ func SetupEnterprise() *TestHelper {
utils.TranslationsPreInit() utils.TranslationsPreInit()
utils.LoadConfig("config.json") utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings) utils.InitTranslations(utils.Cfg.LocalizationSettings)
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50 *utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.RateLimitSettings.Enable = false *utils.Cfg.RateLimitSettings.Enable = false
utils.DisableDebugLogForTest() utils.DisableDebugLogForTest()
utils.License().Features.SetDefaults() utils.License().Features.SetDefaults()
...@@ -63,7 +63,7 @@ func Setup() *TestHelper { ...@@ -63,7 +63,7 @@ func Setup() *TestHelper {
utils.TranslationsPreInit() utils.TranslationsPreInit()
utils.LoadConfig("config.json") utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings) utils.InitTranslations(utils.Cfg.LocalizationSettings)
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50 *utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.RateLimitSettings.Enable = false *utils.Cfg.RateLimitSettings.Enable = false
utils.Cfg.EmailSettings.SendEmailNotifications = true utils.Cfg.EmailSettings.SendEmailNotifications = true
utils.Cfg.EmailSettings.SMTPServer = "dockerhost" utils.Cfg.EmailSettings.SMTPServer = "dockerhost"
...@@ -90,7 +90,7 @@ func Setup() *TestHelper { ...@@ -90,7 +90,7 @@ func Setup() *TestHelper {
func ReloadConfigForSetup() { func ReloadConfigForSetup() {
utils.LoadConfig("config.json") utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings) utils.InitTranslations(utils.Cfg.LocalizationSettings)
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50 *utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.RateLimitSettings.Enable = false *utils.Cfg.RateLimitSettings.Enable = false
utils.Cfg.EmailSettings.SendEmailNotifications = true utils.Cfg.EmailSettings.SendEmailNotifications = true
utils.Cfg.EmailSettings.SMTPServer = "dockerhost" utils.Cfg.EmailSettings.SMTPServer = "dockerhost"
...@@ -133,11 +133,11 @@ func (me *TestHelper) InitSystemAdmin() *TestHelper { ...@@ -133,11 +133,11 @@ func (me *TestHelper) InitSystemAdmin() *TestHelper {
} }
func (me *TestHelper) CreateClient() *model.Client { func (me *TestHelper) CreateClient() *model.Client {
return model.NewClient("http://localhost" + utils.Cfg.ServiceSettings.ListenAddress) return model.NewClient("http://localhost" + *utils.Cfg.ServiceSettings.ListenAddress)
} }
func (me *TestHelper) CreateWebSocketClient() (*model.WebSocketClient, *model.AppError) { func (me *TestHelper) CreateWebSocketClient() (*model.WebSocketClient, *model.AppError) {
return model.NewWebSocketClient("ws://localhost"+utils.Cfg.ServiceSettings.ListenAddress, me.BasicClient.AuthToken) return model.NewWebSocketClient("ws://localhost"+*utils.Cfg.ServiceSettings.ListenAddress, me.BasicClient.AuthToken)
} }
func (me *TestHelper) CreateTeam(client *model.Client) *model.Team { func (me *TestHelper) CreateTeam(client *model.Client) *model.Team {
......
...@@ -242,7 +242,7 @@ func TestTestCommand(t *testing.T) { ...@@ -242,7 +242,7 @@ func TestTestCommand(t *testing.T) {
*utils.Cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost" *utils.Cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost"
cmd1 := &model.Command{ cmd1 := &model.Command{
URL: "http://localhost" + utils.Cfg.ServiceSettings.ListenAddress + model.API_URL_SUFFIX_V3 + "/teams/command_test", URL: "http://localhost" + *utils.Cfg.ServiceSettings.ListenAddress + model.API_URL_SUFFIX_V3 + "/teams/command_test",
Method: model.COMMAND_METHOD_POST, Method: model.COMMAND_METHOD_POST,
Trigger: "testcommand", Trigger: "testcommand",
} }
...@@ -262,7 +262,7 @@ func TestTestCommand(t *testing.T) { ...@@ -262,7 +262,7 @@ func TestTestCommand(t *testing.T) {
} }
cmd2 := &model.Command{ cmd2 := &model.Command{
URL: "http://localhost" + utils.Cfg.ServiceSettings.ListenAddress + model.API_URL_SUFFIX_V3 + "/teams/command_test", URL: "http://localhost" + *utils.Cfg.ServiceSettings.ListenAddress + model.API_URL_SUFFIX_V3 + "/teams/command_test",
Method: model.COMMAND_METHOD_GET, Method: model.COMMAND_METHOD_GET,
Trigger: "test2", Trigger: "test2",
} }
......
...@@ -59,7 +59,7 @@ func createEmoji(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -59,7 +59,7 @@ func createEmoji(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
if len(utils.Cfg.FileSettings.DriverName) == 0 { if len(*utils.Cfg.FileSettings.DriverName) == 0 {
c.Err = model.NewLocAppError("createEmoji", "api.emoji.storage.app_error", nil, "") c.Err = model.NewLocAppError("createEmoji", "api.emoji.storage.app_error", nil, "")
c.Err.StatusCode = http.StatusNotImplemented c.Err.StatusCode = http.StatusNotImplemented
return return
...@@ -137,7 +137,7 @@ func deleteEmoji(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -137,7 +137,7 @@ func deleteEmoji(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
if len(utils.Cfg.FileSettings.DriverName) == 0 { if len(*utils.Cfg.FileSettings.DriverName) == 0 {
c.Err = model.NewLocAppError("deleteImage", "api.emoji.storage.app_error", nil, "") c.Err = model.NewLocAppError("deleteImage", "api.emoji.storage.app_error", nil, "")
c.Err.StatusCode = http.StatusNotImplemented c.Err.StatusCode = http.StatusNotImplemented
return return
...@@ -179,7 +179,7 @@ func getEmojiImage(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -179,7 +179,7 @@ func getEmojiImage(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
if len(utils.Cfg.FileSettings.DriverName) == 0 { if len(*utils.Cfg.FileSettings.DriverName) == 0 {
c.Err = model.NewLocAppError("getEmojiImage", "api.emoji.storage.app_error", nil, "") c.Err = model.NewLocAppError("getEmojiImage", "api.emoji.storage.app_error", nil, "")
c.Err.StatusCode = http.StatusNotImplemented c.Err.StatusCode = http.StatusNotImplemented
return return
......
...@@ -200,7 +200,7 @@ func getPublicFile(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -200,7 +200,7 @@ func getPublicFile(c *Context, w http.ResponseWriter, r *http.Request) {
} }
func getFileInfoForRequest(c *Context, r *http.Request, requireFileVisible bool) (*model.FileInfo, *model.AppError) { func getFileInfoForRequest(c *Context, r *http.Request, requireFileVisible bool) (*model.FileInfo, *model.AppError) {
if len(utils.Cfg.FileSettings.DriverName) == 0 { if len(*utils.Cfg.FileSettings.DriverName) == 0 {
return nil, model.NewAppError("getFileInfoForRequest", "api.file.get_info_for_request.storage.app_error", nil, "", http.StatusNotImplemented) return nil, model.NewAppError("getFileInfoForRequest", "api.file.get_info_for_request.storage.app_error", nil, "", http.StatusNotImplemented)
} }
...@@ -236,7 +236,7 @@ func getFileInfoForRequest(c *Context, r *http.Request, requireFileVisible bool) ...@@ -236,7 +236,7 @@ func getFileInfoForRequest(c *Context, r *http.Request, requireFileVisible bool)
} }
func getPublicFileOld(c *Context, w http.ResponseWriter, r *http.Request) { func getPublicFileOld(c *Context, w http.ResponseWriter, r *http.Request) {
if len(utils.Cfg.FileSettings.DriverName) == 0 { if len(*utils.Cfg.FileSettings.DriverName) == 0 {
c.Err = model.NewLocAppError("getPublicFile", "api.file.get_public_file_old.storage.app_error", nil, "") c.Err = model.NewLocAppError("getPublicFile", "api.file.get_public_file_old.storage.app_error", nil, "")
c.Err.StatusCode = http.StatusNotImplemented c.Err.StatusCode = http.StatusNotImplemented
return return
......
...@@ -26,7 +26,7 @@ import ( ...@@ -26,7 +26,7 @@ import (
func TestUploadFile(t *testing.T) { func TestUploadFile(t *testing.T) {
th := Setup().InitBasic() th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" { if *utils.Cfg.FileSettings.DriverName == "" {
t.Logf("skipping because no file driver is enabled") t.Logf("skipping because no file driver is enabled")
return return
} }
...@@ -125,7 +125,7 @@ func TestUploadFile(t *testing.T) { ...@@ -125,7 +125,7 @@ func TestUploadFile(t *testing.T) {
func TestGetFileInfo(t *testing.T) { func TestGetFileInfo(t *testing.T) {
th := Setup().InitBasic() th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" { if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled") t.Skip("skipping because no file driver is enabled")
} }
...@@ -194,7 +194,7 @@ func TestGetFileInfo(t *testing.T) { ...@@ -194,7 +194,7 @@ func TestGetFileInfo(t *testing.T) {
func TestGetFile(t *testing.T) { func TestGetFile(t *testing.T) {
th := Setup().InitBasic() th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" { if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled") t.Skip("skipping because no file driver is enabled")
} }
...@@ -276,7 +276,7 @@ func TestGetFile(t *testing.T) { ...@@ -276,7 +276,7 @@ func TestGetFile(t *testing.T) {
func TestGetFileThumbnail(t *testing.T) { func TestGetFileThumbnail(t *testing.T) {
th := Setup().InitBasic() th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" { if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled") t.Skip("skipping because no file driver is enabled")
} }
...@@ -332,7 +332,7 @@ func TestGetFileThumbnail(t *testing.T) { ...@@ -332,7 +332,7 @@ func TestGetFileThumbnail(t *testing.T) {
func TestGetFilePreview(t *testing.T) { func TestGetFilePreview(t *testing.T) {
th := Setup().InitBasic() th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" { if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled") t.Skip("skipping because no file driver is enabled")
} }
...@@ -388,7 +388,7 @@ func TestGetFilePreview(t *testing.T) { ...@@ -388,7 +388,7 @@ func TestGetFilePreview(t *testing.T) {
func TestGetPublicFile(t *testing.T) { func TestGetPublicFile(t *testing.T) {
th := Setup().InitBasic() th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" { if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled") t.Skip("skipping because no file driver is enabled")
} }
...@@ -455,7 +455,7 @@ func TestGetPublicFile(t *testing.T) { ...@@ -455,7 +455,7 @@ func TestGetPublicFile(t *testing.T) {
func TestGetPublicFileOld(t *testing.T) { func TestGetPublicFileOld(t *testing.T) {
th := Setup().InitBasic() th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" { if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled") t.Skip("skipping because no file driver is enabled")
} }
...@@ -493,7 +493,7 @@ func TestGetPublicFileOld(t *testing.T) { ...@@ -493,7 +493,7 @@ func TestGetPublicFileOld(t *testing.T) {
// reconstruct old style of link // reconstruct old style of link
siteURL := *utils.Cfg.ServiceSettings.SiteURL siteURL := *utils.Cfg.ServiceSettings.SiteURL
if siteURL == "" { if siteURL == "" {
siteURL = "http://localhost" + utils.Cfg.ServiceSettings.ListenAddress siteURL = "http://localhost" + *utils.Cfg.ServiceSettings.ListenAddress
} }
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")
...@@ -539,7 +539,7 @@ func generatePublicLinkOld(siteURL, teamId, channelId, userId, filename string) ...@@ -539,7 +539,7 @@ func generatePublicLinkOld(siteURL, teamId, channelId, userId, filename string)
func TestGetPublicLink(t *testing.T) { func TestGetPublicLink(t *testing.T) {
th := Setup().InitBasic() th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" { if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled") t.Skip("skipping because no file driver is enabled")
} }
...@@ -608,7 +608,7 @@ func TestGetPublicLink(t *testing.T) { ...@@ -608,7 +608,7 @@ func TestGetPublicLink(t *testing.T) {
func TestMigrateFilenamesToFileInfos(t *testing.T) { func TestMigrateFilenamesToFileInfos(t *testing.T) {
th := Setup().InitBasic() th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" { if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled") t.Skip("skipping because no file driver is enabled")
} }
...@@ -720,7 +720,7 @@ func uploadFileOld(t *testing.T, data []byte, dest string, filename string) { ...@@ -720,7 +720,7 @@ func uploadFileOld(t *testing.T, data []byte, dest string, filename string) {
func TestFindTeamIdForFilename(t *testing.T) { func TestFindTeamIdForFilename(t *testing.T) {
th := Setup().InitBasic() th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" { if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled") t.Skip("skipping because no file driver is enabled")
} }
...@@ -786,7 +786,7 @@ func TestFindTeamIdForFilename(t *testing.T) { ...@@ -786,7 +786,7 @@ func TestFindTeamIdForFilename(t *testing.T) {
func TestGetInfoForFilename(t *testing.T) { func TestGetInfoForFilename(t *testing.T) {
th := Setup().InitBasic() th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" { if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled") t.Skip("skipping because no file driver is enabled")
} }
...@@ -874,7 +874,7 @@ func s3New(endpoint, accessKey, secretKey string, secure bool, signV2 bool, regi ...@@ -874,7 +874,7 @@ func s3New(endpoint, accessKey, secretKey string, secure bool, signV2 bool, regi
} }
func cleanupTestFile(info *model.FileInfo) error { func cleanupTestFile(info *model.FileInfo) error {
if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 { if *utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 {
endpoint := utils.Cfg.FileSettings.AmazonS3Endpoint endpoint := utils.Cfg.FileSettings.AmazonS3Endpoint
accessKey := utils.Cfg.FileSettings.AmazonS3AccessKeyId accessKey := utils.Cfg.FileSettings.AmazonS3AccessKeyId
secretKey := utils.Cfg.FileSettings.AmazonS3SecretAccessKey secretKey := utils.Cfg.FileSettings.AmazonS3SecretAccessKey
...@@ -901,7 +901,7 @@ func cleanupTestFile(info *model.FileInfo) error { ...@@ -901,7 +901,7 @@ func cleanupTestFile(info *model.FileInfo) error {
return err return err
} }
} }
} else if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_LOCAL { } else if *utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_LOCAL {
if err := os.Remove(utils.Cfg.FileSettings.Directory + info.Path); err != nil { if err := os.Remove(utils.Cfg.FileSettings.Directory + info.Path); err != nil {
return err return err
} }
......
...@@ -580,7 +580,7 @@ func getProfileImage(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -580,7 +580,7 @@ func getProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
} }
func uploadProfileImage(c *Context, w http.ResponseWriter, r *http.Request) { func uploadProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
if len(utils.Cfg.FileSettings.DriverName) == 0 { if len(*utils.Cfg.FileSettings.DriverName) == 0 {
c.Err = model.NewLocAppError("uploadProfileImage", "api.user.upload_profile_user.storage.app_error", nil, "") c.Err = model.NewLocAppError("uploadProfileImage", "api.user.upload_profile_user.storage.app_error", nil, "")
c.Err.StatusCode = http.StatusNotImplemented c.Err.StatusCode = http.StatusNotImplemented
return return
......
...@@ -263,13 +263,13 @@ func TestPasswordGuessLockout(t *testing.T) { ...@@ -263,13 +263,13 @@ func TestPasswordGuessLockout(t *testing.T) {
Client.Must(Client.Logout()) Client.Must(Client.Logout())
enableSignInWithEmail := *utils.Cfg.EmailSettings.EnableSignInWithEmail enableSignInWithEmail := *utils.Cfg.EmailSettings.EnableSignInWithEmail
passwordAttempts := utils.Cfg.ServiceSettings.MaximumLoginAttempts passwordAttempts := *utils.Cfg.ServiceSettings.MaximumLoginAttempts
defer func() { defer func() {
*utils.Cfg.EmailSettings.EnableSignInWithEmail = enableSignInWithEmail *utils.Cfg.EmailSettings.EnableSignInWithEmail = enableSignInWithEmail
utils.Cfg.ServiceSettings.MaximumLoginAttempts = passwordAttempts *utils.Cfg.ServiceSettings.MaximumLoginAttempts = passwordAttempts
}() }()
*utils.Cfg.EmailSettings.EnableSignInWithEmail = true *utils.Cfg.EmailSettings.EnableSignInWithEmail = true
utils.Cfg.ServiceSettings.MaximumLoginAttempts = 2 *utils.Cfg.ServiceSettings.MaximumLoginAttempts = 2
// OK to log in // OK to log in
if _, err := Client.Login(user.Username, user.Password); err != nil { if _, err := Client.Login(user.Username, user.Password); err != nil {
...@@ -689,7 +689,7 @@ func TestUserCreateImage(t *testing.T) { ...@@ -689,7 +689,7 @@ func TestUserCreateImage(t *testing.T) {
} }
} }
if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 { if *utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 {
endpoint := utils.Cfg.FileSettings.AmazonS3Endpoint endpoint := utils.Cfg.FileSettings.AmazonS3Endpoint
accessKey := utils.Cfg.FileSettings.AmazonS3AccessKeyId accessKey := utils.Cfg.FileSettings.AmazonS3AccessKeyId
secretKey := utils.Cfg.FileSettings.AmazonS3SecretAccessKey secretKey := utils.Cfg.FileSettings.AmazonS3SecretAccessKey
...@@ -726,7 +726,7 @@ func TestUserUploadProfileImage(t *testing.T) { ...@@ -726,7 +726,7 @@ func TestUserUploadProfileImage(t *testing.T) {
LinkUserToTeam(user, team) LinkUserToTeam(user, team)
store.Must(app.Srv.Store.User().VerifyEmail(user.Id)) store.Must(app.Srv.Store.User().VerifyEmail(user.Id))
if utils.Cfg.FileSettings.DriverName != "" { if *utils.Cfg.FileSettings.DriverName != "" {
body := &bytes.Buffer{} body := &bytes.Buffer{}
writer := multipart.NewWriter(body) writer := multipart.NewWriter(body)
...@@ -795,7 +795,7 @@ func TestUserUploadProfileImage(t *testing.T) { ...@@ -795,7 +795,7 @@ func TestUserUploadProfileImage(t *testing.T) {
Client.DoApiGet("/users/"+user.Id+"/image", "", "") Client.DoApiGet("/users/"+user.Id+"/image", "", "")
if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 { if *utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 {
endpoint := utils.Cfg.FileSettings.AmazonS3Endpoint endpoint := utils.Cfg.FileSettings.AmazonS3Endpoint
accessKey := utils.Cfg.FileSettings.AmazonS3AccessKeyId accessKey := utils.Cfg.FileSettings.AmazonS3AccessKeyId
secretKey := utils.Cfg.FileSettings.AmazonS3SecretAccessKey secretKey := utils.Cfg.FileSettings.AmazonS3SecretAccessKey
...@@ -934,11 +934,11 @@ func TestUserUpdatePassword(t *testing.T) { ...@@ -934,11 +934,11 @@ func TestUserUpdatePassword(t *testing.T) {
} }
// Test lockout // Test lockout
passwordAttempts := utils.Cfg.ServiceSettings.MaximumLoginAttempts passwordAttempts := *utils.Cfg.ServiceSettings.MaximumLoginAttempts
defer func() { defer func() {
utils.Cfg.ServiceSettings.MaximumLoginAttempts = passwordAttempts *utils.Cfg.ServiceSettings.MaximumLoginAttempts = passwordAttempts
}() }()
utils.Cfg.ServiceSettings.MaximumLoginAttempts = 2 *utils.Cfg.ServiceSettings.MaximumLoginAttempts = 2
// Fail twice // Fail twice
if _, err := Client.UpdateUserPassword(user.Id, "badpwd", "newpwd"); err == nil { if _, err := Client.UpdateUserPassword(user.Id, "badpwd", "newpwd"); err == nil {
......
...@@ -317,7 +317,7 @@ func TestCreateDirectChannelWithSocket(t *testing.T) { ...@@ -317,7 +317,7 @@ func TestCreateDirectChannelWithSocket(t *testing.T) {
func TestWebsocketOriginSecurity(t *testing.T) { func TestWebsocketOriginSecurity(t *testing.T) {
Setup().InitBasic() Setup().InitBasic()
url := "ws://localhost" + utils.Cfg.ServiceSettings.ListenAddress url := "ws://localhost" + *utils.Cfg.ServiceSettings.ListenAddress
// Should fail because origin doesn't match // Should fail because origin doesn't match
_, _, err := websocket.DefaultDialer.Dial(url+model.API_URL_SUFFIX_V3+"/users/websocket", http.Header{ _, _, err := websocket.DefaultDialer.Dial(url+model.API_URL_SUFFIX_V3+"/users/websocket", http.Header{
...@@ -329,7 +329,7 @@ func TestWebsocketOriginSecurity(t *testing.T) { ...@@ -329,7 +329,7 @@ func TestWebsocketOriginSecurity(t *testing.T) {
// We are not a browser so we can spoof this just fine // We are not a browser so we can spoof this just fine
_, _, err = websocket.DefaultDialer.Dial(url+model.API_URL_SUFFIX_V3+"/users/websocket", http.Header{ _, _, err = websocket.DefaultDialer.Dial(url+model.API_URL_SUFFIX_V3+"/users/websocket", http.Header{
"Origin": []string{"http://localhost" + utils.Cfg.ServiceSettings.ListenAddress}, "Origin": []string{"http://localhost" + *utils.Cfg.ServiceSettings.ListenAddress},
}) })
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
......
...@@ -48,7 +48,7 @@ func SetupEnterprise() *TestHelper { ...@@ -48,7 +48,7 @@ func SetupEnterprise() *TestHelper {
utils.TranslationsPreInit() utils.TranslationsPreInit()
utils.LoadConfig("config.json") utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings) utils.InitTranslations(utils.Cfg.LocalizationSettings)
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50 *utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.RateLimitSettings.Enable = false *utils.Cfg.RateLimitSettings.Enable = false
utils.Cfg.EmailSettings.SendEmailNotifications = true utils.Cfg.EmailSettings.SendEmailNotifications = true
utils.Cfg.EmailSettings.SMTPServer = "dockerhost" utils.Cfg.EmailSettings.SMTPServer = "dockerhost"
...@@ -85,7 +85,7 @@ func Setup() *TestHelper { ...@@ -85,7 +85,7 @@ func Setup() *TestHelper {
utils.TranslationsPreInit() utils.TranslationsPreInit()
utils.LoadConfig("config.json") utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings) utils.InitTranslations(utils.Cfg.LocalizationSettings)
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50 *utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.RateLimitSettings.Enable = false *utils.Cfg.RateLimitSettings.Enable = false
utils.Cfg.EmailSettings.SendEmailNotifications = true utils.Cfg.EmailSettings.SendEmailNotifications = true
utils.Cfg.EmailSettings.SMTPServer = "dockerhost" utils.Cfg.EmailSettings.SMTPServer = "dockerhost"
...@@ -212,11 +212,11 @@ func (me *TestHelper) InitSystemAdmin() *TestHelper { ...@@ -212,11 +212,11 @@ func (me *TestHelper) InitSystemAdmin() *TestHelper {
} }
func (me *TestHelper) CreateClient() *model.Client4 { func (me *TestHelper) CreateClient() *model.Client4 {
return model.NewAPIv4Client("http://localhost" + utils.Cfg.ServiceSettings.ListenAddress) return model.NewAPIv4Client("http://localhost" + *utils.Cfg.ServiceSettings.ListenAddress)
} }
func (me *TestHelper) CreateWebSocketClient() (*model.WebSocketClient, *model.AppError) { func (me *TestHelper) CreateWebSocketClient() (*model.WebSocketClient, *model.AppError) {
return model.NewWebSocketClient4("ws://localhost"+utils.Cfg.ServiceSettings.ListenAddress, me.Client.AuthToken) return model.NewWebSocketClient4("ws://localhost"+*utils.Cfg.ServiceSettings.ListenAddress, me.Client.AuthToken)
} }
func (me *TestHelper) CreateUser() *model.User { func (me *TestHelper) CreateUser() *model.User {
...@@ -658,7 +658,7 @@ func s3New(endpoint, accessKey, secretKey string, secure bool, signV2 bool, regi ...@@ -658,7 +658,7 @@ func s3New(endpoint, accessKey, secretKey string, secure bool, signV2 bool, regi
} }
func cleanupTestFile(info *model.FileInfo) error { func cleanupTestFile(info *model.FileInfo) error {
if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 { if *utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 {
endpoint := utils.Cfg.FileSettings.AmazonS3Endpoint endpoint := utils.Cfg.FileSettings.AmazonS3Endpoint
accessKey := utils.Cfg.FileSettings.AmazonS3AccessKeyId accessKey := utils.Cfg.FileSettings.AmazonS3AccessKeyId
secretKey := utils.Cfg.FileSettings.AmazonS3SecretAccessKey secretKey := utils.Cfg.FileSettings.AmazonS3SecretAccessKey
...@@ -685,7 +685,7 @@ func cleanupTestFile(info *model.FileInfo) error { ...@@ -685,7 +685,7 @@ func cleanupTestFile(info *model.FileInfo) error {
return err return err
} }
} }
} else if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_LOCAL { } else if *utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_LOCAL {
if err := os.Remove(utils.Cfg.FileSettings.Directory + info.Path); err != nil { if err := os.Remove(utils.Cfg.FileSettings.Directory + info.Path); err != nil {
return err return err
} }
......
...@@ -399,7 +399,7 @@ func TestExecuteCommand(t *testing.T) { ...@@ -399,7 +399,7 @@ func TestExecuteCommand(t *testing.T) {
postCmd := &model.Command{ postCmd := &model.Command{
CreatorId: th.BasicUser.Id, CreatorId: th.BasicUser.Id,
TeamId: th.BasicTeam.Id, TeamId: th.BasicTeam.Id,
URL: "http://localhost" + utils.Cfg.ServiceSettings.ListenAddress + model.API_URL_SUFFIX_V4 + "/teams/command_test", URL: "http://localhost" + *utils.Cfg.ServiceSettings.ListenAddress + model.API_URL_SUFFIX_V4 + "/teams/command_test",
Method: model.COMMAND_METHOD_POST, Method: model.COMMAND_METHOD_POST,
Trigger: "postcommand", Trigger: "postcommand",
} }
...@@ -423,7 +423,7 @@ func TestExecuteCommand(t *testing.T) { ...@@ -423,7 +423,7 @@ func TestExecuteCommand(t *testing.T) {
getCmd := &model.Command{ getCmd := &model.Command{
CreatorId: th.BasicUser.Id, CreatorId: th.BasicUser.Id,
TeamId: th.BasicTeam.Id, TeamId: th.BasicTeam.Id,
URL: "http://localhost" + utils.Cfg.ServiceSettings.ListenAddress + model.API_URL_SUFFIX_V4 + "/teams/command_test", URL: "http://localhost" + *utils.Cfg.ServiceSettings.ListenAddress + model.API_URL_SUFFIX_V4 + "/teams/command_test",
Method: model.COMMAND_METHOD_GET, Method: model.COMMAND_METHOD_GET,
Trigger: "getcommand", Trigger: "getcommand",
} }
......
...@@ -37,7 +37,7 @@ func createEmoji(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -37,7 +37,7 @@ func createEmoji(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
if len(utils.Cfg.FileSettings.DriverName) == 0 { if len(*utils.Cfg.FileSettings.DriverName) == 0 {
c.Err = model.NewAppError("createEmoji", "api.emoji.storage.app_error", nil, "", http.StatusNotImplemented) c.Err = model.NewAppError("createEmoji", "api.emoji.storage.app_error", nil, "", http.StatusNotImplemented)
return return
} }
...@@ -147,7 +147,7 @@ func getEmojiImage(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -147,7 +147,7 @@ func getEmojiImage(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
if len(utils.Cfg.FileSettings.DriverName) == 0 { if len(*utils.Cfg.FileSettings.DriverName) == 0 {
c.Err = model.NewAppError("getEmojiImage", "api.emoji.storage.app_error", nil, "", http.StatusNotImplemented) c.Err = model.NewAppError("getEmojiImage", "api.emoji.storage.app_error", nil, "", http.StatusNotImplemented)
return return
} }
......
...@@ -313,10 +313,10 @@ func TestGetEmojiImage(t *testing.T) { ...@@ -313,10 +313,10 @@ func TestGetEmojiImage(t *testing.T) {
Client := th.Client Client := th.Client
EnableCustomEmoji := *utils.Cfg.ServiceSettings.EnableCustomEmoji EnableCustomEmoji := *utils.Cfg.ServiceSettings.EnableCustomEmoji
DriverName := utils.Cfg.FileSettings.DriverName DriverName := *utils.Cfg.FileSettings.DriverName
defer func() { defer func() {
*utils.Cfg.ServiceSettings.EnableCustomEmoji = EnableCustomEmoji *utils.Cfg.ServiceSettings.EnableCustomEmoji = EnableCustomEmoji
utils.Cfg.FileSettings.DriverName = DriverName *utils.Cfg.FileSettings.DriverName = DriverName
}() }()
*utils.Cfg.ServiceSettings.EnableCustomEmoji = true *utils.Cfg.ServiceSettings.EnableCustomEmoji = true
...@@ -334,14 +334,14 @@ func TestGetEmojiImage(t *testing.T) { ...@@ -334,14 +334,14 @@ func TestGetEmojiImage(t *testing.T) {
CheckNotImplementedStatus(t, resp) CheckNotImplementedStatus(t, resp)
CheckErrorMessage(t, resp, "api.emoji.disabled.app_error") CheckErrorMessage(t, resp, "api.emoji.disabled.app_error")
utils.Cfg.FileSettings.DriverName = "" *utils.Cfg.FileSettings.DriverName = ""
*utils.Cfg.ServiceSettings.EnableCustomEmoji = true *utils.Cfg.ServiceSettings.EnableCustomEmoji = true
_, resp = Client.GetEmojiImage(emoji1.Id) _, resp = Client.GetEmojiImage(emoji1.Id)