summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/ci/reports/security/finding_key_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/ci/reports/security/finding_key_spec.rb')
-rw-r--r--spec/lib/gitlab/ci/reports/security/finding_key_spec.rb61
1 files changed, 36 insertions, 25 deletions
diff --git a/spec/lib/gitlab/ci/reports/security/finding_key_spec.rb b/spec/lib/gitlab/ci/reports/security/finding_key_spec.rb
index 784c1183320..2320f011cf5 100644
--- a/spec/lib/gitlab/ci/reports/security/finding_key_spec.rb
+++ b/spec/lib/gitlab/ci/reports/security/finding_key_spec.rb
@@ -6,36 +6,47 @@ RSpec.describe Gitlab::Ci::Reports::Security::FindingKey do
using RSpec::Parameterized::TableSyntax
describe '#==' do
- where(:location_fp_1, :location_fp_2, :identifier_fp_1, :identifier_fp_2, :equals?) do
- nil | 'different location fp' | 'identifier fp' | 'different identifier fp' | false
- 'location fp' | nil | 'identifier fp' | 'different identifier fp' | false
- 'location fp' | 'different location fp' | nil | 'different identifier fp' | false
- 'location fp' | 'different location fp' | 'identifier fp' | nil | false
- nil | nil | 'identifier fp' | 'identifier fp' | false
- 'location fp' | 'location fp' | nil | nil | false
- nil | nil | nil | nil | false
- 'location fp' | 'different location fp' | 'identifier fp' | 'different identifier fp' | false
- 'location fp' | 'different location fp' | 'identifier fp' | 'identifier fp' | false
- 'location fp' | 'location fp' | 'identifier fp' | 'different identifier fp' | false
- 'location fp' | 'location fp' | 'identifier fp' | 'identifier fp' | true
- end
-
- with_them do
- let(:finding_key_1) do
- build(:ci_reports_security_finding_key,
- location_fingerprint: location_fp_1,
- identifier_fingerprint: identifier_fp_1)
+ context 'when the comparison is done between FindingKey instances' do
+ where(:location_fp_1, :location_fp_2, :identifier_fp_1, :identifier_fp_2, :equals?) do
+ nil | 'different location fp' | 'identifier fp' | 'different identifier fp' | false
+ 'location fp' | nil | 'identifier fp' | 'different identifier fp' | false
+ 'location fp' | 'different location fp' | nil | 'different identifier fp' | false
+ 'location fp' | 'different location fp' | 'identifier fp' | nil | false
+ nil | nil | 'identifier fp' | 'identifier fp' | false
+ 'location fp' | 'location fp' | nil | nil | false
+ nil | nil | nil | nil | false
+ 'location fp' | 'different location fp' | 'identifier fp' | 'different identifier fp' | false
+ 'location fp' | 'different location fp' | 'identifier fp' | 'identifier fp' | false
+ 'location fp' | 'location fp' | 'identifier fp' | 'different identifier fp' | false
+ 'location fp' | 'location fp' | 'identifier fp' | 'identifier fp' | true
end
- let(:finding_key_2) do
- build(:ci_reports_security_finding_key,
- location_fingerprint: location_fp_2,
- identifier_fingerprint: identifier_fp_2)
+ with_them do
+ let(:finding_key_1) do
+ build(:ci_reports_security_finding_key,
+ location_fingerprint: location_fp_1,
+ identifier_fingerprint: identifier_fp_1)
+ end
+
+ let(:finding_key_2) do
+ build(:ci_reports_security_finding_key,
+ location_fingerprint: location_fp_2,
+ identifier_fingerprint: identifier_fp_2)
+ end
+
+ subject { finding_key_1 == finding_key_2 }
+
+ it { is_expected.to be(equals?) }
end
+ end
+
+ context 'when the comparison is not done between FindingKey instances' do
+ let(:finding_key) { build(:ci_reports_security_finding_key) }
+ let(:uuid) { SecureRandom.uuid }
- subject { finding_key_1 == finding_key_2 }
+ subject { finding_key == uuid }
- it { is_expected.to be(equals?) }
+ it { is_expected.to be_falsey }
end
end
end