MM-41655: Prevent mmctl import into cloud instances (#20191)

mmctl import is not supported and therefore we stop it.

https://mattermost.atlassian.net/browse/MM-41655

```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2022-05-12 12:37:59 +05:30
коммит произвёл GitHub
родитель 1092c60bc6
Коммит 52661807f7
3 изменённых файлов: 50 добавлений и 0 удалений

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

@@ -45,6 +45,21 @@ func TestCreateUpload(t *testing.T) {
require.Equal(t, http.StatusForbidden, resp.StatusCode)
})
t.Run("not allowed in cloud", func(t *testing.T) {
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
defer th.App.Srv().RemoveLicense()
u, resp, err := th.SystemAdminClient.CreateUpload(&model.UploadSession{
ChannelId: th.BasicChannel.Id,
Filename: "upload",
FileSize: 8 * 1024 * 1024,
Type: model.UploadTypeImport,
})
require.Nil(t, u)
CheckErrorID(t, err, "api.file.cloud_upload.app_error")
require.Equal(t, http.StatusBadRequest, resp.StatusCode)
})
t.Run("valid", func(t *testing.T) {
us.ChannelId = th.BasicChannel.Id
u, resp, err := th.Client.CreateUpload(us)
@@ -223,6 +238,28 @@ func TestUploadData(t *testing.T) {
CheckErrorID(t, err, "api.context.permissions.app_error")
})
t.Run("not allowed in cloud", func(t *testing.T) {
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
defer th.App.Srv().RemoveLicense()
us2 := &model.UploadSession{
Id: model.NewId(),
Type: model.UploadTypeImport,
CreateAt: model.GetMillis(),
UserId: th.BasicUser2.Id,
ChannelId: th.BasicChannel.Id,
Filename: "upload",
FileSize: 8 * 1024 * 1024,
}
_, appErr := th.App.CreateUploadSession(us2)
require.Nil(t, appErr)
info, resp, err := th.SystemAdminClient.UploadData(us2.Id, bytes.NewReader(data))
require.Nil(t, info)
CheckErrorID(t, err, "api.file.cloud_upload.app_error")
require.Equal(t, http.StatusBadRequest, resp.StatusCode)
})
t.Run("bad content-length", func(t *testing.T) {
u, resp, err := th.Client.CreateUpload(us)
require.NoError(t, err)