mirror of
https://github.com/miurahr/aqtinstall.git
synced 2025-12-18 05:04:38 +03:00
Use sha256 hashes only from trusted mirrors
To keep this commit small, `hashurl` was removed from QtPackage, and `get_hash` constructs the hash url based on the url of the 7z archive to download. I think that in the future, QtArchive and QtPackage could be refactored to construct this url more appropriately. However, this would be a complicated change that doesn't belong in this commit.
This commit is contained in:
@@ -137,7 +137,7 @@ def make_mock_geturl_download_archive(
|
||||
def mock_getUrl(url: str, *args) -> str:
|
||||
if url.endswith(updates_url):
|
||||
return "<Updates>\n{}\n</Updates>".format("\n".join([archive.xml_package_update() for archive in archives]))
|
||||
elif url.endswith(".sha1"):
|
||||
elif url.endswith(".sha256"):
|
||||
return "" # Skip the checksum
|
||||
assert False
|
||||
|
||||
@@ -598,7 +598,7 @@ def test_install(
|
||||
|
||||
mock_get_url, mock_download_archive = make_mock_geturl_download_archive(archives, arch, host, updates_url)
|
||||
monkeypatch.setattr("aqt.archives.getUrl", mock_get_url)
|
||||
monkeypatch.setattr("aqt.installer.getUrl", mock_get_url)
|
||||
monkeypatch.setattr("aqt.helper.getUrl", mock_get_url)
|
||||
monkeypatch.setattr("aqt.installer.downloadBinaryFile", mock_download_archive)
|
||||
|
||||
with TemporaryDirectory() as output_dir:
|
||||
@@ -713,7 +713,7 @@ def test_install_nonexistent_archives(monkeypatch, capsys, cmd, xml_file: Option
|
||||
return (Path(__file__).parent / "data" / xml_file).read_text("utf-8")
|
||||
|
||||
monkeypatch.setattr("aqt.archives.getUrl", mock_get_url)
|
||||
monkeypatch.setattr("aqt.installer.getUrl", mock_get_url)
|
||||
monkeypatch.setattr("aqt.helper.getUrl", mock_get_url)
|
||||
monkeypatch.setattr("aqt.metadata.getUrl", mock_get_url)
|
||||
|
||||
cli = Cli()
|
||||
@@ -779,7 +779,7 @@ def test_install_pool_exception(monkeypatch, capsys, make_exception, settings_fi
|
||||
cmd = ["install-qt", host, target, ver, arch]
|
||||
mock_get_url, mock_download_archive = make_mock_geturl_download_archive(archives, arch, host, updates_url)
|
||||
monkeypatch.setattr("aqt.archives.getUrl", mock_get_url)
|
||||
monkeypatch.setattr("aqt.installer.getUrl", mock_get_url)
|
||||
monkeypatch.setattr("aqt.helper.getUrl", mock_get_url)
|
||||
monkeypatch.setattr("aqt.installer.installer", mock_installer_func)
|
||||
|
||||
Settings.load_settings(str(Path(__file__).parent / settings_file))
|
||||
@@ -793,7 +793,7 @@ def test_install_installer_archive_extraction_err(monkeypatch):
|
||||
def mock_extractor_that_fails(*args, **kwargs):
|
||||
raise subprocess.CalledProcessError(returncode=1, cmd="some command", output="out", stderr="err")
|
||||
|
||||
monkeypatch.setattr("aqt.installer.getUrl", lambda *args: "")
|
||||
monkeypatch.setattr("aqt.installer.get_hash", lambda *args, **kwargs: "")
|
||||
monkeypatch.setattr("aqt.installer.downloadBinaryFile", lambda *args: None)
|
||||
monkeypatch.setattr("aqt.installer.subprocess.run", mock_extractor_that_fails)
|
||||
|
||||
@@ -804,7 +804,6 @@ def test_install_installer_archive_extraction_err(monkeypatch):
|
||||
"archive-url",
|
||||
"archive",
|
||||
"package_desc",
|
||||
"hashurl",
|
||||
"pkg_update_name",
|
||||
),
|
||||
base_dir=temp_dir,
|
||||
|
||||
Reference in New Issue
Block a user