set to default value with config is missing (#7320)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
4c1f467442
Коммит
651dd33b29
@@ -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")
|
||||
|
||||
Ссылка в новой задаче
Block a user