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
@@ -235,7 +235,8 @@ func TestGetGroupsByChannel(t *testing.T) {
|
||||
|
||||
groups, _, err := th.App.GetGroupsByChannel(th.BasicChannel.Id, opts)
|
||||
require.Nil(t, err)
|
||||
require.ElementsMatch(t, []*model.Group{group}, groups)
|
||||
require.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewBool(false)}}, groups)
|
||||
require.NotNil(t, groups[0].SchemeAdmin)
|
||||
|
||||
groups, _, err = th.App.GetGroupsByChannel(model.NewId(), opts)
|
||||
require.Nil(t, err)
|
||||
@@ -261,7 +262,8 @@ func TestGetGroupsByTeam(t *testing.T) {
|
||||
|
||||
groups, _, err := th.App.GetGroupsByTeam(th.BasicTeam.Id, model.GroupSearchOpts{})
|
||||
require.Nil(t, err)
|
||||
require.ElementsMatch(t, []*model.Group{group}, groups)
|
||||
require.ElementsMatch(t, []*model.GroupWithSchemeAdmin{{Group: *group, SchemeAdmin: model.NewBool(false)}}, groups)
|
||||
require.NotNil(t, groups[0].SchemeAdmin)
|
||||
|
||||
groups, _, err = th.App.GetGroupsByTeam(model.NewId(), model.GroupSearchOpts{})
|
||||
require.Nil(t, err)
|
||||
@@ -277,3 +279,55 @@ func TestGetGroups(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
require.ElementsMatch(t, []*model.Group{group}, groups)
|
||||
}
|
||||
|
||||
func TestUserIsInAdminRoleGroup(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
group1 := th.CreateGroup()
|
||||
group2 := th.CreateGroup()
|
||||
|
||||
g, err := th.App.UpsertGroupMember(group1.Id, th.BasicUser.Id)
|
||||
require.Nil(t, err)
|
||||
require.NotNil(t, g)
|
||||
|
||||
g, err = th.App.UpsertGroupMember(group2.Id, th.BasicUser.Id)
|
||||
require.Nil(t, err)
|
||||
require.NotNil(t, g)
|
||||
|
||||
_, err = th.App.UpsertGroupSyncable(&model.GroupSyncable{
|
||||
GroupId: group1.Id,
|
||||
AutoAdd: false,
|
||||
SyncableId: th.BasicTeam.Id,
|
||||
Type: model.GroupSyncableTypeTeam,
|
||||
})
|
||||
require.Nil(t, err)
|
||||
|
||||
groupSyncable2, err := th.App.UpsertGroupSyncable(&model.GroupSyncable{
|
||||
GroupId: group2.Id,
|
||||
AutoAdd: false,
|
||||
SyncableId: th.BasicTeam.Id,
|
||||
Type: model.GroupSyncableTypeTeam,
|
||||
})
|
||||
require.Nil(t, err)
|
||||
|
||||
// no syncables are set to scheme admin true, so this returns false
|
||||
actual, err := th.App.UserIsInAdminRoleGroup(th.BasicUser.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam)
|
||||
require.Nil(t, err)
|
||||
require.False(t, actual)
|
||||
|
||||
// set a syncable to be scheme admins
|
||||
groupSyncable2.SchemeAdmin = true
|
||||
_, err = th.App.UpdateGroupSyncable(groupSyncable2)
|
||||
require.Nil(t, err)
|
||||
|
||||
// a syncable is set to scheme admin true, so this returns true
|
||||
actual, err = th.App.UserIsInAdminRoleGroup(th.BasicUser.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam)
|
||||
require.Nil(t, err)
|
||||
require.True(t, actual)
|
||||
|
||||
// delete the syncable, should be false again
|
||||
th.App.DeleteGroupSyncable(group2.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam)
|
||||
actual, err = th.App.UserIsInAdminRoleGroup(th.BasicUser.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam)
|
||||
require.Nil(t, err)
|
||||
require.False(t, actual)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user