[MM-25657] api4/config: add config migrate endpoint (#14928)

* api4/config: add config migrate endpoint

* api4/config: reflect review comments

* fix i18n lint error

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2020-08-14 18:26:23 +03:00
коммит произвёл GitHub
родитель bda24c8fe0
Коммит 16ffb6712f
5 изменённых файлов: 76 добавлений и 0 удалений

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

@@ -9,6 +9,7 @@ import (
"strings"
"testing"
"github.com/mattermost/mattermost-server/v5/config"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -551,3 +552,26 @@ func TestPatchConfig(t *testing.T) {
require.Equal(t, nonEmptyURL, *cfg.ServiceSettings.SiteURL)
})
}
func TestMigrateConfig(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
t.Run("user is not system admin", func(t *testing.T) {
_, response := th.Client.MigrateConfig("from", "to")
CheckForbiddenStatus(t, response)
})
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
f, err := config.NewStore("from.json", false)
require.NoError(t, err)
defer f.RemoveFile("from.json")
_, err = config.NewStore("to.json", false)
require.NoError(t, err)
defer f.RemoveFile("to.json")
_, response := client.MigrateConfig("from.json", "to.json")
CheckNoError(t, response)
})
}