def test_bad_contents_hash(self):
"""
Test that a package with a bad contents hash fails installation.
"""
tabledata = b'Bad package'
h = hashlib.new(HASH_TYPE)
h.update(tabledata)
obj_hash = h.hexdigest()
contents = GroupNode(dict(
foo=GroupNode(dict(
bar=TableNode([obj_hash], PackageFormat.default.value)
))
))
contents_hash = 'e867010701edc0b1c8be177e02a93aa3cb1342bb1123046e1f6b40e428c6048e'
self._mock_tag('foo/bar', 'latest', contents_hash)
self._mock_package('foo/bar', contents_hash, '', contents, [obj_hash])
with assertRaisesRegex(self, command.CommandException, "Mismatched hash"):
command.install('foo/bar')
assert not os.path.exists(os.path.join(self._store_dir, 'foo/bar.json'))
评论列表
文章目录