Commit 5148c8c4 authored by Diego Louzán's avatar Diego Louzán

Rename :full_private_access policy ability to :read_all_resources

parent 6fca5c53
...@@ -1454,7 +1454,7 @@ class User < ApplicationRecord ...@@ -1454,7 +1454,7 @@ class User < ApplicationRecord
# Does the user have access to all private groups & projects? # Does the user have access to all private groups & projects?
# Overridden in EE to also check auditor? # Overridden in EE to also check auditor?
def full_private_access? def full_private_access?
can?(:full_private_access) can?(:read_all_resources)
end end
def update_two_factor_requirement def update_two_factor_requirement
......
...@@ -36,11 +36,11 @@ class BasePolicy < DeclarativePolicy::Base ...@@ -36,11 +36,11 @@ class BasePolicy < DeclarativePolicy::Base
::Gitlab::ExternalAuthorization.perform_check? ::Gitlab::ExternalAuthorization.perform_check?
end end
rule { external_authorization_enabled & ~can?(:full_private_access) }.policy do rule { external_authorization_enabled & ~can?(:read_all_resources) }.policy do
prevent :read_cross_project prevent :read_cross_project
end end
rule { admin }.enable :full_private_access rule { admin }.enable :read_all_resources
rule { default }.enable :read_cross_project rule { default }.enable :read_cross_project
end end
......
...@@ -30,5 +30,5 @@ class PersonalSnippetPolicy < BasePolicy ...@@ -30,5 +30,5 @@ class PersonalSnippetPolicy < BasePolicy
rule { can?(:create_note) }.enable :award_emoji rule { can?(:create_note) }.enable :award_emoji
rule { can?(:full_private_access) }.enable :read_personal_snippet rule { can?(:read_all_resources) }.enable :read_personal_snippet
end end
...@@ -28,7 +28,7 @@ class ProjectSnippetPolicy < BasePolicy ...@@ -28,7 +28,7 @@ class ProjectSnippetPolicy < BasePolicy
all?(private_snippet | (internal_snippet & external_user), all?(private_snippet | (internal_snippet & external_user),
~project.guest, ~project.guest,
~is_author, ~is_author,
~can?(:full_private_access)) ~can?(:read_all_resources))
end.prevent :read_project_snippet end.prevent :read_project_snippet
rule { internal_snippet & ~is_author & ~admin }.policy do rule { internal_snippet & ~is_author & ~admin }.policy do
......
...@@ -20,7 +20,7 @@ module EE ...@@ -20,7 +20,7 @@ module EE
with_scope :global with_scope :global
condition(:license_block) { License.block_changes? } condition(:license_block) { License.block_changes? }
rule { auditor }.enable :full_private_access rule { auditor }.enable :read_all_resources
end end
end end
end end
...@@ -144,7 +144,7 @@ describe Issue do ...@@ -144,7 +144,7 @@ describe Issue do
describe 'when a user cannot read cross project' do describe 'when a user cannot read cross project' do
it 'only returns issues within the same project' do it 'only returns issues within the same project' do
expect(Ability).to receive(:allowed?).with(user, :full_private_access, :global).and_call_original expect(Ability).to receive(:allowed?).with(user, :read_all_resources, :global).and_call_original
expect(Ability).to receive(:allowed?).with(user, :read_cross_project).and_return(false) expect(Ability).to receive(:allowed?).with(user, :read_cross_project).and_return(false)
expect(authorized_issue_a.related_issues(user)) expect(authorized_issue_a.related_issues(user))
......
...@@ -21,9 +21,9 @@ describe BasePolicy, :do_not_mock_admin_mode do ...@@ -21,9 +21,9 @@ describe BasePolicy, :do_not_mock_admin_mode do
end end
end end
describe 'full private access' do describe 'read all resources' do
it 'allows auditors' do it 'allows auditors' do
is_expected.to be_allowed(:full_private_access) is_expected.to be_allowed(:read_all_resources)
end end
end end
end end
...@@ -60,7 +60,7 @@ describe BasePolicy, :do_not_mock_admin_mode do ...@@ -60,7 +60,7 @@ describe BasePolicy, :do_not_mock_admin_mode do
subject { described_class.new(current_user, nil) } subject { described_class.new(current_user, nil) }
it { is_expected.not_to be_allowed(:full_private_access) } it { is_expected.not_to be_allowed(:read_all_resources) }
context 'for admins' do context 'for admins' do
let(:current_user) { build(:admin) } let(:current_user) { build(:admin) }
...@@ -68,11 +68,11 @@ describe BasePolicy, :do_not_mock_admin_mode do ...@@ -68,11 +68,11 @@ describe BasePolicy, :do_not_mock_admin_mode do
it 'allowed when in admin mode' do it 'allowed when in admin mode' do
enable_admin_mode!(current_user) enable_admin_mode!(current_user)
is_expected.to be_allowed(:full_private_access) is_expected.to be_allowed(:read_all_resources)
end end
it 'prevented when not in admin mode' do it 'prevented when not in admin mode' do
is_expected.not_to be_allowed(:full_private_access) is_expected.not_to be_allowed(:read_all_resources)
end end
end 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