Commit dedad142 authored by Philip Cunningham's avatar Philip Cunningham

Clean up DAST profile not found error handling

- Favours push instead of append
- Removes nil check and defers to ability check
- Removes questionable spec
parent 9bc09614
...@@ -41,8 +41,8 @@ module AppSec ...@@ -41,8 +41,8 @@ module AppSec
profile = yield(name).execute.first profile = yield(name).execute.first
unless profile && can?(current_user, :read_on_demand_scans, profile) unless can?(current_user, :read_on_demand_scans, profile)
errors.append("DAST profile not found: #{name}") errors.push("DAST profile not found: #{name}")
return return
end end
......
...@@ -22,9 +22,7 @@ module EE ...@@ -22,9 +22,7 @@ module EE
override :errors override :errors
def errors def errors
strong_memoize(:errors) do super.concat(dast_configuration.errors)
super.concat(dast_configuration.errors)
end
end end
private private
......
...@@ -3,11 +3,10 @@ ...@@ -3,11 +3,10 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe AppSec::Dast::Profiles::BuildConfigService do RSpec.describe AppSec::Dast::Profiles::BuildConfigService do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project) }
let_it_be(:dast_site_profile) { create(:dast_site_profile, project: project) } let_it_be(:dast_site_profile) { create(:dast_site_profile, project: project) }
let_it_be(:dast_scanner_profile) { create(:dast_scanner_profile, project: project) } let_it_be(:dast_scanner_profile) { create(:dast_scanner_profile, project: project) }
let_it_be(:user) { create(:user, developer_projects: [project] ) } let_it_be(:user) { create(:user, developer_projects: [project]) }
let_it_be(:outsider) { create(:user) }
let(:dast_site_profile_name) { dast_site_profile.name } let(:dast_site_profile_name) { dast_site_profile.name }
let(:dast_scanner_profile_name) { dast_scanner_profile.name } let(:dast_scanner_profile_name) { dast_scanner_profile.name }
...@@ -58,14 +57,8 @@ RSpec.describe AppSec::Dast::Profiles::BuildConfigService do ...@@ -58,14 +57,8 @@ RSpec.describe AppSec::Dast::Profiles::BuildConfigService do
end end
context 'when the profile cannot be read' do context 'when the profile cannot be read' do
let_it_be(:user) { outsider } let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user, developer_projects: [project]) }
before do
allow_next_instance_of(AppSec::Dast::Profiles::BuildConfigService) do |service|
allow(service).to receive(:can?).and_call_original
allow(service).to receive(:can?).with(user, :create_on_demand_dast_scan, project).and_return(true)
end
end
it_behaves_like 'an error occurred' do it_behaves_like 'an error occurred' do
let(:error_message) { "DAST profile not found: #{profile_name}" } let(:error_message) { "DAST profile not found: #{profile_name}" }
......
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