Commit 2ca4981a authored by Pedro Pombeiro's avatar Pedro Pombeiro

Add read_group_runners permissions

Replaces admin_group usage
parent 4328f801
...@@ -47,7 +47,7 @@ module Ci ...@@ -47,7 +47,7 @@ module Ci
end end
def group_runners def group_runners
raise Gitlab::Access::AccessDeniedError unless can?(@current_user, :admin_group, @group) raise Gitlab::Access::AccessDeniedError unless can?(@current_user, :read_group_runners, @group)
@runners = case @params[:membership] @runners = case @params[:membership]
when :direct when :direct
......
...@@ -180,6 +180,8 @@ class GroupPolicy < Namespaces::GroupProjectNamespaceSharedPolicy ...@@ -180,6 +180,8 @@ class GroupPolicy < Namespaces::GroupProjectNamespaceSharedPolicy
enable :admin_group_member enable :admin_group_member
enable :change_visibility_level enable :change_visibility_level
enable :read_group_runners
enable :set_note_created_at enable :set_note_created_at
enable :set_emails_disabled enable :set_emails_disabled
enable :change_prevent_sharing_groups_outside_hierarchy enable :change_prevent_sharing_groups_outside_hierarchy
......
...@@ -34,10 +34,8 @@ module Sidebars ...@@ -34,10 +34,8 @@ module Sidebars
) )
end end
# TODO Proper policies, such as `read_group_runners`, should be implemented per
# See https://gitlab.com/gitlab-org/gitlab/-/issues/334802
def show_runners? def show_runners?
can?(context.current_user, :admin_group, context.group) && can?(context.current_user, :read_group_runners, context.group) &&
Feature.enabled?(:runner_list_group_view_vue_ui, context.group, default_enabled: :yaml) Feature.enabled?(:runner_list_group_view_vue_ui, context.group, default_enabled: :yaml)
end end
end end
......
...@@ -36,6 +36,7 @@ RSpec.describe GroupPolicy do ...@@ -36,6 +36,7 @@ RSpec.describe GroupPolicy do
it { expect_disallowed(:read_crm_organization) } it { expect_disallowed(:read_crm_organization) }
it { expect_disallowed(:read_crm_contact) } it { expect_disallowed(:read_crm_contact) }
it { expect_disallowed(:read_counts) } it { expect_disallowed(:read_counts) }
it { expect_disallowed(:read_group_runners) }
it { expect_disallowed(*read_group_permissions) } it { expect_disallowed(*read_group_permissions) }
end end
...@@ -51,6 +52,7 @@ RSpec.describe GroupPolicy do ...@@ -51,6 +52,7 @@ RSpec.describe GroupPolicy do
it { expect_disallowed(:read_crm_organization) } it { expect_disallowed(:read_crm_organization) }
it { expect_disallowed(:read_crm_contact) } it { expect_disallowed(:read_crm_contact) }
it { expect_disallowed(:read_counts) } it { expect_disallowed(:read_counts) }
it { expect_disallowed(:read_group_runners) }
it { expect_disallowed(*read_group_permissions) } it { expect_disallowed(*read_group_permissions) }
end end
......
...@@ -53,17 +53,18 @@ RSpec.shared_context 'GroupPolicy context' do ...@@ -53,17 +53,18 @@ RSpec.shared_context 'GroupPolicy context' do
end end
let(:owner_permissions) do let(:owner_permissions) do
[ %i[
:owner_access, owner_access
:admin_group, admin_group
:admin_namespace, admin_namespace
:admin_group_member, admin_group_member
:change_visibility_level, change_visibility_level
:set_note_created_at, set_note_created_at
:create_subgroup, create_subgroup
:read_statistics, read_statistics
:update_default_branch_protection update_default_branch_protection
].compact read_group_runners
]
end end
let(:admin_permissions) { %i[read_confidential_issues] } let(:admin_permissions) { %i[read_confidential_issues] }
......
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