[MM-29515] Don't allow slack imports in cloud installations (#16271)
* Don't allow slack imports in cloud installations * Update api4/team.go Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com> * Add a test case for when the import is restricted in cloud * Update api4/team_test.go Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com> * Check for cloud license instead of restrictsystemadmin * fix tests Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com> Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
@@ -1079,6 +1079,11 @@ func teamExists(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func importTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if c.App.Srv().License() != nil && *c.App.Srv().License().Features.Cloud {
|
||||
c.Err = model.NewAppError("importTeam", "api.restricted_system_admin", nil, "", http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
c.RequireTeamId()
|
||||
if c.Err != nil {
|
||||
return
|
||||
|
||||
@@ -2709,6 +2709,20 @@ func TestImportTeam(t *testing.T) {
|
||||
require.Equal(t, posts.Posts[posts.Order[3]].Message, "This is a test post to test the import process", "missing posts in the import process")
|
||||
})
|
||||
|
||||
t.Run("Cloud Forbidden", func(t *testing.T) {
|
||||
var data []byte
|
||||
var err error
|
||||
data, err = testutils.ReadTestFile("Fake_Team_Import.zip")
|
||||
|
||||
require.False(t, err != nil && len(data) == 0, "Error while reading the test file.")
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
||||
|
||||
// Import the channels/users/posts
|
||||
_, resp := th.SystemAdminClient.ImportTeam(data, binary.Size(data), "slack", "Fake_Team_Import.zip", th.BasicTeam.Id)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
th.App.Srv().SetLicense(nil)
|
||||
})
|
||||
|
||||
t.Run("MissingFile", func(t *testing.T) {
|
||||
_, resp := th.SystemAdminClient.ImportTeam(nil, 4343, "slack", "Fake_Team_Import.zip", th.BasicTeam.Id)
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
Ссылка в новой задаче
Block a user