Add parameter to return group members in order of display name (#21775)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
fae9bdf173
Коммит
33b59e0e96
@@ -2837,6 +2837,64 @@ func TestGetUsersInGroup(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestGetUsersInGroupByDisplayName(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
id := model.NewId()
|
||||
group, appErr := th.App.CreateGroup(&model.Group{
|
||||
DisplayName: "dn-foo_" + id,
|
||||
Name: model.NewString("name" + id),
|
||||
Source: model.GroupSourceLdap,
|
||||
Description: "description_" + id,
|
||||
RemoteId: model.NewString(model.NewId()),
|
||||
})
|
||||
assert.Nil(t, appErr)
|
||||
|
||||
user1, err := th.App.CreateUser(th.Context, &model.User{Email: th.GenerateTestEmail(), Nickname: "aaa", Password: "test-password-1", Username: "zzz", Roles: model.SystemUserRoleId})
|
||||
assert.Nil(t, err)
|
||||
|
||||
user2, err := th.App.CreateUser(th.Context, &model.User{Email: th.GenerateTestEmail(), Password: "test-password-2", Username: "bbb", Roles: model.SystemUserRoleId})
|
||||
assert.Nil(t, err)
|
||||
|
||||
_, err = th.App.UpsertGroupMember(group.Id, user1.Id)
|
||||
assert.Nil(t, err)
|
||||
_, err = th.App.UpsertGroupMember(group.Id, user2.Id)
|
||||
assert.Nil(t, err)
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional))
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.PrivacySettings.ShowFullName = true
|
||||
})
|
||||
|
||||
preference := model.Preference{
|
||||
UserId: th.SystemAdminUser.Id,
|
||||
Category: model.PreferenceCategoryDisplaySettings,
|
||||
Name: model.PreferenceNameNameFormat,
|
||||
Value: model.ShowUsername,
|
||||
}
|
||||
|
||||
err = th.App.UpdatePreferences(th.SystemAdminUser.Id, model.Preferences{preference})
|
||||
assert.Nil(t, err)
|
||||
|
||||
t.Run("Returns users in group in right order for username", func(t *testing.T) {
|
||||
users, _, err := th.SystemAdminClient.GetUsersInGroupByDisplayName(group.Id, 0, 1, "")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, users[0].Id, user2.Id)
|
||||
})
|
||||
|
||||
preference.Value = model.ShowNicknameFullName
|
||||
err = th.App.UpdatePreferences(th.SystemAdminUser.Id, model.Preferences{preference})
|
||||
assert.Nil(t, err)
|
||||
|
||||
t.Run("Returns users in group in right order for nickname", func(t *testing.T) {
|
||||
users, _, err := th.SystemAdminClient.GetUsersInGroupByDisplayName(group.Id, 0, 1, "")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, users[0].Id, user1.Id)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func TestUpdateUserMfa(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Ссылка в новой задаче
Block a user