Commit ae38614c authored by Dominic Bauer's avatar Dominic Bauer Committed by Vasilii Iakliushin

Test scanner creation

Changelog: fixed
EE: true
parent d74aea9c
......@@ -94,9 +94,8 @@ module Vulnerabilities
def initialize_scanner(scanner_hash)
name = scanner_hash[:name]
Vulnerabilities::Scanner.find_or_initialize_by(name: name) do |s|
s.project = @project
s.external_id = scanner_hash[:id]
Vulnerabilities::Scanner.find_or_initialize_by(project: @project, external_id: scanner_hash[:id]) do |s|
s.name = name
s.vendor = scanner_hash.dig(:vendor, :name)
end
end
......
......@@ -93,6 +93,20 @@ RSpec.describe Vulnerabilities::StarboardVulnerabilityCreateService do
expect(scanner.name).to eq(params.dig(:scanner, :name))
expect(scanner.vendor).to eq(params.dig(:scanner, :vendor, :name))
end
context 'when there is a scanner for a different project' do
let(:other_scanner) { create(:vulnerabilities_scanner, external_id: params.dig(:scanner, :id)) }
it "does not reuse another project's scanner" do
subject
expect(vulnerability.finding.scanner).not_to eq(other_scanner)
end
it 'creates a new scanner' do
expect { subject }.to change { Vulnerabilities::Scanner.count }.by(1)
end
end
end
context 'with feature disabled' 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