MM-20644: Add users to teams as a SchemeAdmin based on a new configuration field on GroupTeams and GroupChannels records. (#13361)
* MM-20644: Add users to teams as a SchemeAdmin based on a new configuration field on GroupTeams and GroupChannels records. * MM-20644: Adds SchemeAdmin to mapping of the GroupSyncable struct fields. * MM-2064: Adds test to ensure SchemeAdmin field value is mapped. * MM-20644: Adds missing index creation for fresh DBs. * MM-20644: Duplicates UpdateMembersRole across Team and Channel stores. Adds tests. * MM-20644: Fixes some old method name references. * MM-20644: Moves variable declaration; removes Println statement. * MM-20644: Use a SQL query instead of two to update Team and Channel members. * MM-20644: Fixes tests; updates query. * MM-20644: Fix permission check for patching a group syncable. * MM-20644: Fixes test for change of permissions verification in group patch API request. * MM-20644: Fix for ORM select vs insert. * MM-20644: Linting fixes. * MM-20644: Fixes some tests. * MM-20644: Skips changing the role of guests. * MM-20644: Added syncableID filtering
Этот коммит содержится в:
коммит произвёл
catalintomai
родитель
04430041a8
Коммит
605040c597
@@ -1161,3 +1161,55 @@ func TestMarkChannelAsUnreadFromPost(t *testing.T) {
|
||||
assert.Nil(t, response)
|
||||
})
|
||||
}
|
||||
|
||||
func TestAddUserToChannel(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
user1 := model.User{Email: strings.ToLower(model.NewId()) + "success+test@example.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), Password: "passwd1", AuthService: ""}
|
||||
ruser1, _ := th.App.CreateUser(&user1)
|
||||
defer th.App.PermanentDeleteUser(&user1)
|
||||
th.App.AddTeamMember(th.BasicTeam.Id, ruser1.Id)
|
||||
|
||||
group := th.CreateGroup()
|
||||
|
||||
_, err := th.App.UpsertGroupMember(group.Id, user1.Id)
|
||||
require.Nil(t, err)
|
||||
|
||||
gs, err := th.App.UpsertGroupSyncable(&model.GroupSyncable{
|
||||
AutoAdd: true,
|
||||
SyncableId: th.BasicChannel.Id,
|
||||
Type: model.GroupSyncableTypeChannel,
|
||||
GroupId: group.Id,
|
||||
SchemeAdmin: false,
|
||||
})
|
||||
require.Nil(t, err)
|
||||
|
||||
err = th.App.JoinChannel(th.BasicChannel, ruser1.Id)
|
||||
require.Nil(t, err)
|
||||
|
||||
// verify user was added as a non-admin
|
||||
cm1, err := th.App.GetChannelMember(th.BasicChannel.Id, ruser1.Id)
|
||||
require.Nil(t, err)
|
||||
require.False(t, cm1.SchemeAdmin)
|
||||
|
||||
user2 := model.User{Email: strings.ToLower(model.NewId()) + "success+test@example.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), Password: "passwd1", AuthService: ""}
|
||||
ruser2, _ := th.App.CreateUser(&user2)
|
||||
defer th.App.PermanentDeleteUser(&user2)
|
||||
th.App.AddTeamMember(th.BasicTeam.Id, ruser2.Id)
|
||||
|
||||
_, err = th.App.UpsertGroupMember(group.Id, user2.Id)
|
||||
require.Nil(t, err)
|
||||
|
||||
gs.SchemeAdmin = true
|
||||
_, err = th.App.UpdateGroupSyncable(gs)
|
||||
require.Nil(t, err)
|
||||
|
||||
err = th.App.JoinChannel(th.BasicChannel, ruser2.Id)
|
||||
require.Nil(t, err)
|
||||
|
||||
// verify user was added as an admin
|
||||
cm2, err := th.App.GetChannelMember(th.BasicChannel.Id, ruser2.Id)
|
||||
require.Nil(t, err)
|
||||
require.True(t, cm2.SchemeAdmin)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user