diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-13 15:07:53 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-13 15:07:53 +0000 |
commit | a5ab3467a705b62911feacc3cf627fdbb00aa198 (patch) | |
tree | 65143ce13405efccb922fc428624ad57c38b6efa /spec/finders | |
parent | eb30dd6e28f6fc9eb8021d205f6ed84511f001e2 (diff) | |
download | gitlab-ce-a5ab3467a705b62911feacc3cf627fdbb00aa198.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/finders')
-rw-r--r-- | spec/finders/group_members_finder_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/finders/group_members_finder_spec.rb b/spec/finders/group_members_finder_spec.rb index f161a1df9c3..5636b5db84f 100644 --- a/spec/finders/group_members_finder_spec.rb +++ b/spec/finders/group_members_finder_spec.rb @@ -10,6 +10,7 @@ describe GroupMembersFinder, '#execute' do let(:user2) { create(:user) } let(:user3) { create(:user) } let(:user4) { create(:user) } + let(:user5) { create(:user, :two_factor_via_otp) } it 'returns members for top-level group' do member1 = group.add_maintainer(user1) @@ -67,4 +68,43 @@ describe GroupMembersFinder, '#execute' do expect(result.to_a).to match_array([member1, member2, member3, member4]) end + + it 'returns searched members if requested' do + group.add_maintainer(user2) + nested_group.add_maintainer(user2) + nested_group.add_maintainer(user3) + nested_group.add_maintainer(user4) + member = group.add_maintainer(user1) + + result = described_class.new(group).execute(include_relations: [:direct, :descendants], params: { search: user1.name }) + + expect(result.to_a).to match_array([member]) + end + + it 'returns members with two-factor auth if requested by owner' do + group.add_owner(user2) + group.add_maintainer(user1) + nested_group.add_maintainer(user2) + nested_group.add_maintainer(user3) + nested_group.add_maintainer(user4) + member = group.add_maintainer(user5) + + result = described_class.new(group, user2).execute(include_relations: [:direct, :descendants], params: { two_factor: 'enabled' }) + + expect(result.to_a).to contain_exactly(member) + end + + it 'returns members without two-factor auth if requested by owner' do + member1 = group.add_owner(user2) + member2 = group.add_maintainer(user1) + nested_group.add_maintainer(user2) + member3 = nested_group.add_maintainer(user3) + member4 = nested_group.add_maintainer(user4) + member_with_2fa = group.add_maintainer(user5) + + result = described_class.new(group, user2).execute(include_relations: [:direct, :descendants], params: { two_factor: 'disabled' }) + + expect(result.to_a).not_to include(member_with_2fa) + expect(result.to_a).to match_array([member1, member2, member3, member4]) + end end |