blob: 4fd2db85ec2d90b6e29cb84c4247d445f4ededc6 (
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
60
61
62
63
64
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Verify::CiSecureFiles, factory_default: :keep, feature_category: :mobile_devops do
include GitlabVerifyHelpers
it_behaves_like 'Gitlab::Verify::BatchVerifier subclass' do
let_it_be(:objects) { create_list(:ci_secure_file, 3) }
end
describe '#run_batches' do
let_it_be(:project) { create(:project) }
let(:failures) { collect_failures }
let(:failure) { failures[secure_file] }
let!(:secure_file) { create(:ci_secure_file, project: project) }
it 'passes secure_files with the correct file' do
expect(failures).to eq({})
end
it 'fails secure_files with a missing file' do
FileUtils.rm_f(secure_file.file.path)
expect(failures.keys).to contain_exactly(secure_file)
expect(failure).to include('No such file or directory')
expect(failure).to include(secure_file.file.path)
end
it 'fails secure_files with a mismatched checksum' do
secure_file.update!(checksum: 'something incorrect')
expect(failures.keys).to contain_exactly(secure_file)
expect(failure).to include('Checksum mismatch')
end
context 'with remote files' do
let(:file) { CarrierWaveStringFile.new }
before do
stub_ci_secure_file_object_storage
secure_file.update!(file_store: ObjectStorage::Store::REMOTE)
end
describe 'returned hash object' do
it 'passes secure_files in object storage that exist' do
expect(CarrierWave::Storage::Fog::File).to receive(:new).and_return(file)
expect(file).to receive(:exists?).and_return(true)
expect(failures).to eq({})
end
it 'fails secure_files in object storage that do not exist' do
expect(CarrierWave::Storage::Fog::File).to receive(:new).and_return(file)
expect(file).to receive(:exists?).and_return(false)
expect(failures.keys).to contain_exactly(secure_file)
expect(failure).to include('Remote object does not exist')
end
end
end
end
end
|