Improve system admin permissions to dms and gms (#29656)
* revert the api4 portion of 57372bd06b
* test: Add system admin channel access tests
* skip a.HasPermissionToTeam for channels without a team
* fix TestPostGetInfo
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
812034f5eb
Коммит
9e01424b15
@@ -1995,13 +1995,39 @@ func TestGetPostsForChannel(t *testing.T) {
|
||||
CheckOKStatus(t, resp)
|
||||
require.Len(t, posts.Order, 10, "expected 10 posts")
|
||||
|
||||
// allow viewing of direct messages
|
||||
// System admin can access public channel without being member
|
||||
adminPublicChannel := th.CreatePublicChannel()
|
||||
th.CreateMessagePostNoClient(adminPublicChannel, "admin channel post", model.GetMillis())
|
||||
posts, resp, err = c.GetPostsForChannel(context.Background(), adminPublicChannel.Id, 0, 100, "", false, false)
|
||||
require.NoError(t, err)
|
||||
CheckOKStatus(t, resp)
|
||||
require.NotEmpty(t, posts.Order)
|
||||
|
||||
// System admin can access private channel without being member
|
||||
privateChannel := th.CreatePrivateChannel()
|
||||
th.CreateMessagePostNoClient(privateChannel, "private channel post", model.GetMillis())
|
||||
posts, resp, err = c.GetPostsForChannel(context.Background(), privateChannel.Id, 0, 100, "", false, false)
|
||||
require.NoError(t, err)
|
||||
CheckOKStatus(t, resp)
|
||||
require.NotEmpty(t, posts.Order)
|
||||
|
||||
// System admin can access direct messages without being member
|
||||
dmChannel := th.CreateDmChannel(th.BasicUser2)
|
||||
th.CreateMessagePostNoClient(dmChannel, "test1", model.GetMillis())
|
||||
|
||||
posts, resp, err = c.GetPostsForChannel(context.Background(), dmChannel.Id, 0, 100, "", false, false)
|
||||
require.NoError(t, err)
|
||||
CheckOKStatus(t, resp)
|
||||
require.NotEmpty(t, posts.Order)
|
||||
|
||||
// System admin can access group messages without being member
|
||||
user3 := th.CreateUser()
|
||||
gmChannel, _, err := th.Client.CreateGroupChannel(context.Background(), []string{th.BasicUser.Id, th.BasicUser2.Id, user3.Id})
|
||||
require.NoError(t, err)
|
||||
th.CreateMessagePostNoClient(gmChannel, "test2", model.GetMillis())
|
||||
posts, resp, err = c.GetPostsForChannel(context.Background(), gmChannel.Id, 0, 100, "", false, false)
|
||||
require.NoError(t, err)
|
||||
CheckOKStatus(t, resp)
|
||||
require.NotEmpty(t, posts.Order)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -4544,7 +4570,7 @@ func TestPostGetInfo(t *testing.T) {
|
||||
channel: gmChannel,
|
||||
post: gmPost,
|
||||
client: sysadminClient,
|
||||
hasAccess: false,
|
||||
hasAccess: true,
|
||||
},
|
||||
|
||||
// DM channel
|
||||
@@ -4563,7 +4589,7 @@ func TestPostGetInfo(t *testing.T) {
|
||||
channel: dmChannel,
|
||||
post: dmPost,
|
||||
client: sysadminClient,
|
||||
hasAccess: false,
|
||||
hasAccess: true,
|
||||
},
|
||||
|
||||
// Open channel - Open Team
|
||||
|
||||
Ссылка в новой задаче
Block a user