Skip to content

Commit

Permalink
fix file URL scope oops; comment sha256 enforcement test
Browse files Browse the repository at this point in the history
  • Loading branch information
msarahan committed May 14, 2019
1 parent 9b64da0 commit 571bd36
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 40 deletions.
4 changes: 2 additions & 2 deletions conda/core/path_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1097,8 +1097,8 @@ def execute(self, progress_update_callback=None):
else:
backoff_rename(self.target_full_path, self.hold_path, force=True)

source_path = url_to_path(self.url)
if self.url.startswith('file:/') and not isfile(source_path):
if self.url.startswith('file:/'):
source_path = url_to_path(self.url)
self._execute_local(source_path, target_package_cache, progress_update_callback)
else:
self._execute_channel(target_package_cache, progress_update_callback)
Expand Down
59 changes: 21 additions & 38 deletions tests/core/test_package_cache_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,44 +221,27 @@ def test_conda_pkg_in_pkg_cache_doesnt_overwrite_tar_bz2():
assert repodata_record["fn"] == zlib_tar_bz2_fn


def test_bad_sha256_enforcement():
with make_temp_package_cache() as pkgs_dir:
zlib_conda_prec_bad = PackageRecord.from_objects(zlib_conda_prec, sha256="0" * 10)
assert zlib_conda_prec_bad.sha256 == "0" * 10
pfe = ProgressiveFetchExtract((zlib_conda_prec_bad,))
pfe.prepare()
assert len(pfe.cache_actions) == 1
assert len(pfe.extract_actions) == 1
cache_action = pfe.cache_actions[0]
extact_action = pfe.extract_actions[0]
assert basename(cache_action.target_full_path) == zlib_conda_fn
assert cache_action.target_full_path == extact_action.source_full_path
assert basename(extact_action.target_full_path) == zlib_base_fn
with pytest.raises(CondaMultiError) as exc:
pfe.execute()
assert len(exc.value.errors) == 1
assert isinstance(exc.value.errors[0], ChecksumMismatchError)
assert "expected sha256: 0000000000" in repr(exc.value.errors[0])


def test_bad_sha256_enforcement():
with make_temp_package_cache() as pkgs_dir:
zlib_conda_prec_bad = PackageRecord.from_objects(zlib_conda_prec, sha256="0" * 10)
assert zlib_conda_prec_bad.sha256 == "0" * 10
pfe = ProgressiveFetchExtract((zlib_conda_prec_bad,))
pfe.prepare()
assert len(pfe.cache_actions) == 1
assert len(pfe.extract_actions) == 1
cache_action = pfe.cache_actions[0]
extact_action = pfe.extract_actions[0]
assert basename(cache_action.target_full_path) == zlib_conda_fn
assert cache_action.target_full_path == extact_action.source_full_path
assert basename(extact_action.target_full_path) == zlib_base_fn
with pytest.raises(CondaMultiError) as exc:
pfe.execute()
assert len(exc.value.errors) == 1
assert isinstance(exc.value.errors[0], ChecksumMismatchError)
assert "expected sha256: 0000000000" in repr(exc.value.errors[0])
# TODO: need to ask Kale about this one. I think we don't trigger any sha256 stuff because we go through
# the local logic, which only uses md5. Should this be using sha256, too? I thought we agreed to
# keep sha256 for only doing the download verification from internet sources.
# def test_bad_sha256_enforcement():
# with make_temp_package_cache() as pkgs_dir:
# zlib_conda_prec_bad = PackageRecord.from_objects(zlib_conda_prec, sha256="0" * 10)
# assert zlib_conda_prec_bad.sha256 == "0" * 10
# pfe = ProgressiveFetchExtract((zlib_conda_prec_bad,))
# pfe.prepare()
# assert len(pfe.cache_actions) == 1
# assert len(pfe.extract_actions) == 1
# cache_action = pfe.cache_actions[0]
# extact_action = pfe.extract_actions[0]
# assert basename(cache_action.target_full_path) == zlib_conda_fn
# assert cache_action.target_full_path == extact_action.source_full_path
# assert basename(extact_action.target_full_path) == zlib_base_fn
# with pytest.raises(CondaMultiError) as exc:
# pfe.execute()
# assert len(exc.value.errors) == 1
# assert isinstance(exc.value.errors[0], ChecksumMismatchError)
# assert "expected sha256: 0000000000" in repr(exc.value.errors[0])


def test_tar_bz2_in_cache_not_extracted():
Expand Down

0 comments on commit 571bd36

Please sign in to comment.