Sanitize sensitive data of out config file for the system console (#2849)

Этот коммит содержится в:
Joram Wilander
2016-05-03 14:45:36 -04:00
коммит произвёл Christopher Speller
родитель 87989b8afd
Коммит b18cf58c8f
5 изменённых файлов: 112 добавлений и 15 удалений

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

@@ -68,6 +68,37 @@ func TestGetConfig(t *testing.T) {
if len(cfg.TeamSettings.SiteName) == 0 {
t.Fatal()
}
if *cfg.LdapSettings.BindPassword != model.FAKE_SETTING && len(*cfg.LdapSettings.BindPassword) != 0 {
t.Fatal("did not sanitize properly")
}
if cfg.FileSettings.PublicLinkSalt != model.FAKE_SETTING {
t.Fatal("did not sanitize properly")
}
if cfg.FileSettings.AmazonS3SecretAccessKey != model.FAKE_SETTING && len(cfg.FileSettings.AmazonS3SecretAccessKey) != 0 {
t.Fatal("did not sanitize properly")
}
if cfg.EmailSettings.InviteSalt != model.FAKE_SETTING {
t.Fatal("did not sanitize properly")
}
if cfg.EmailSettings.PasswordResetSalt != model.FAKE_SETTING {
t.Fatal("did not sanitize properly")
}
if cfg.EmailSettings.SMTPPassword != model.FAKE_SETTING && len(cfg.EmailSettings.SMTPPassword) != 0 {
t.Fatal("did not sanitize properly")
}
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 {
t.Fatal("did not sanitize properly")
}
if cfg.SqlSettings.AtRestEncryptKey != model.FAKE_SETTING {
t.Fatal("did not sanitize properly")
}
if !strings.Contains(strings.Join(cfg.SqlSettings.DataSourceReplicas, " "), model.FAKE_SETTING) && len(cfg.SqlSettings.DataSourceReplicas) != 0 {
t.Fatal("did not sanitize properly")
}
}
}
@@ -80,14 +111,8 @@ func TestSaveConfig(t *testing.T) {
*utils.Cfg.TeamSettings.EnableOpenServer = false
if result, err := th.SystemAdminClient.SaveConfig(utils.Cfg); err != nil {
if _, err := th.SystemAdminClient.SaveConfig(utils.Cfg); err != nil {
t.Fatal(err)
} else {
cfg := result.Data.(*model.Config)
if len(cfg.TeamSettings.SiteName) == 0 {
t.Fatal()
}
}
*utils.Cfg.TeamSettings.EnableOpenServer = true