Merge remote-tracking branch 'upstream/release-5.3' into release-5.3-daily-merge-20180904
Этот коммит содержится в:
@@ -5006,6 +5006,10 @@
|
|||||||
"id": "store.sql_channel.update.app_error",
|
"id": "store.sql_channel.update.app_error",
|
||||||
"translation": "We couldn't update the channel"
|
"translation": "We couldn't update the channel"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "store.sql_channel.update.archived_channel.app_error",
|
||||||
|
"translation": "You can not modify an archived channel"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "store.sql_channel.update.exists.app_error",
|
"id": "store.sql_channel.update.exists.app_error",
|
||||||
"translation": "A channel with that handle already exists"
|
"translation": "A channel with that handle already exists"
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import (
|
|||||||
// It should be maintained in chronological order with most current
|
// It should be maintained in chronological order with most current
|
||||||
// release at the front of the list.
|
// release at the front of the list.
|
||||||
var versions = []string{
|
var versions = []string{
|
||||||
|
"5.3.0",
|
||||||
"5.2.0",
|
"5.2.0",
|
||||||
"5.1.0",
|
"5.1.0",
|
||||||
"5.0.0",
|
"5.0.0",
|
||||||
|
|||||||
@@ -463,6 +463,11 @@ func (s SqlChannelStore) Update(channel *model.Channel) store.StoreChannel {
|
|||||||
return store.Do(func(result *store.StoreResult) {
|
return store.Do(func(result *store.StoreResult) {
|
||||||
channel.PreUpdate()
|
channel.PreUpdate()
|
||||||
|
|
||||||
|
if channel.DeleteAt != 0 {
|
||||||
|
result.Err = model.NewAppError("SqlChannelStore.Update", "store.sql_channel.update.archived_channel.app_error", nil, "", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if result.Err = channel.IsValid(); result.Err != nil {
|
if result.Err = channel.IsValid(); result.Err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -484,10 +484,8 @@ func UpgradeDatabaseToVersion52(sqlStore SqlStore) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func UpgradeDatabaseToVersion53(sqlStore SqlStore) {
|
func UpgradeDatabaseToVersion53(sqlStore SqlStore) {
|
||||||
// TODO: Uncomment following condition when version 5.3.0 is released
|
if shouldPerformUpgrade(sqlStore, VERSION_5_2_0, VERSION_5_3_0) {
|
||||||
// if shouldPerformUpgrade(sqlStore, VERSION_5_2_0, VERSION_5_3_0) {
|
saveSchemaVersion(sqlStore, VERSION_5_3_0)
|
||||||
sqlStore.AlterColumnTypeIfExists("OutgoingWebhooks", "Description", "varchar(500)", "varchar(500)")
|
}
|
||||||
sqlStore.AlterColumnTypeIfExists("IncomingWebhooks", "Description", "varchar(500)", "varchar(500)")
|
|
||||||
// saveSchemaVersion(sqlStore, VERSION_5_3_0)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,6 +220,12 @@ func testChannelStoreUpdate(t *testing.T, ss store.Store) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
o1.DeleteAt = 100
|
||||||
|
if err := (<-ss.Channel().Update(&o1)).Err; err == nil {
|
||||||
|
t.Fatal("Update should have failed because channel is archived")
|
||||||
|
}
|
||||||
|
|
||||||
|
o1.DeleteAt = 0
|
||||||
o1.Id = "missing"
|
o1.Id = "missing"
|
||||||
if err := (<-ss.Channel().Update(&o1)).Err; err == nil {
|
if err := (<-ss.Channel().Update(&o1)).Err; err == nil {
|
||||||
t.Fatal("Update should have failed because of missing key")
|
t.Fatal("Update should have failed because of missing key")
|
||||||
|
|||||||
@@ -245,6 +245,16 @@ func ReadConfig(r io.Reader, allowEnvironmentOverrides bool) (*model.Config, map
|
|||||||
|
|
||||||
var config model.Config
|
var config model.Config
|
||||||
unmarshalErr := v.Unmarshal(&config)
|
unmarshalErr := v.Unmarshal(&config)
|
||||||
|
// https://github.com/spf13/viper/issues/324
|
||||||
|
// https://github.com/spf13/viper/issues/348
|
||||||
|
if unmarshalErr == nil {
|
||||||
|
config.PluginSettings.Plugins = make(map[string]map[string]interface{})
|
||||||
|
unmarshalErr = v.UnmarshalKey("pluginsettings.plugins", &config.PluginSettings.Plugins)
|
||||||
|
}
|
||||||
|
if unmarshalErr == nil {
|
||||||
|
config.PluginSettings.PluginStates = make(map[string]*model.PluginState)
|
||||||
|
unmarshalErr = v.UnmarshalKey("pluginsettings.pluginstates", &config.PluginSettings.PluginStates)
|
||||||
|
}
|
||||||
|
|
||||||
envConfig := v.EnvSettings()
|
envConfig := v.EnvSettings()
|
||||||
|
|
||||||
@@ -272,6 +282,10 @@ func newViper(allowEnvironmentOverrides bool) *viper.Viper {
|
|||||||
defaults := getDefaultsFromStruct(model.Config{})
|
defaults := getDefaultsFromStruct(model.Config{})
|
||||||
|
|
||||||
for key, value := range defaults {
|
for key, value := range defaults {
|
||||||
|
if key == "PluginSettings.Plugins" || key == "PluginSettings.PluginStates" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
v.SetDefault(key, value)
|
v.SetDefault(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,11 +52,23 @@ func TestReadConfig_PluginSettings(t *testing.T) {
|
|||||||
"abc": 123,
|
"abc": 123,
|
||||||
"def": "456"
|
"def": "456"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"jira": {
|
||||||
|
"number": 2,
|
||||||
|
"string": "123",
|
||||||
|
"boolean": true,
|
||||||
|
"abc.def.ghi": {
|
||||||
|
"abc": 456,
|
||||||
|
"def": "123"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"PluginStates": {
|
"PluginStates": {
|
||||||
"com.example.plugin": {
|
"com.example.plugin": {
|
||||||
"enable": true
|
"enable": true
|
||||||
|
},
|
||||||
|
"jira": {
|
||||||
|
"enable": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,7 +76,8 @@ func TestReadConfig_PluginSettings(t *testing.T) {
|
|||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
assert.Equal(t, "/temp/mattermost-plugins", *config.PluginSettings.Directory)
|
assert.Equal(t, "/temp/mattermost-plugins", *config.PluginSettings.Directory)
|
||||||
assert.Contains(t, config.PluginSettings.Plugins, "com.example.plugin")
|
|
||||||
|
if assert.Contains(t, config.PluginSettings.Plugins, "com.example.plugin") {
|
||||||
assert.Equal(t, map[string]interface{}{
|
assert.Equal(t, map[string]interface{}{
|
||||||
"number": float64(1),
|
"number": float64(1),
|
||||||
"string": "abc",
|
"string": "abc",
|
||||||
@@ -74,12 +87,31 @@ func TestReadConfig_PluginSettings(t *testing.T) {
|
|||||||
"def": "456",
|
"def": "456",
|
||||||
},
|
},
|
||||||
}, config.PluginSettings.Plugins["com.example.plugin"])
|
}, config.PluginSettings.Plugins["com.example.plugin"])
|
||||||
assert.Contains(t, config.PluginSettings.PluginStates, "com.example.plugin")
|
}
|
||||||
|
if assert.Contains(t, config.PluginSettings.PluginStates, "com.example.plugin") {
|
||||||
assert.Equal(t, model.PluginState{
|
assert.Equal(t, model.PluginState{
|
||||||
Enable: true,
|
Enable: true,
|
||||||
}, *config.PluginSettings.PluginStates["com.example.plugin"])
|
}, *config.PluginSettings.PluginStates["com.example.plugin"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if assert.Contains(t, config.PluginSettings.Plugins, "jira") {
|
||||||
|
assert.Equal(t, map[string]interface{}{
|
||||||
|
"number": float64(2),
|
||||||
|
"string": "123",
|
||||||
|
"boolean": true,
|
||||||
|
"abc.def.ghi": map[string]interface{}{
|
||||||
|
"abc": float64(456),
|
||||||
|
"def": "123",
|
||||||
|
},
|
||||||
|
}, config.PluginSettings.Plugins["jira"])
|
||||||
|
}
|
||||||
|
if assert.Contains(t, config.PluginSettings.PluginStates, "jira") {
|
||||||
|
assert.Equal(t, model.PluginState{
|
||||||
|
Enable: false,
|
||||||
|
}, *config.PluginSettings.PluginStates["jira"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestTimezoneConfig(t *testing.T) {
|
func TestTimezoneConfig(t *testing.T) {
|
||||||
TranslationsPreInit()
|
TranslationsPreInit()
|
||||||
supportedTimezones := LoadTimezones("timezones.json")
|
supportedTimezones := LoadTimezones("timezones.json")
|
||||||
@@ -381,6 +413,20 @@ func TestConfigFromEnviroVars(t *testing.T) {
|
|||||||
},
|
},
|
||||||
"SupportSettings": {
|
"SupportSettings": {
|
||||||
"TermsOfServiceLink": "https://about.mattermost.com/default-terms/"
|
"TermsOfServiceLink": "https://about.mattermost.com/default-terms/"
|
||||||
|
},
|
||||||
|
"PluginSettings": {
|
||||||
|
"Enable": true,
|
||||||
|
"Plugins": {
|
||||||
|
"jira": {
|
||||||
|
"enabled": "true",
|
||||||
|
"secret": "config-secret"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"PluginStates": {
|
||||||
|
"jira": {
|
||||||
|
"Enable": true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
@@ -517,20 +563,19 @@ func TestConfigFromEnviroVars(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("plugin directory settings", func(t *testing.T) {
|
t.Run("plugin directory settings", func(t *testing.T) {
|
||||||
|
os.Setenv("MM_PLUGINSETTINGS_ENABLE", "false")
|
||||||
os.Setenv("MM_PLUGINSETTINGS_DIRECTORY", "/temp/plugins")
|
os.Setenv("MM_PLUGINSETTINGS_DIRECTORY", "/temp/plugins")
|
||||||
os.Setenv("MM_PLUGINSETTINGS_CLIENTDIRECTORY", "/temp/clientplugins")
|
os.Setenv("MM_PLUGINSETTINGS_CLIENTDIRECTORY", "/temp/clientplugins")
|
||||||
|
defer os.Unsetenv("MM_PLUGINSETTINGS_ENABLE")
|
||||||
defer os.Unsetenv("MM_PLUGINSETTINGS_DIRECTORY")
|
defer os.Unsetenv("MM_PLUGINSETTINGS_DIRECTORY")
|
||||||
defer os.Unsetenv("MM_PLUGINSETTINGS_CLIENTDIRECTORY")
|
defer os.Unsetenv("MM_PLUGINSETTINGS_CLIENTDIRECTORY")
|
||||||
|
|
||||||
cfg, envCfg, err := ReadConfig(strings.NewReader(config), true)
|
cfg, envCfg, err := ReadConfig(strings.NewReader(config), true)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
if *cfg.PluginSettings.Directory != "/temp/plugins" {
|
assert.Equal(t, false, *cfg.PluginSettings.Enable)
|
||||||
t.Fatal("Couldn't read Directory from environment var")
|
assert.Equal(t, "/temp/plugins", *cfg.PluginSettings.Directory)
|
||||||
}
|
assert.Equal(t, "/temp/clientplugins", *cfg.PluginSettings.ClientDirectory)
|
||||||
if *cfg.PluginSettings.ClientDirectory != "/temp/clientplugins" {
|
|
||||||
t.Fatal("Couldn't read ClientDirectory from environment var")
|
|
||||||
}
|
|
||||||
|
|
||||||
if pluginSettings, ok := envCfg["PluginSettings"]; !ok {
|
if pluginSettings, ok := envCfg["PluginSettings"]; !ok {
|
||||||
t.Fatal("PluginSettings is missing from envConfig")
|
t.Fatal("PluginSettings is missing from envConfig")
|
||||||
@@ -545,6 +590,58 @@ func TestConfigFromEnviroVars(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("plugin specific settings cannot be overridden via environment", func(t *testing.T) {
|
||||||
|
os.Setenv("MM_PLUGINSETTINGS_PLUGINS_JIRA_ENABLED", "false")
|
||||||
|
os.Setenv("MM_PLUGINSETTINGS_PLUGINS_JIRA_SECRET", "env-secret")
|
||||||
|
os.Setenv("MM_PLUGINSETTINGS_PLUGINSTATES_JIRA_ENABLE", "false")
|
||||||
|
defer os.Unsetenv("MM_PLUGINSETTINGS_PLUGINS_JIRA_ENABLED")
|
||||||
|
defer os.Unsetenv("MM_PLUGINSETTINGS_PLUGINS_JIRA_SECRET")
|
||||||
|
defer os.Unsetenv("MM_PLUGINSETTINGS_PLUGINSTATES_JIRA_ENABLE")
|
||||||
|
|
||||||
|
cfg, envCfg, err := ReadConfig(strings.NewReader(config), true)
|
||||||
|
require.Nil(t, err)
|
||||||
|
|
||||||
|
if pluginsJira, ok := cfg.PluginSettings.Plugins["jira"]; !ok {
|
||||||
|
t.Fatal("PluginSettings.Plugins.jira is missing from config")
|
||||||
|
} else {
|
||||||
|
if enabled, ok := pluginsJira["enabled"]; !ok {
|
||||||
|
t.Fatal("PluginSettings.Plugins.jira.enabled is missing from config")
|
||||||
|
} else {
|
||||||
|
assert.Equal(t, "true", enabled)
|
||||||
|
}
|
||||||
|
|
||||||
|
if secret, ok := pluginsJira["secret"]; !ok {
|
||||||
|
t.Fatal("PluginSettings.Plugins.jira.secret is missing from config")
|
||||||
|
} else {
|
||||||
|
assert.Equal(t, "config-secret", secret)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if pluginStatesJira, ok := cfg.PluginSettings.PluginStates["jira"]; !ok {
|
||||||
|
t.Fatal("PluginSettings.PluginStates.jira is missing from config")
|
||||||
|
} else {
|
||||||
|
require.Equal(t, true, pluginStatesJira.Enable)
|
||||||
|
}
|
||||||
|
|
||||||
|
if pluginSettings, ok := envCfg["PluginSettings"]; !ok {
|
||||||
|
t.Fatal("PluginSettings is missing from envConfig")
|
||||||
|
} else if pluginSettingsAsMap, ok := pluginSettings.(map[string]interface{}); !ok {
|
||||||
|
t.Fatal("PluginSettings is not a map in envConfig")
|
||||||
|
} else {
|
||||||
|
if plugins, ok := pluginSettingsAsMap["Plugins"].(map[string]interface{}); !ok {
|
||||||
|
t.Fatal("PluginSettings.Plugins is not a map in envConfig")
|
||||||
|
} else if _, ok := plugins["jira"].(map[string]interface{}); ok {
|
||||||
|
t.Fatal("PluginSettings.Plugins.jira should not be a map in envConfig")
|
||||||
|
}
|
||||||
|
|
||||||
|
if pluginStates, ok := pluginSettingsAsMap["PluginStates"].(map[string]interface{}); !ok {
|
||||||
|
t.Fatal("PluginSettings.PluginStates is missing from envConfig")
|
||||||
|
} else if _, ok := pluginStates["jira"].(map[string]interface{}); ok {
|
||||||
|
t.Fatal("PluginSettings.PluginStates.jira should not be a map in envConfig")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateLocales(t *testing.T) {
|
func TestValidateLocales(t *testing.T) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user