Ignore case when comparing checksums

Fixes GH-6648
This commit is contained in:
Seth Vargo 2015-12-07 10:30:44 -05:00
parent 44eac3c819
commit 4e21dd78e4
2 changed files with 23 additions and 1 deletions

View File

@ -522,7 +522,7 @@ module Vagrant
@logger.info("Expected checksum: #{checksum}") @logger.info("Expected checksum: #{checksum}")
actual = FileChecksum.new(path, checksum_klass).checksum actual = FileChecksum.new(path, checksum_klass).checksum
if actual != checksum if actual.casecmp(checksum) != 0
raise Errors::BoxChecksumMismatch, raise Errors::BoxChecksumMismatch,
actual: actual, actual: actual,
expected: checksum expected: checksum

View File

@ -207,6 +207,28 @@ describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
to raise_error(Vagrant::Errors::BoxChecksumMismatch) to raise_error(Vagrant::Errors::BoxChecksumMismatch)
end end
it "does not raise an error if the checksum has different case" do
box_path = iso_env.box2_file(:virtualbox)
box = double(
name: "foo",
version: "1.2.3",
provider: "virtualbox",
)
env[:box_name] = box.name
env[:box_url] = box_path.to_s
env[:box_checksum] = checksum(box_path)
env[:box_checksum_type] = "sha1"
# Convert to a different case
env[:box_checksum].upcase!
expect(box_collection).to receive(:add).and_return(box)
expect { subject.call(env) }.to_not raise_error
end
it "raises an error if the box path doesn't exist" do it "raises an error if the box path doesn't exist" do
box_path = iso_env.box2_file(:virtualbox) box_path = iso_env.box2_file(:virtualbox)