Skip to content
代码片段 群组 项目
未验证 提交 7b440ce1 编辑于 作者: Huzaifa Iftikhar's avatar Huzaifa Iftikhar 提交者: GitLab
浏览文件

Merge branch '144638-mask-group-detail-from-non-owners' into 'master'

Hide invited group name and source from project/group non-admins

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/147629



Merged-by: default avatarHuzaifa Iftikhar <hiftikhar@gitlab.com>
Approved-by: default avatarJarka Košanová <jarka@gitlab.com>
Approved-by: default avatarHuzaifa Iftikhar <hiftikhar@gitlab.com>
Co-authored-by: default avatarAbdul Wadood <awadood@gitlab.com>
No related branches found
No related tags found
无相关合并请求
......@@ -2,7 +2,7 @@
class GroupGroupLinkPolicy < ::BasePolicy # rubocop:disable Gitlab/NamespacedClass
condition(:can_read_shared_with_group) { can?(:read_group, @subject.shared_with_group) }
condition(:group_member) { @subject.shared_group.member?(@user) }
condition(:group_admin) { can?(:admin_group, @subject.shared_group) }
rule { can_read_shared_with_group | group_member }.enable :read_shared_with_group
rule { can_read_shared_with_group | group_admin }.enable :read_shared_with_group
end
......@@ -4,7 +4,6 @@ class ProjectGroupLinkPolicy < BasePolicy # rubocop:disable Gitlab/NamespacedCla
condition(:group_owner) { group_owner? }
condition(:group_owner_or_project_admin) { group_owner? || project_admin? }
condition(:can_read_group) { can?(:read_group, @subject.group) }
condition(:project_member) { @subject.project.member?(@user) }
condition(:can_manage_owners) { can_manage_owners? }
condition(:can_manage_group_link_with_owner_access) do
next true unless @subject.owner_access?
......@@ -26,7 +25,7 @@ class ProjectGroupLinkPolicy < BasePolicy # rubocop:disable Gitlab/NamespacedCla
enable :destroy_project_group_link
end
rule { can_read_group | project_member }.enable :read_shared_with_group
rule { can_read_group | group_owner_or_project_admin }.enable :read_shared_with_group
private
......
......@@ -15,12 +15,24 @@
describe 'read_shared_with_group' do
context 'when the user is a shared_group member' do
before_all do
group.add_guest(user)
context 'when the user is not a shared_group owner' do
before_all do
group.add_maintainer(user)
end
it 'cannot read_shared_with_group' do
expect(policy).to be_disallowed(:read_shared_with_group)
end
end
it 'can read_shared_with_group' do
expect(policy).to be_allowed(:read_shared_with_group)
context 'when the user is a shared_group owner' do
before_all do
group.add_owner(user)
end
it 'can read_shared_with_group' do
expect(policy).to be_allowed(:read_shared_with_group)
end
end
end
......
......@@ -129,12 +129,24 @@
end
context 'when the user is a project member' do
before_all do
project.add_guest(user)
context 'when the user is not a project admin' do
before_all do
project.add_guest(user)
end
it 'cannot read_shared_with_group' do
expect(policy).to be_disallowed(:read_shared_with_group)
end
end
it 'can read_shared_with_group' do
expect(policy).to be_allowed(:read_shared_with_group)
context 'when the user is a project admin' do
before_all do
project.add_maintainer(user)
end
it 'can read_shared_with_group' do
expect(policy).to be_allowed(:read_shared_with_group)
end
end
end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册