PLT-7978 Add websocket event for user role update (#7745)
* Add websocket event for user role update * Fix tests * More test fixes
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
6886de04d4
Коммит
06ec648cf3
@@ -194,7 +194,7 @@ func (me *TestHelper) InitBasic() *TestHelper {
|
||||
me.waitForConnectivity()
|
||||
|
||||
me.TeamAdminUser = me.CreateUser()
|
||||
me.App.UpdateUserRoles(me.TeamAdminUser.Id, model.ROLE_SYSTEM_USER.Id)
|
||||
me.App.UpdateUserRoles(me.TeamAdminUser.Id, model.ROLE_SYSTEM_USER.Id, false)
|
||||
me.LoginTeamAdmin()
|
||||
me.BasicTeam = me.CreateTeam()
|
||||
me.BasicChannel = me.CreatePublicChannel()
|
||||
@@ -211,7 +211,7 @@ func (me *TestHelper) InitBasic() *TestHelper {
|
||||
me.App.AddUserToChannel(me.BasicUser2, me.BasicChannel2)
|
||||
me.App.AddUserToChannel(me.BasicUser, me.BasicPrivateChannel)
|
||||
me.App.AddUserToChannel(me.BasicUser2, me.BasicPrivateChannel)
|
||||
me.App.UpdateUserRoles(me.BasicUser.Id, model.ROLE_SYSTEM_USER.Id)
|
||||
me.App.UpdateUserRoles(me.BasicUser.Id, model.ROLE_SYSTEM_USER.Id, false)
|
||||
me.LoginBasic()
|
||||
|
||||
return me
|
||||
@@ -221,7 +221,7 @@ func (me *TestHelper) InitSystemAdmin() *TestHelper {
|
||||
me.waitForConnectivity()
|
||||
|
||||
me.SystemAdminUser = me.CreateUser()
|
||||
me.App.UpdateUserRoles(me.SystemAdminUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_ADMIN.Id)
|
||||
me.App.UpdateUserRoles(me.SystemAdminUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_ADMIN.Id, false)
|
||||
me.LoginSystemAdmin()
|
||||
|
||||
return me
|
||||
|
||||
@@ -292,7 +292,7 @@ func TestCreatePostPublic(t *testing.T) {
|
||||
_, resp = Client.CreatePost(post)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
th.App.UpdateUserRoles(ruser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_POST_ALL_PUBLIC.Id)
|
||||
th.App.UpdateUserRoles(ruser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_POST_ALL_PUBLIC.Id, false)
|
||||
th.App.InvalidateAllCaches()
|
||||
|
||||
Client.Login(user.Email, user.Password)
|
||||
@@ -304,7 +304,7 @@ func TestCreatePostPublic(t *testing.T) {
|
||||
_, resp = Client.CreatePost(post)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
th.App.UpdateUserRoles(ruser.Id, model.ROLE_SYSTEM_USER.Id)
|
||||
th.App.UpdateUserRoles(ruser.Id, model.ROLE_SYSTEM_USER.Id, false)
|
||||
th.App.JoinUserToTeam(th.BasicTeam, ruser, "")
|
||||
th.App.UpdateTeamMemberRoles(th.BasicTeam.Id, ruser.Id, model.ROLE_TEAM_USER.Id+" "+model.ROLE_TEAM_POST_ALL_PUBLIC.Id)
|
||||
th.App.InvalidateAllCaches()
|
||||
@@ -339,7 +339,7 @@ func TestCreatePostAll(t *testing.T) {
|
||||
_, resp = Client.CreatePost(post)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
th.App.UpdateUserRoles(ruser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_POST_ALL.Id)
|
||||
th.App.UpdateUserRoles(ruser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_POST_ALL.Id, false)
|
||||
th.App.InvalidateAllCaches()
|
||||
|
||||
Client.Login(user.Email, user.Password)
|
||||
@@ -355,7 +355,7 @@ func TestCreatePostAll(t *testing.T) {
|
||||
_, resp = Client.CreatePost(post)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
th.App.UpdateUserRoles(ruser.Id, model.ROLE_SYSTEM_USER.Id)
|
||||
th.App.UpdateUserRoles(ruser.Id, model.ROLE_SYSTEM_USER.Id, false)
|
||||
th.App.JoinUserToTeam(th.BasicTeam, ruser, "")
|
||||
th.App.UpdateTeamMemberRoles(th.BasicTeam.Id, ruser.Id, model.ROLE_TEAM_USER.Id+" "+model.ROLE_TEAM_POST_ALL.Id)
|
||||
th.App.InvalidateAllCaches()
|
||||
|
||||
@@ -651,7 +651,7 @@ func updateUserRoles(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := c.App.UpdateUserRoles(c.Params.UserId, newRoles); err != nil {
|
||||
if _, err := c.App.UpdateUserRoles(c.Params.UserId, newRoles, true); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
} else {
|
||||
|
||||
@@ -2200,7 +2200,7 @@ func TestCreateUserAccessToken(t *testing.T) {
|
||||
_, resp = Client.CreateUserAccessToken(th.BasicUser.Id, "")
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_USER_ACCESS_TOKEN.Id)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_USER_ACCESS_TOKEN.Id, false)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableUserAccessTokens = false })
|
||||
_, resp = Client.CreateUserAccessToken(th.BasicUser.Id, testDescription)
|
||||
@@ -2278,7 +2278,7 @@ func TestGetUserAccessToken(t *testing.T) {
|
||||
_, resp = Client.GetUserAccessToken(model.NewId())
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_USER_ACCESS_TOKEN.Id)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_USER_ACCESS_TOKEN.Id, false)
|
||||
token, resp := Client.CreateUserAccessToken(th.BasicUser.Id, testDescription)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
@@ -2339,7 +2339,7 @@ func TestRevokeUserAccessToken(t *testing.T) {
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableUserAccessTokens = true })
|
||||
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_USER_ACCESS_TOKEN.Id)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_USER_ACCESS_TOKEN.Id, false)
|
||||
token, resp := Client.CreateUserAccessToken(th.BasicUser.Id, testDescription)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
@@ -2387,7 +2387,7 @@ func TestDisableUserAccessToken(t *testing.T) {
|
||||
}()
|
||||
*utils.Cfg.ServiceSettings.EnableUserAccessTokens = true
|
||||
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_USER_ACCESS_TOKEN.Id)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_USER_ACCESS_TOKEN.Id, false)
|
||||
token, resp := Client.CreateUserAccessToken(th.BasicUser.Id, testDescription)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
@@ -2434,7 +2434,7 @@ func TestEnableUserAccessToken(t *testing.T) {
|
||||
}()
|
||||
*utils.Cfg.ServiceSettings.EnableUserAccessTokens = true
|
||||
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_USER_ACCESS_TOKEN.Id)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_USER_ACCESS_TOKEN.Id, false)
|
||||
token, resp := Client.CreateUserAccessToken(th.BasicUser.Id, testDescription)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
@@ -2476,7 +2476,7 @@ func TestUserAccessTokenInactiveUser(t *testing.T) {
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableUserAccessTokens = true })
|
||||
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_USER_ACCESS_TOKEN.Id)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_USER_ACCESS_TOKEN.Id, false)
|
||||
token, resp := Client.CreateUserAccessToken(th.BasicUser.Id, testDescription)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
@@ -2499,7 +2499,7 @@ func TestUserAccessTokenDisableConfig(t *testing.T) {
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableUserAccessTokens = true })
|
||||
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_USER_ACCESS_TOKEN.Id)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_USER_ACCESS_TOKEN.Id, false)
|
||||
token, resp := Client.CreateUserAccessToken(th.BasicUser.Id, testDescription)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user