MM-9730 & MM-9729: Missing Server PRs (#8908)
* MM-9730: API endpoint to update scheme-derived roles of TeamMembers. * MM-9729: API to update scheme-derived roles of ChannelMembers.
Этот коммит содержится в:
коммит произвёл
Martin Kraft
родитель
2c75247c97
Коммит
0c4078b6b0
@@ -15,6 +15,7 @@ import (
|
||||
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCreateChannel(t *testing.T) {
|
||||
@@ -1537,6 +1538,81 @@ func TestUpdateChannelRoles(t *testing.T) {
|
||||
CheckForbiddenStatus(t, resp)
|
||||
}
|
||||
|
||||
func TestUpdateChannelMemberSchemeRoles(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
SystemAdminClient := th.SystemAdminClient
|
||||
th.LoginBasic()
|
||||
|
||||
s1 := &model.SchemeRoles{
|
||||
SchemeAdmin: false,
|
||||
SchemeUser: false,
|
||||
}
|
||||
_, r1 := SystemAdminClient.UpdateChannelMemberSchemeRoles(th.BasicChannel.Id, th.BasicUser.Id, s1)
|
||||
CheckNoError(t, r1)
|
||||
|
||||
tm1, rtm1 := SystemAdminClient.GetChannelMember(th.BasicChannel.Id, th.BasicUser.Id, "")
|
||||
CheckNoError(t, rtm1)
|
||||
assert.Equal(t, false, tm1.SchemeUser)
|
||||
assert.Equal(t, false, tm1.SchemeAdmin)
|
||||
|
||||
s2 := &model.SchemeRoles{
|
||||
SchemeAdmin: false,
|
||||
SchemeUser: true,
|
||||
}
|
||||
_, r2 := SystemAdminClient.UpdateChannelMemberSchemeRoles(th.BasicChannel.Id, th.BasicUser.Id, s2)
|
||||
CheckNoError(t, r2)
|
||||
|
||||
tm2, rtm2 := SystemAdminClient.GetChannelMember(th.BasicChannel.Id, th.BasicUser.Id, "")
|
||||
CheckNoError(t, rtm2)
|
||||
assert.Equal(t, true, tm2.SchemeUser)
|
||||
assert.Equal(t, false, tm2.SchemeAdmin)
|
||||
|
||||
s3 := &model.SchemeRoles{
|
||||
SchemeAdmin: true,
|
||||
SchemeUser: false,
|
||||
}
|
||||
_, r3 := SystemAdminClient.UpdateChannelMemberSchemeRoles(th.BasicChannel.Id, th.BasicUser.Id, s3)
|
||||
CheckNoError(t, r3)
|
||||
|
||||
tm3, rtm3 := SystemAdminClient.GetChannelMember(th.BasicChannel.Id, th.BasicUser.Id, "")
|
||||
CheckNoError(t, rtm3)
|
||||
assert.Equal(t, false, tm3.SchemeUser)
|
||||
assert.Equal(t, true, tm3.SchemeAdmin)
|
||||
|
||||
s4 := &model.SchemeRoles{
|
||||
SchemeAdmin: true,
|
||||
SchemeUser: true,
|
||||
}
|
||||
_, r4 := SystemAdminClient.UpdateChannelMemberSchemeRoles(th.BasicChannel.Id, th.BasicUser.Id, s4)
|
||||
CheckNoError(t, r4)
|
||||
|
||||
tm4, rtm4 := SystemAdminClient.GetChannelMember(th.BasicChannel.Id, th.BasicUser.Id, "")
|
||||
CheckNoError(t, rtm4)
|
||||
assert.Equal(t, true, tm4.SchemeUser)
|
||||
assert.Equal(t, true, tm4.SchemeAdmin)
|
||||
|
||||
_, resp := SystemAdminClient.UpdateChannelMemberSchemeRoles(model.NewId(), th.BasicUser.Id, s4)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
_, resp = SystemAdminClient.UpdateChannelMemberSchemeRoles(th.BasicChannel.Id, model.NewId(), s4)
|
||||
CheckNotFoundStatus(t, resp)
|
||||
|
||||
_, resp = SystemAdminClient.UpdateChannelMemberSchemeRoles("ASDF", th.BasicUser.Id, s4)
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
_, resp = SystemAdminClient.UpdateChannelMemberSchemeRoles(th.BasicChannel.Id, "ASDF", s4)
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
th.LoginBasic2()
|
||||
_, resp = th.Client.UpdateChannelMemberSchemeRoles(th.BasicChannel.Id, th.BasicUser.Id, s4)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
SystemAdminClient.Logout()
|
||||
_, resp = SystemAdminClient.UpdateChannelMemberSchemeRoles(th.BasicChannel.Id, th.SystemAdminUser.Id, s4)
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
}
|
||||
|
||||
func TestUpdateChannelNotifyProps(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Ссылка в новой задаче
Block a user