Commit a8b42a82 authored by peterhegman's avatar peterhegman

Add multiple filters support to group members

Previously inherited/direct and two factor filters could not be
combined. This adds support for combining those two filters
parent e3f99409
...@@ -21,7 +21,7 @@ class GroupMembersFinder < UnionFinder ...@@ -21,7 +21,7 @@ class GroupMembersFinder < UnionFinder
group_members = group_members_list group_members = group_members_list
relations = [] 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) 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 ...@@ -129,4 +129,48 @@ RSpec.describe GroupMembersFinder, '#execute' do
expect(result.to_a).not_to include(member_with_2fa) expect(result.to_a).not_to include(member_with_2fa)
expect(result.to_a).to match_array([member1, member2]) expect(result.to_a).to match_array([member1, member2])
end 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 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