Commit 733a4bdd authored by Dheeraj Joshi's avatar Dheeraj Joshi Committed by Kerri Miller

Fix disabling options in scanner profile

This should fix updating DAST scanner profile
with false values
parent 6285814e
......@@ -16,8 +16,8 @@ module DastScannerProfiles
spider_timeout: spider_timeout
}
update_args[:scan_type] = scan_type if scan_type
update_args[:use_ajax_spider] = use_ajax_spider if use_ajax_spider
update_args[:show_debug_messages] = show_debug_messages if show_debug_messages
update_args[:use_ajax_spider] = use_ajax_spider unless use_ajax_spider.nil?
update_args[:show_debug_messages] = show_debug_messages unless show_debug_messages.nil?
if dast_scanner_profile.update(update_args)
ServiceResponse.success(payload: dast_scanner_profile)
......
---
title: Fix disabling options in scanner profile
merge_request: 44937
author:
type: fixed
......@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe DastScannerProfiles::UpdateService do
let_it_be(:user) { create(:user) }
let_it_be(:dast_scanner_profile, reload: true) { create(:dast_scanner_profile, target_timeout: 200, spider_timeout: 5000) }
let_it_be(:dast_scanner_profile_2, reload: true) { create(:dast_scanner_profile, target_timeout: 200, spider_timeout: 5000) }
let_it_be(:dast_scanner_profile_2, reload: true) { create(:dast_scanner_profile) }
let(:project) { dast_scanner_profile.project }
let(:project_2) { dast_scanner_profile_2.project }
......@@ -13,8 +13,8 @@ RSpec.describe DastScannerProfiles::UpdateService do
let_it_be(:new_target_timeout) { dast_scanner_profile.target_timeout + 1 }
let_it_be(:new_spider_timeout) { dast_scanner_profile.spider_timeout + 1 }
let_it_be(:new_scan_type) { (DastScannerProfile.scan_types.keys - [DastScannerProfile.last.scan_type]).first }
let_it_be(:new_use_ajax_spider) { !dast_scanner_profile.use_ajax_spider }
let_it_be(:new_show_debug_messages) { !dast_scanner_profile.show_debug_messages }
let(:new_use_ajax_spider) { !dast_scanner_profile.use_ajax_spider }
let(:new_show_debug_messages) { !dast_scanner_profile.show_debug_messages }
before do
stub_licensed_features(security_on_demand_scans: true)
......@@ -118,6 +118,21 @@ RSpec.describe DastScannerProfiles::UpdateService do
end
end
context 'when setting properties to false' do
let_it_be(:dast_scanner_profile, reload: true) { create(:dast_scanner_profile, target_timeout: 200, spider_timeout: 5000, use_ajax_spider: true, show_debug_messages: true) }
let(:new_use_ajax_spider) { false }
let(:new_show_debug_messages) { false }
it 'updates the dast_scanner_profile' do
updated_dast_scanner_profile = payload.reload
aggregate_failures do
expect(updated_dast_scanner_profile.use_ajax_spider).to eq(new_use_ajax_spider)
expect(updated_dast_scanner_profile.show_debug_messages).to eq(new_show_debug_messages)
end
end
end
it 'returns a dast_scanner_profile payload' do
expect(payload).to be_a(DastScannerProfile)
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