Commit 2fbb28cd authored by Mehmet Emin INAC's avatar Mehmet Emin INAC Committed by Stan Hu

Disable access to projects by instance security dashboard

parent 5a1517a5
...@@ -24,6 +24,7 @@ class InstanceSecurityDashboard ...@@ -24,6 +24,7 @@ class InstanceSecurityDashboard
def projects def projects
Project.where(id: visible_users_security_dashboard_projects) Project.where(id: visible_users_security_dashboard_projects)
.with_feature_available_for_user(:security_and_compliance, user)
end end
def vulnerabilities def vulnerabilities
......
...@@ -85,8 +85,24 @@ RSpec.describe InstanceSecurityDashboard do ...@@ -85,8 +85,24 @@ RSpec.describe InstanceSecurityDashboard do
describe '#projects' do describe '#projects' do
context 'when the user cannot read all resources' do context 'when the user cannot read all resources' do
it 'returns only projects on their dashboard that they can read' do context 'when the `security_and_compliance` is enabled for the project' do
expect(subject.projects).to contain_exactly(project1) before do
ProjectFeature.update_all(security_and_compliance_access_level: Featurable::ENABLED)
end
it 'returns only projects on their dashboard that they can read' do
expect(subject.projects).to contain_exactly(project1)
end
end
context 'when the `security_and_compliance` is disabled for the project' do
before do
project1.project_feature.update_column(:security_and_compliance_access_level, Featurable::DISABLED)
end
it 'returns only projects on their dashboard that they can read' do
expect(subject.projects).to be_empty
end
end end
end end
...@@ -94,8 +110,24 @@ RSpec.describe InstanceSecurityDashboard do ...@@ -94,8 +110,24 @@ RSpec.describe InstanceSecurityDashboard do
let(:project_ids) { [project1.id, project2.id] } let(:project_ids) { [project1.id, project2.id] }
let(:user) { create(:auditor) } let(:user) { create(:auditor) }
it "returns all projects on the user's dashboard" do context 'when the `security_and_compliance` is enabled for the project' do
expect(subject.projects).to contain_exactly(project1, project2, project3) before do
ProjectFeature.update_all(security_and_compliance_access_level: Featurable::ENABLED)
end
it "returns all projects on the user's dashboard" do
expect(subject.projects).to contain_exactly(project1, project2, project3)
end
end
context 'when the `security_and_compliance` is disabled for the project' do
before do
project1.project_feature.update_column(:security_and_compliance_access_level, Featurable::DISABLED)
end
it "returns only the feature enabled projects on the user's dashboard" do
expect(subject.projects).to contain_exactly(project2, project3)
end
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