Commit 92fc6729 authored by Sean McGivern's avatar Sean McGivern

Merge branch...

Merge branch '228675-separate-filtering-users-from-sorting-users-support-multiple-filters' into 'master'

Add support for mixing direct member filter with 2FA filter

See merge request gitlab-org/gitlab!48084
parents 1cbdc9e6 a8b42a82
......@@ -21,7 +21,7 @@ class GroupMembersFinder < UnionFinder
group_members = group_members_list
relations = []
return group_members if include_relations == [:direct]
return filter_members(group_members) if include_relations == [:direct]
relations << group_members if include_relations.include?(:direct)
......
---
title: Add support for filtering direct group members by 2FA enabled/disabled
merge_request: 48084
author:
type: changed
......@@ -129,4 +129,48 @@ RSpec.describe GroupMembersFinder, '#execute' do
expect(result.to_a).not_to include(member_with_2fa)
expect(result.to_a).to match_array([member1, member2])
end
it 'returns direct members with two-factor auth if requested by owner' do
group.add_owner(user1)
group.add_maintainer(user2)
nested_group.add_maintainer(user3)
member_with_2fa = nested_group.add_maintainer(user5)
result = described_class.new(nested_group, user1, params: { two_factor: 'enabled' }).execute(include_relations: [:direct])
expect(result.to_a).to match_array([member_with_2fa])
end
it 'returns inherited members with two-factor auth if requested by owner' do
group.add_owner(user1)
member_with_2fa = group.add_maintainer(user5)
nested_group.add_maintainer(user2)
nested_group.add_maintainer(user3)
result = described_class.new(nested_group, user1, params: { two_factor: 'enabled' }).execute(include_relations: [:inherited])
expect(result.to_a).to match_array([member_with_2fa])
end
it 'returns direct members without two-factor auth if requested by owner' do
group.add_owner(user1)
group.add_maintainer(user2)
member3 = nested_group.add_maintainer(user3)
nested_group.add_maintainer(user5)
result = described_class.new(nested_group, user1, params: { two_factor: 'disabled' }).execute(include_relations: [:direct])
expect(result.to_a).to match_array([member3])
end
it 'returns inherited members without two-factor auth if requested by owner' do
member1 = group.add_owner(user1)
group.add_maintainer(user5)
nested_group.add_maintainer(user2)
nested_group.add_maintainer(user3)
result = described_class.new(nested_group, user1, params: { two_factor: 'disabled' }).execute(include_relations: [:inherited])
expect(result.to_a).to match_array([member1])
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment