Commit 87d6abca authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'dblessing-auditor-project-access' into 'master'

Allow auditor user to access project private features

See merge request gitlab-org/gitlab!34794
parents cd0f9aa5 c465d977
...@@ -650,7 +650,7 @@ class ProjectPolicy < BasePolicy ...@@ -650,7 +650,7 @@ class ProjectPolicy < BasePolicy
when ProjectFeature::DISABLED when ProjectFeature::DISABLED
false false
when ProjectFeature::PRIVATE when ProjectFeature::PRIVATE
admin? || team_access_level >= ProjectFeature.required_minimum_access_level(feature) can?(:read_all_resources) || team_access_level >= ProjectFeature.required_minimum_access_level(feature)
else else
true true
end end
......
---
title: Allow auditor user to access project private features
merge_request: 34794
author:
type: fixed
...@@ -98,6 +98,10 @@ RSpec.describe ProjectPolicy do ...@@ -98,6 +98,10 @@ RSpec.describe ProjectPolicy do
is_expected.to be_allowed(*auditor_permissions) is_expected.to be_allowed(*auditor_permissions)
end end
end end
it_behaves_like 'project private features with read_all_resources ability' do
let(:user) { current_user }
end
end end
end end
......
...@@ -41,6 +41,28 @@ RSpec.shared_examples 'archived project policies' do ...@@ -41,6 +41,28 @@ RSpec.shared_examples 'archived project policies' do
end end
end end
RSpec.shared_examples 'project private features with read_all_resources ability' do
subject { described_class.new(user, project) }
before do
project.project_feature.update!(
repository_access_level: ProjectFeature::PRIVATE,
merge_requests_access_level: ProjectFeature::PRIVATE,
builds_access_level: ProjectFeature::PRIVATE
)
end
[:public, :internal, :private].each do |visibility|
context "for #{visibility} projects" do
let(:project) { create(:project, visibility, namespace: owner.namespace) }
it 'allows the download_code ability' do
expect_allowed(:download_code)
end
end
end
end
RSpec.shared_examples 'project policies as anonymous' do RSpec.shared_examples 'project policies as anonymous' do
context 'abilities for public projects' do context 'abilities for public projects' do
context 'when a project has pending invites' do context 'when a project has pending invites' do
...@@ -231,6 +253,12 @@ RSpec.shared_examples 'project policies as admin with admin mode' do ...@@ -231,6 +253,12 @@ RSpec.shared_examples 'project policies as admin with admin mode' do
let(:regular_abilities) { owner_permissions } let(:regular_abilities) { owner_permissions }
end end
end end
context 'abilities for all project visibility', :enable_admin_mode do
it_behaves_like 'project private features with read_all_resources ability' do
let(:user) { admin }
end
end
end end
RSpec.shared_examples 'project policies as admin without admin mode' do RSpec.shared_examples 'project policies as admin without admin mode' do
......
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