blob: 23e6b40a039fdcef7494f37ae2ae2944f072f676 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Ci::Reports::Security::FindingSignature do
subject { described_class.new(params.with_indifferent_access) }
let(:params) do
{
algorithm_type: 'hash',
signature_value: 'SIGNATURE'
}
end
describe '#initialize' do
context 'when a supported algorithm type is given' do
it 'allows itself to be created' do
expect(subject.algorithm_type).to eq(params[:algorithm_type])
expect(subject.signature_value).to eq(params[:signature_value])
end
describe '#valid?' do
it 'returns true' do
expect(subject.valid?).to eq(true)
end
end
end
end
describe '#valid?' do
context 'when supported algorithm_type is given' do
it 'is valid' do
expect(subject.valid?).to eq(true)
end
end
context 'when an unsupported algorithm_type is given' do
let(:params) do
{
algorithm_type: 'INVALID',
signature_value: 'SIGNATURE'
}
end
it 'is not valid' do
expect(subject.valid?).to eq(false)
end
end
end
describe '#to_hash' do
it 'returns a hash representation of the signature' do
expect(subject.to_hash).to eq(
algorithm_type: params[:algorithm_type],
signature_sha: Digest::SHA1.digest(params[:signature_value])
)
end
end
end
|