2015-08-03 13:09:07 +01:00
|
|
|
require "testing_env"
|
2016-01-08 23:35:58 +01:00
|
|
|
require "formula"
|
2013-04-13 16:36:30 -05:00
|
|
|
|
2014-06-23 21:36:04 -05:00
|
|
|
class ChecksumVerificationTests < Homebrew::TestCase
|
2013-04-13 16:36:30 -05:00
|
|
|
def assert_checksum_good
|
|
|
|
assert_nothing_raised { shutup { @_f.brew {} } }
|
|
|
|
end
|
|
|
|
|
|
|
|
def assert_checksum_bad
|
|
|
|
assert_raises(ChecksumMismatchError) { shutup { @_f.brew {} } }
|
|
|
|
end
|
|
|
|
|
|
|
|
def formula(&block)
|
2014-12-28 00:03:16 -05:00
|
|
|
super do
|
|
|
|
url "file://#{TEST_DIRECTORY}/tarballs/testball-0.1.tbz"
|
|
|
|
instance_eval(&block)
|
|
|
|
end
|
2013-04-13 16:36:30 -05:00
|
|
|
end
|
|
|
|
|
2014-06-23 21:30:37 -05:00
|
|
|
def teardown
|
|
|
|
@_f.clear_cache
|
|
|
|
end
|
|
|
|
|
2013-04-13 16:36:30 -05:00
|
|
|
def test_good_sha1
|
|
|
|
formula do
|
2016-01-17 17:01:19 -08:00
|
|
|
sha1 TESTBALL_SHA1
|
2013-04-13 16:36:30 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
assert_checksum_good
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_bad_sha1
|
|
|
|
formula do
|
2015-08-03 13:09:07 +01:00
|
|
|
sha1 "7ea8a98acb8f918df723c2ae73fe67d5664bfd7e"
|
2013-04-13 16:36:30 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
assert_checksum_bad
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_good_sha256
|
|
|
|
formula do
|
2016-01-17 17:01:19 -08:00
|
|
|
sha256 TESTBALL_SHA256
|
2013-04-13 16:36:30 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
assert_checksum_good
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_bad_sha256
|
|
|
|
formula do
|
2015-08-03 13:09:07 +01:00
|
|
|
sha256 "dcbf5f44743b74add648c7e35e414076632fa3b24463d68d1f6afc5be77024f8"
|
2013-04-13 16:36:30 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
assert_checksum_bad
|
|
|
|
end
|
|
|
|
end
|