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

Этот коммит содержится в:
Saturnino Abril
2017-08-31 01:54:16 +08:00
коммит произвёл Joram Wilander
родитель 4c1f467442
Коммит 651dd33b29
41 изменённых файлов: 252 добавлений и 195 удалений

Просмотреть файл

@@ -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)