From 545e2156b5900afc3bea3c2deaa002acb8d82933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Thu, 17 Apr 2025 17:26:11 +0200 Subject: [PATCH] Skip container signature verification during the tests This is not required, and skipping them allows to make the whole test-suite run faster. --- dangerzone/updater/signatures.py | 2 +- tests/conftest.py | 8 ++++++++ tests/test_cli.py | 7 ++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/dangerzone/updater/signatures.py b/dangerzone/updater/signatures.py index 72f44af..bdc5f57 100644 --- a/dangerzone/updater/signatures.py +++ b/dangerzone/updater/signatures.py @@ -423,7 +423,7 @@ def store_signatures( write_log_index(get_log_index_from_signatures(signatures)) -def verify_local_image(image: str, pubkey: str) -> bool: +def verify_local_image(image: str, pubkey: str = DEFAULT_PUBKEY_LOCATION) -> bool: """ Verifies that a local image has a valid signature """ diff --git a/tests/conftest.py b/tests/conftest.py index edd293f..89d8d86 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -112,6 +112,14 @@ def sample_pdf() -> str: return str(test_docs_dir.joinpath(BASIC_SAMPLE_PDF)) +@pytest.fixture +def skip_image_verification(monkeypatch): + def noop(*args, **kwargs): + return True + + monkeypatch.setattr(container, "verify_local_image", noop) + + SAMPLE_DIRECTORY = "test_docs" BASIC_SAMPLE_PDF = "sample-pdf.pdf" BASIC_SAMPLE_DOC = "sample-doc.doc" diff --git a/tests/test_cli.py b/tests/test_cli.py index dbaa880..ffb6022 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -202,7 +202,12 @@ class TestCliConversion(TestCliBasic): result.assert_success() @for_each_doc - def test_formats(self, doc: Path, tmp_path_factory: pytest.TempPathFactory) -> None: + def test_formats( + self, + doc: Path, + tmp_path_factory: pytest.TempPathFactory, + skip_image_verification: pytest.FixtureRequest, + ) -> None: reference = (doc.parent / "reference" / doc.stem).with_suffix(".pdf") destination = tmp_path_factory.mktemp(doc.stem).with_suffix(".pdf")