2019-11-21 04:06:16 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-01-10 11:22:33 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe Gitlab::Git::BundleFile do
|
2019-01-10 11:22:33 -05:00
|
|
|
describe '.check!' do
|
|
|
|
let(:valid_bundle) { Tempfile.new }
|
|
|
|
let(:valid_bundle_path) { valid_bundle.path }
|
|
|
|
let(:invalid_bundle_path) { Rails.root.join('spec/fixtures/malicious.bundle') }
|
|
|
|
|
|
|
|
after do
|
|
|
|
valid_bundle.close!
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns nil for a valid bundle' do
|
|
|
|
valid_bundle.write("# v2 git bundle\nfoo bar baz\n")
|
|
|
|
valid_bundle.close
|
|
|
|
|
|
|
|
expect(described_class.check!(valid_bundle_path)).to be_nil
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'raises an exception for an invalid bundle' do
|
|
|
|
expect do
|
|
|
|
described_class.check!(invalid_bundle_path)
|
|
|
|
end.to raise_error(described_class::InvalidBundleError)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|