Commit aa65354d authored by Pedro Pombeiro's avatar Pedro Pombeiro

Make admin/register runners only available to owners

parent 9edc206e
...@@ -162,8 +162,6 @@ class GroupPolicy < Namespaces::GroupProjectNamespaceSharedPolicy ...@@ -162,8 +162,6 @@ class GroupPolicy < Namespaces::GroupProjectNamespaceSharedPolicy
enable :destroy_package enable :destroy_package
enable :create_projects enable :create_projects
enable :admin_pipeline enable :admin_pipeline
enable :admin_group_runners
enable :register_group_runners
enable :admin_build enable :admin_build
enable :read_cluster enable :read_cluster
enable :add_cluster enable :add_cluster
...@@ -182,6 +180,8 @@ class GroupPolicy < Namespaces::GroupProjectNamespaceSharedPolicy ...@@ -182,6 +180,8 @@ class GroupPolicy < Namespaces::GroupProjectNamespaceSharedPolicy
enable :change_visibility_level enable :change_visibility_level
enable :read_group_runners enable :read_group_runners
enable :admin_group_runners
enable :register_group_runners
enable :set_note_created_at enable :set_note_created_at
enable :set_emails_disabled enable :set_emails_disabled
......
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
- if can?(current_user, :admin_group_runners, @project.group) - if can?(current_user, :admin_group_runners, @project.group)
- group_link = link_to _("group's CI/CD settings."), group_settings_ci_cd_path(@project.group) - group_link = link_to _("group's CI/CD settings."), group_settings_ci_cd_path(@project.group)
= _('Group maintainers can register group runners in the %{link}').html_safe % { link: group_link } = _('Group owners can register group runners in the %{link}').html_safe % { link: group_link }
- else - else
= _('Ask your group maintainer to set up a group runner.') = _('Ask your group owner to set up a group runner.')
- else - else
%h4.underlined-title %h4.underlined-title
......
...@@ -4796,7 +4796,7 @@ msgstr "" ...@@ -4796,7 +4796,7 @@ msgstr ""
msgid "Ask someone with write access to resolve it." msgid "Ask someone with write access to resolve it."
msgstr "" msgstr ""
msgid "Ask your group maintainer to set up a group runner." msgid "Ask your group owner to set up a group runner."
msgstr "" msgstr ""
msgid "Assertion consumer service URL" msgid "Assertion consumer service URL"
...@@ -16721,9 +16721,6 @@ msgstr "" ...@@ -16721,9 +16721,6 @@ msgstr ""
msgid "Group jobs by" msgid "Group jobs by"
msgstr "" msgstr ""
msgid "Group maintainers can register group runners in the %{link}"
msgstr ""
msgid "Group members" msgid "Group members"
msgstr "" msgstr ""
...@@ -16748,6 +16745,9 @@ msgstr "" ...@@ -16748,6 +16745,9 @@ msgstr ""
msgid "Group overview content" msgid "Group overview content"
msgstr "" msgstr ""
msgid "Group owners can register group runners in the %{link}"
msgstr ""
msgid "Group path is already taken. We've suggested one that is available." msgid "Group path is already taken. We've suggested one that is available."
msgstr "" msgstr ""
......
...@@ -268,10 +268,27 @@ RSpec.describe 'Runners' do ...@@ -268,10 +268,27 @@ RSpec.describe 'Runners' do
it 'group runners are not available' do it 'group runners are not available' do
visit project_runners_path(project) visit project_runners_path(project)
expect(page).not_to have_content 'Group owners can register group runners in the group\'s CI/CD settings.'
expect(page).to have_content 'Ask your group owner to set up a group runner'
end
end
end
context 'as project maintainer and group owner' do
before do
group.add_owner(user)
end
context 'project with a group but no group runner' do
let(:project) { create :project, group: group }
it 'group runners are available' do
visit project_runners_path(project)
expect(page).to have_content 'This group does not have any group runners yet.' expect(page).to have_content 'This group does not have any group runners yet.'
expect(page).to have_content 'Group maintainers can register group runners in the group\'s CI/CD settings.' expect(page).to have_content 'Group owners can register group runners in the group\'s CI/CD settings.'
expect(page).not_to have_content 'Ask your group maintainer to set up a group runner' expect(page).not_to have_content 'Ask your group owner to set up a group runner'
end end
end end
end end
...@@ -296,8 +313,8 @@ RSpec.describe 'Runners' do ...@@ -296,8 +313,8 @@ RSpec.describe 'Runners' do
expect(page).to have_content 'This group does not have any group runners yet.' expect(page).to have_content 'This group does not have any group runners yet.'
expect(page).not_to have_content 'Group maintainers can register group runners in the group\'s CI/CD settings.' expect(page).not_to have_content 'Group owners can register group runners in the group\'s CI/CD settings.'
expect(page).to have_content 'Ask your group maintainer to set up a group runner.' expect(page).to have_content 'Ask your group owner to set up a group runner.'
end end
end end
......
...@@ -1085,9 +1085,7 @@ RSpec.describe GroupPolicy do ...@@ -1085,9 +1085,7 @@ RSpec.describe GroupPolicy do
context 'with maintainer' do context 'with maintainer' do
let(:current_user) { maintainer } let(:current_user) { maintainer }
it { is_expected.to be_allowed(:register_group_runners) } it { is_expected.to be_disallowed(:register_group_runners) }
it_behaves_like 'expected outcome based on runner registration control'
end end
context 'with reporter' do context 'with reporter' do
......
...@@ -48,7 +48,6 @@ RSpec.shared_context 'GroupPolicy context' do ...@@ -48,7 +48,6 @@ RSpec.shared_context 'GroupPolicy context' do
destroy_package destroy_package
create_projects create_projects
read_cluster create_cluster update_cluster admin_cluster add_cluster read_cluster create_cluster update_cluster admin_cluster add_cluster
admin_group_runners
] ]
end end
...@@ -64,6 +63,8 @@ RSpec.shared_context 'GroupPolicy context' do ...@@ -64,6 +63,8 @@ RSpec.shared_context 'GroupPolicy context' do
read_statistics read_statistics
update_default_branch_protection update_default_branch_protection
read_group_runners read_group_runners
admin_group_runners
register_group_runners
] ]
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