[MM-36444] Manage config deprecations for 6.0 (#18035)

* removing deprecated stuff

* removing deprecations and marking others for deprecations

* removing some of the configs

* partially remove ExperimentalChannelOrganization

* fixing merge issues

* moving default permissions to defaultroles function

* removing experimentaltownsquare

* removing old tests and remove legacysidebar config

* fixing test

* removing log

* removing unused variables

* MM-36444: Fix for renamed functions.

* MM-36444: go mod tidy and go mod vendor.

* MM-36444: Vendored go modules.

* MM-36444: Removes UseExperimentalGossip config field from model.

* Fix vendors

* fixing test

Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.local>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Martin Kraft <martin@upspin.org>
Co-authored-by: Claudio Costa <cstcld91@gmail.com>
Этот коммит содержится в:
Ben Cooke
2021-09-14 13:22:59 -04:00
коммит произвёл GitHub
родитель 0953e3f0cf
Коммит 3b9324b389
22 изменённых файлов: 92 добавлений и 1176 удалений

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

@@ -725,7 +725,6 @@ func saveIsPinnedPost(c *Context, w http.ResponseWriter, isPinned bool) {
}
if c.App.Srv().License() != nil &&
*c.App.Config().TeamSettings.ExperimentalTownSquareIsReadOnly &&
channel.Name == model.DefaultChannelName &&
!c.App.RolesGrantPermission(user.GetRoles(), model.PermissionManageSystem.Id) {
c.Err = model.NewAppError("saveIsPinnedPost", "api.post.save_is_pinned_post.town_square_read_only", nil, "", http.StatusForbidden)

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

@@ -1006,23 +1006,6 @@ func TestPinPost(t *testing.T) {
require.Error(t, err)
CheckForbiddenStatus(t, resp)
t.Run("unable-to-pin-post-in-read-only-town-square", func(t *testing.T) {
townSquareIsReadOnly := *th.App.Config().TeamSettings.ExperimentalTownSquareIsReadOnly
th.App.Srv().SetLicense(model.NewTestLicense())
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = true })
defer th.App.Srv().RemoveLicense()
defer th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = townSquareIsReadOnly })
channel, appErr := th.App.GetChannelByName("town-square", th.BasicTeam.Id, true)
assert.Nil(t, appErr)
adminPost := th.CreatePostWithClient(th.SystemAdminClient, channel)
resp, err = client.PinPost(adminPost.Id)
require.Error(t, err)
CheckForbiddenStatus(t, resp)
})
client.Logout()
resp, err = client.PinPost(post.Id)
require.Error(t, err)

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

@@ -165,34 +165,6 @@ func TestSaveReaction(t *testing.T) {
th.AddPermissionToRole(model.PermissionAddReaction.Id, model.ChannelUserRoleId)
})
t.Run("unable-to-react-in-read-only-town-square", func(t *testing.T) {
th.LoginBasic()
channel, appErr := th.App.GetChannelByName("town-square", th.BasicTeam.Id, true)
assert.Nil(t, appErr)
post := th.CreatePostWithClient(th.Client, channel)
th.App.Srv().SetLicense(model.NewTestLicense())
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = true })
reaction := &model.Reaction{
UserId: userId,
PostId: post.Id,
EmojiName: "smile",
}
_, resp, err := client.SaveReaction(reaction)
require.Error(t, err)
CheckForbiddenStatus(t, resp)
reactions, appErr := th.App.GetReactionsForPost(post.Id)
require.Nil(t, appErr)
require.Equal(t, 0, len(reactions), "should have not created a reaction")
th.App.Srv().RemoveLicense()
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = false })
})
t.Run("unable-to-react-in-an-archived-channel", func(t *testing.T) {
th.LoginBasic()
@@ -501,42 +473,6 @@ func TestDeleteReaction(t *testing.T) {
th.AddPermissionToRole(model.PermissionRemoveOthersReactions.Id, model.SystemAdminRoleId)
})
t.Run("unable-to-delete-reactions-in-read-only-town-square", func(t *testing.T) {
th.LoginBasic()
channel, appErr := th.App.GetChannelByName("town-square", th.BasicTeam.Id, true)
assert.Nil(t, appErr)
post := th.CreatePostWithClient(th.Client, channel)
th.App.Srv().SetLicense(model.NewTestLicense())
reaction := &model.Reaction{
UserId: userId,
PostId: post.Id,
EmojiName: "smile",
}
r1, _, err := client.SaveReaction(reaction)
require.NoError(t, err)
reactions, appErr := th.App.GetReactionsForPost(postId)
require.Nil(t, appErr)
require.Equal(t, 1, len(reactions), "should have created a reaction")
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = true })
resp, err := th.SystemAdminClient.DeleteReaction(r1)
require.Error(t, err)
CheckForbiddenStatus(t, resp)
reactions, appErr = th.App.GetReactionsForPost(postId)
require.Nil(t, appErr)
require.Equal(t, 1, len(reactions), "should have not deleted a reaction")
th.App.Srv().RemoveLicense()
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = false })
})
t.Run("unable-to-delete-reactions-in-an-archived-channel", func(t *testing.T) {
th.LoginBasic()

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

@@ -57,7 +57,6 @@ func (api *API) InitUser() {
api.BaseRoutes.User.Handle("/auth", api.APISessionRequiredTrustRequester(updateUserAuth)).Methods("PUT")
api.BaseRoutes.Users.Handle("/mfa", api.APIHandler(checkUserMfa)).Methods("POST")
api.BaseRoutes.User.Handle("/mfa", api.APISessionRequiredMfa(updateUserMfa)).Methods("PUT")
api.BaseRoutes.User.Handle("/mfa/generate", api.APISessionRequiredMfa(generateMfaSecret)).Methods("POST")
@@ -1510,40 +1509,6 @@ func updateUserAuth(c *Context, w http.ResponseWriter, r *http.Request) {
}
}
// Deprecated: checkUserMfa is deprecated and should not be used anymore, starting with version 6.0 it will be disabled.
// Clients should attempt a login without MFA and will receive a MFA error when it's required.
func checkUserMfa(c *Context, w http.ResponseWriter, r *http.Request) {
if *c.App.Config().ServiceSettings.DisableLegacyMFA {
http.NotFound(w, r)
return
}
props := model.MapFromJSON(r.Body)
loginId := props["login_id"]
if loginId == "" {
c.SetInvalidParam("login_id")
return
}
resp := map[string]interface{}{}
resp["mfa_required"] = false
if !*c.App.Config().ServiceSettings.EnableMultifactorAuthentication {
w.Write([]byte(model.StringInterfaceToJSON(resp)))
return
}
if *c.App.Config().ServiceSettings.ExperimentalEnableHardenedMode {
resp["mfa_required"] = true
} else if user, err := c.App.GetUserForLogin("", loginId); err == nil {
resp["mfa_required"] = user.MfaActive
}
w.Write([]byte(model.StringInterfaceToJSON(resp)))
}
func updateUserMfa(c *Context, w http.ResponseWriter, r *http.Request) {
c.RequireUserId()
if c.Err != nil {

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

@@ -2769,7 +2769,6 @@ func TestUserLoginMFAFlow(t *testing.T) {
defer th.TearDown()
th.App.UpdateConfig(func(c *model.Config) {
*c.ServiceSettings.DisableLegacyMFA = true
*c.ServiceSettings.EnableMultifactorAuthentication = true
})