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) {
if cfg.GitLabSettings.Secret != model.FAKE_SETTING && len(cfg.GitLabSettings.Secret) != 0 {
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")
}
if cfg.SqlSettings.AtRestEncryptKey != model.FAKE_SETTING {
......@@ -114,7 +114,7 @@ func TestReloadConfig(t *testing.T) {
t.Fatal(err)
}
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.TeamSettings.EnableOpenServer = true
}
......
......@@ -36,7 +36,7 @@ func SetupEnterprise() *TestHelper {
utils.TranslationsPreInit()
utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings)
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.RateLimitSettings.Enable = false
utils.DisableDebugLogForTest()
utils.License().Features.SetDefaults()
......@@ -63,7 +63,7 @@ func Setup() *TestHelper {
utils.TranslationsPreInit()
utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings)
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.RateLimitSettings.Enable = false
utils.Cfg.EmailSettings.SendEmailNotifications = true
utils.Cfg.EmailSettings.SMTPServer = "dockerhost"
......@@ -90,7 +90,7 @@ func Setup() *TestHelper {
func ReloadConfigForSetup() {
utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings)
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.RateLimitSettings.Enable = false
utils.Cfg.EmailSettings.SendEmailNotifications = true
utils.Cfg.EmailSettings.SMTPServer = "dockerhost"
......@@ -133,11 +133,11 @@ func (me *TestHelper) InitSystemAdmin() *TestHelper {
}
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) {
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 {
......
......@@ -242,7 +242,7 @@ func TestTestCommand(t *testing.T) {
*utils.Cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost"
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,
Trigger: "testcommand",
}
......@@ -262,7 +262,7 @@ func TestTestCommand(t *testing.T) {
}
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,
Trigger: "test2",
}
......
......@@ -59,7 +59,7 @@ func createEmoji(c *Context, w http.ResponseWriter, r *http.Request) {
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.StatusCode = http.StatusNotImplemented
return
......@@ -137,7 +137,7 @@ func deleteEmoji(c *Context, w http.ResponseWriter, r *http.Request) {
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.StatusCode = http.StatusNotImplemented
return
......@@ -179,7 +179,7 @@ func getEmojiImage(c *Context, w http.ResponseWriter, r *http.Request) {
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.StatusCode = http.StatusNotImplemented
return
......
......@@ -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) {
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)
}
......@@ -236,7 +236,7 @@ func getFileInfoForRequest(c *Context, r *http.Request, requireFileVisible bool)
}
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.StatusCode = http.StatusNotImplemented
return
......
......@@ -26,7 +26,7 @@ import (
func TestUploadFile(t *testing.T) {
th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" {
if *utils.Cfg.FileSettings.DriverName == "" {
t.Logf("skipping because no file driver is enabled")
return
}
......@@ -125,7 +125,7 @@ func TestUploadFile(t *testing.T) {
func TestGetFileInfo(t *testing.T) {
th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" {
if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled")
}
......@@ -194,7 +194,7 @@ func TestGetFileInfo(t *testing.T) {
func TestGetFile(t *testing.T) {
th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" {
if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled")
}
......@@ -276,7 +276,7 @@ func TestGetFile(t *testing.T) {
func TestGetFileThumbnail(t *testing.T) {
th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" {
if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled")
}
......@@ -332,7 +332,7 @@ func TestGetFileThumbnail(t *testing.T) {
func TestGetFilePreview(t *testing.T) {
th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" {
if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled")
}
......@@ -388,7 +388,7 @@ func TestGetFilePreview(t *testing.T) {
func TestGetPublicFile(t *testing.T) {
th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" {
if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled")
}
......@@ -455,7 +455,7 @@ func TestGetPublicFile(t *testing.T) {
func TestGetPublicFileOld(t *testing.T) {
th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" {
if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled")
}
......@@ -493,7 +493,7 @@ func TestGetPublicFileOld(t *testing.T) {
// reconstruct old style of link
siteURL := *utils.Cfg.ServiceSettings.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")
......@@ -539,7 +539,7 @@ func generatePublicLinkOld(siteURL, teamId, channelId, userId, filename string)
func TestGetPublicLink(t *testing.T) {
th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" {
if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled")
}
......@@ -608,7 +608,7 @@ func TestGetPublicLink(t *testing.T) {
func TestMigrateFilenamesToFileInfos(t *testing.T) {
th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" {
if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled")
}
......@@ -720,7 +720,7 @@ func uploadFileOld(t *testing.T, data []byte, dest string, filename string) {
func TestFindTeamIdForFilename(t *testing.T) {
th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" {
if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled")
}
......@@ -786,7 +786,7 @@ func TestFindTeamIdForFilename(t *testing.T) {
func TestGetInfoForFilename(t *testing.T) {
th := Setup().InitBasic()
if utils.Cfg.FileSettings.DriverName == "" {
if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled")
}
......@@ -874,7 +874,7 @@ func s3New(endpoint, accessKey, secretKey string, secure bool, signV2 bool, regi
}
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
accessKey := utils.Cfg.FileSettings.AmazonS3AccessKeyId
secretKey := utils.Cfg.FileSettings.AmazonS3SecretAccessKey
......@@ -901,7 +901,7 @@ func cleanupTestFile(info *model.FileInfo) error {
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 {
return err
}
......
......@@ -580,7 +580,7 @@ func getProfileImage(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.StatusCode = http.StatusNotImplemented
return
......
......@@ -263,13 +263,13 @@ func TestPasswordGuessLockout(t *testing.T) {
Client.Must(Client.Logout())
enableSignInWithEmail := *utils.Cfg.EmailSettings.EnableSignInWithEmail
passwordAttempts := utils.Cfg.ServiceSettings.MaximumLoginAttempts
passwordAttempts := *utils.Cfg.ServiceSettings.MaximumLoginAttempts
defer func() {
*utils.Cfg.EmailSettings.EnableSignInWithEmail = enableSignInWithEmail
utils.Cfg.ServiceSettings.MaximumLoginAttempts = passwordAttempts
*utils.Cfg.ServiceSettings.MaximumLoginAttempts = passwordAttempts
}()
*utils.Cfg.EmailSettings.EnableSignInWithEmail = true
utils.Cfg.ServiceSettings.MaximumLoginAttempts = 2
*utils.Cfg.ServiceSettings.MaximumLoginAttempts = 2
// OK to log in
if _, err := Client.Login(user.Username, user.Password); err != nil {
......@@ -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
accessKey := utils.Cfg.FileSettings.AmazonS3AccessKeyId
secretKey := utils.Cfg.FileSettings.AmazonS3SecretAccessKey
......@@ -726,7 +726,7 @@ func TestUserUploadProfileImage(t *testing.T) {
LinkUserToTeam(user, team)
store.Must(app.Srv.Store.User().VerifyEmail(user.Id))
if utils.Cfg.FileSettings.DriverName != "" {
if *utils.Cfg.FileSettings.DriverName != "" {
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
......@@ -795,7 +795,7 @@ func TestUserUploadProfileImage(t *testing.T) {
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
accessKey := utils.Cfg.FileSettings.AmazonS3AccessKeyId
secretKey := utils.Cfg.FileSettings.AmazonS3SecretAccessKey
......@@ -934,11 +934,11 @@ func TestUserUpdatePassword(t *testing.T) {
}
// Test lockout
passwordAttempts := utils.Cfg.ServiceSettings.MaximumLoginAttempts
passwordAttempts := *utils.Cfg.ServiceSettings.MaximumLoginAttempts
defer func() {
utils.Cfg.ServiceSettings.MaximumLoginAttempts = passwordAttempts
*utils.Cfg.ServiceSettings.MaximumLoginAttempts = passwordAttempts
}()
utils.Cfg.ServiceSettings.MaximumLoginAttempts = 2
*utils.Cfg.ServiceSettings.MaximumLoginAttempts = 2
// Fail twice
if _, err := Client.UpdateUserPassword(user.Id, "badpwd", "newpwd"); err == nil {
......
......@@ -317,7 +317,7 @@ func TestCreateDirectChannelWithSocket(t *testing.T) {
func TestWebsocketOriginSecurity(t *testing.T) {
Setup().InitBasic()
url := "ws://localhost" + utils.Cfg.ServiceSettings.ListenAddress
url := "ws://localhost" + *utils.Cfg.ServiceSettings.ListenAddress
// Should fail because origin doesn't match
_, _, err := websocket.DefaultDialer.Dial(url+model.API_URL_SUFFIX_V3+"/users/websocket", http.Header{
......@@ -329,7 +329,7 @@ func TestWebsocketOriginSecurity(t *testing.T) {
// 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{
"Origin": []string{"http://localhost" + utils.Cfg.ServiceSettings.ListenAddress},
"Origin": []string{"http://localhost" + *utils.Cfg.ServiceSettings.ListenAddress},
})
if err != nil {
t.Fatal(err)
......
......@@ -48,7 +48,7 @@ func SetupEnterprise() *TestHelper {
utils.TranslationsPreInit()
utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings)
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.RateLimitSettings.Enable = false
utils.Cfg.EmailSettings.SendEmailNotifications = true
utils.Cfg.EmailSettings.SMTPServer = "dockerhost"
......@@ -85,7 +85,7 @@ func Setup() *TestHelper {
utils.TranslationsPreInit()
utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings)
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.RateLimitSettings.Enable = false
utils.Cfg.EmailSettings.SendEmailNotifications = true
utils.Cfg.EmailSettings.SMTPServer = "dockerhost"
......@@ -212,11 +212,11 @@ func (me *TestHelper) InitSystemAdmin() *TestHelper {
}
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) {
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 {
......@@ -658,7 +658,7 @@ func s3New(endpoint, accessKey, secretKey string, secure bool, signV2 bool, regi
}
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
accessKey := utils.Cfg.FileSettings.AmazonS3AccessKeyId
secretKey := utils.Cfg.FileSettings.AmazonS3SecretAccessKey
......@@ -685,7 +685,7 @@ func cleanupTestFile(info *model.FileInfo) error {
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 {
return err
}
......
......@@ -399,7 +399,7 @@ func TestExecuteCommand(t *testing.T) {
postCmd := &model.Command{
CreatorId: th.BasicUser.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,
Trigger: "postcommand",
}
......@@ -423,7 +423,7 @@ func TestExecuteCommand(t *testing.T) {
getCmd := &model.Command{
CreatorId: th.BasicUser.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,
Trigger: "getcommand",
}
......
......@@ -37,7 +37,7 @@ func createEmoji(c *Context, w http.ResponseWriter, r *http.Request) {
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)
return
}
......@@ -147,7 +147,7 @@ func getEmojiImage(c *Context, w http.ResponseWriter, r *http.Request) {
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)
return
}
......
......@@ -313,10 +313,10 @@ func TestGetEmojiImage(t *testing.T) {
Client := th.Client
EnableCustomEmoji := *utils.Cfg.ServiceSettings.EnableCustomEmoji
DriverName := utils.Cfg.FileSettings.DriverName
DriverName := *utils.Cfg.FileSettings.DriverName
defer func() {
*utils.Cfg.ServiceSettings.EnableCustomEmoji = EnableCustomEmoji
utils.Cfg.FileSettings.DriverName = DriverName
*utils.Cfg.FileSettings.DriverName = DriverName
}()
*utils.Cfg.ServiceSettings.EnableCustomEmoji = true
......@@ -334,14 +334,14 @@ func TestGetEmojiImage(t *testing.T) {
CheckNotImplementedStatus(t, resp)
CheckErrorMessage(t, resp, "api.emoji.disabled.app_error")
utils.Cfg.FileSettings.DriverName = ""
*utils.Cfg.FileSettings.DriverName = ""
*utils.Cfg.ServiceSettings.EnableCustomEmoji = true
_, resp = Client.GetEmojiImage(emoji1.Id)
CheckNotImplementedStatus(t, resp)
CheckErrorMessage(t, resp, "api.emoji.storage.app_error")
utils.Cfg.FileSettings.DriverName = DriverName
*utils.Cfg.FileSettings.DriverName = DriverName
emojiImage, resp := Client.GetEmojiImage(emoji1.Id)
CheckNoError(t, resp)
......
......@@ -124,7 +124,7 @@ func TestGetFile(t *testing.T) {
Client := th.Client
channel := th.BasicChannel
if utils.Cfg.FileSettings.DriverName == "" {
if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled")
}
......@@ -174,7 +174,7 @@ func TestGetFileHeaders(t *testing.T) {
Client := th.Client
channel := th.BasicChannel
if utils.Cfg.FileSettings.DriverName == "" {
if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled")
}
......@@ -238,7 +238,7 @@ func TestGetFileThumbnail(t *testing.T) {
Client := th.Client
channel := th.BasicChannel
if utils.Cfg.FileSettings.DriverName == "" {
if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled")
}
......@@ -290,7 +290,7 @@ func TestGetFileLink(t *testing.T) {
Client := th.Client
channel := th.BasicChannel
if utils.Cfg.FileSettings.DriverName == "" {
if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled")
}
......@@ -365,7 +365,7 @@ func TestGetFilePreview(t *testing.T) {
Client := th.Client
channel := th.BasicChannel
if utils.Cfg.FileSettings.DriverName == "" {
if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled")
}
......@@ -418,7 +418,7 @@ func TestGetFileInfo(t *testing.T) {
user := th.BasicUser
channel := th.BasicChannel
if utils.Cfg.FileSettings.DriverName == "" {
if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled")
}
......@@ -484,7 +484,7 @@ func TestGetPublicFile(t *testing.T) {
Client := th.Client
channel := th.BasicChannel
if utils.Cfg.FileSettings.DriverName == "" {
if *utils.Cfg.FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled")
}
......
......@@ -68,7 +68,7 @@ func TestGetConfig(t *testing.T) {
if cfg.GitLabSettings.Secret != model.FAKE_SETTING && len(cfg.GitLabSettings.Secret) != 0 {
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")
}
if cfg.SqlSettings.AtRestEncryptKey != model.FAKE_SETTING {
......@@ -99,7 +99,7 @@ func TestReloadConfig(t *testing.T) {
t.Fatal("should Reload the config")
}
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.TeamSettings.EnableOpenServer = true
}
......
......@@ -233,7 +233,7 @@ func setProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
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.StatusCode = http.StatusNotImplemented
return
......
......@@ -1672,11 +1672,11 @@ func TestUpdateUserPassword(t *testing.T) {
th.LoginBasic()
// Test lockout
passwordAttempts := utils.Cfg.ServiceSettings.MaximumLoginAttempts
passwordAttempts := *utils.Cfg.ServiceSettings.MaximumLoginAttempts
defer func() {
utils.Cfg.ServiceSettings.MaximumLoginAttempts = passwordAttempts
*utils.Cfg.ServiceSettings.MaximumLoginAttempts = passwordAttempts
}()
utils.Cfg.ServiceSettings.MaximumLoginAttempts = 2
*utils.Cfg.ServiceSettings.MaximumLoginAttempts = 2
// Fail twice
_, resp = Client.UpdateUserPassword(th.BasicUser.Id, "badpwd", "newpwd")
......
......@@ -25,7 +25,7 @@ func SetupEnterprise() *TestHelper {
utils.TranslationsPreInit()
utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings)
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.RateLimitSettings.Enable = false
utils.DisableDebugLogForTest()
utils.License().Features.SetDefaults()
......@@ -47,7 +47,7 @@ func Setup() *TestHelper {
utils.TranslationsPreInit()
utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings)
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.RateLimitSettings.Enable = false
utils.DisableDebugLogForTest()
NewServer()
......
......@@ -121,7 +121,7 @@ func CheckUserMfa(user *model.User, token string) *model.AppError {
}
func checkUserLoginAttempts(user *model.User) *model.AppError {
if user.FailedAttempts >= utils.Cfg.ServiceSettings.MaximumLoginAttempts {
if user.FailedAttempts >= *utils.Cfg.ServiceSettings.MaximumLoginAttempts {
return model.NewAppError("checkUserLoginAttempts", "api.user.check_user_login_attempts.too_many.app_error", nil, "user_id="+user.Id, http.StatusUnauthorized)
}
......
......@@ -13,7 +13,7 @@ import (
)
func SaveBrandImage(imageData *multipart.FileHeader) *model.AppError {
if len(utils.Cfg.FileSettings.DriverName) == 0 {
if len(*utils.Cfg.FileSettings.DriverName) == 0 {
return model.NewAppError("SaveBrandImage", "api.admin.upload_brand_image.storage.app_error", nil, "", http.StatusNotImplemented)
}
......@@ -30,7 +30,7 @@ func SaveBrandImage(imageData *multipart.FileHeader) *model.AppError {
}
func GetBrandImage() ([]byte, *model.AppError) {
if len(utils.Cfg.FileSettings.DriverName) == 0 {
if len(*utils.Cfg.FileSettings.DriverName) == 0 {
return nil, model.NewAppError("GetBrandImage", "api.admin.get_brand_image.storage.app_error", nil, "", http.StatusNotImplemented)
}
......
......@@ -197,7 +197,7 @@ func trackConfig() {
"connection_security": *utils.Cfg.ServiceSettings.ConnectionSecurity,
"uses_letsencrypt": *utils.Cfg.ServiceSettings.UseLetsEncrypt,
"forward_80_to_443": *utils.Cfg.ServiceSettings.Forward80To443,
"maximum_login_attempts": utils.Cfg.ServiceSettings.MaximumLoginAttempts,
"maximum_login_attempts": *utils.Cfg.ServiceSettings.MaximumLoginAttempts,
"session_length_web_in_days": *utils.Cfg.ServiceSettings.SessionLengthWebInDays,
"session_length_mobile_in_days": *utils.Cfg.ServiceSettings.SessionLengthMobileInDays,
"session_length_sso_in_days": *utils.Cfg.ServiceSettings.SessionLengthSSOInDays,
......@@ -235,7 +235,7 @@ func trackConfig() {
"enable_custom_brand": *utils.Cfg.TeamSettings.EnableCustomBrand,
"restrict_direct_message": *utils.Cfg.TeamSettings.RestrictDirectMessage,
"max_notifications_per_channel": *utils.Cfg.TeamSettings.MaxNotificationsPerChannel,
"max_users_per_team": utils.Cfg.TeamSettings.MaxUsersPerTeam,
"max_users_per_team": *utils.Cfg.TeamSettings.MaxUsersPerTeam,
"max_channels_per_team": *utils.Cfg.TeamSettings.MaxChannelsPerTeam,
"teammate_name_display": *utils.Cfg.TeamSettings.TeammateNameDisplay,
"isdefault_site_name": isDefault(utils.Cfg.TeamSettings.SiteName, "Mattermost"),
......@@ -255,10 +255,10 @@ func trackConfig() {
})
SendDiagnostic(TRACK_CONFIG_SQL, map[string]interface{}{
"driver_name": utils.Cfg.SqlSettings.DriverName,
"driver_name": *utils.Cfg.SqlSettings.DriverName,
"trace": utils.Cfg.SqlSettings.Trace,
"max_idle_conns": utils.Cfg.SqlSettings.MaxIdleConns,
"max_open_conns": utils.Cfg.SqlSettings.MaxOpenConns,
"max_idle_conns": *utils.Cfg.SqlSettings.MaxIdleConns,
"max_open_conns": *utils.Cfg.SqlSettings.MaxOpenConns,
"data_source_replicas": len(utils.Cfg.SqlSettings.DataSourceReplicas),
"data_source_search_replicas": len(utils.Cfg.SqlSettings.DataSourceSearchReplicas),
"query_timeout": *utils.Cfg.SqlSettings.QueryTimeout,
......@@ -284,7 +284,7 @@ func trackConfig() {
SendDiagnostic(TRACK_CONFIG_FILE, map[string]interface{}{
"enable_public_links": utils.Cfg.FileSettings.EnablePublicLink,
"driver_name": utils.Cfg.FileSettings.DriverName,
"driver_name": *utils.Cfg.FileSettings.DriverName,
"amazon_s3_ssl": *utils.Cfg.FileSettings.AmazonS3SSL,
"amazon_s3_sse": *utils.Cfg.FileSettings.AmazonS3SSE,
"amazon_s3_signv2": *utils.Cfg.FileSettings.AmazonS3SignV2,
......@@ -313,9 +313,9 @@ func trackConfig() {
SendDiagnostic(TRACK_CONFIG_RATE, map[string]interface{}{
"enable_rate_limiter": *utils.Cfg.RateLimitSettings.Enable,
"vary_by_remote_address": utils.Cfg.RateLimitSettings.VaryByRemoteAddr,
"per_sec": utils.Cfg.RateLimitSettings.PerSec,
"per_sec": *utils.Cfg.RateLimitSettings.PerSec,
"max_burst": *utils.Cfg.RateLimitSettings.MaxBurst,
"memory_store_size": utils.Cfg.RateLimitSettings.MemoryStoreSize,
"memory_store_size": *utils.Cfg.RateLimitSettings.MemoryStoreSize,
"isdefault_vary_by_header": isDefault(utils.Cfg.RateLimitSettings.VaryByHeader, ""),
})
......@@ -456,7 +456,7 @@ func trackServer() {
data := map[string]interface{}{
"edition": model.BuildEnterpriseReady,
"version": model.CurrentVersion,
"database_type": utils.Cfg.SqlSettings.DriverName,
"database_type": *utils.Cfg.SqlSettings.DriverName,
"operating_system": runtime.GOOS,
}
......
......@@ -142,7 +142,7 @@ func GetEmoji(emojiId string) (*model.Emoji, *model.AppError) {
return nil, model.NewAppError("deleteEmoji", "api.emoji.disabled.app_error", nil, "", http.StatusNotImplemented)
}
if len(utils.Cfg.FileSettings.DriverName) == 0 {
if len(*utils.Cfg.FileSettings.DriverName) == 0 {
return nil, model.NewAppError("deleteImage", "api.emoji.storage.app_error", nil, "", http.StatusNotImplemented)
}
......
......@@ -244,7 +244,7 @@ func GeneratePublicLinkHash(fileId, salt string) string {
}