From 0828357e19e55e5090b6d6e13d3ff568dc6cfa29 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Sat, 17 Sep 2022 18:43:12 +0200 Subject: Include full path in ManifestNoSupportedHashes exception MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Górny --- gemato/exceptions.py | 5 +++-- gemato/verify.py | 2 +- tests/test_recursiveloader.py | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gemato/exceptions.py b/gemato/exceptions.py index 71283ea..62c8ac8 100644 --- a/gemato/exceptions.py +++ b/gemato/exceptions.py @@ -272,12 +272,13 @@ class ManifestNoSupportedHashes(GematoException): unsupported. """ - def __init__(self, entry): + def __init__(self, path, entry): super().__init__() + self.path = path self.entry = entry def __str__(self): - return (f"No hashes provided for file {self.entry.path!r} are " + return (f"No hashes provided for file {self.path!r} are " f"supported (out of {' '.join(self.entry.checksums)})") diff --git a/gemato/verify.py b/gemato/verify.py index 05e568d..56ffe64 100644 --- a/gemato/verify.py +++ b/gemato/verify.py @@ -181,7 +181,7 @@ def verify_path(path, e, expected_dev=None, last_mtime=None, expect_exist = True checksums = list(filter(is_hash_supported, e.checksums)) if not checksums and e.checksums: - raise ManifestNoSupportedHashes(e) + raise ManifestNoSupportedHashes(path, e) if require_secure_hash: # Note: even if we require secure hashes, we verify all of them secure_hashes = list(filter(is_hash_secure, checksums)) diff --git a/tests/test_recursiveloader.py b/tests/test_recursiveloader.py index 6e2395b..f0c5673 100644 --- a/tests/test_recursiveloader.py +++ b/tests/test_recursiveloader.py @@ -1431,8 +1431,8 @@ def test_assert_directory_verifies(layout_factory, layout, path, fail_handler, str(ManifestSymlinkLoop('')).split('', 1)[1]), (SymlinkLoopIgnoreLayout, '', '', None), (UnknownHashOnlyLayout, '', '', - str(ManifestNoSupportedHashes(ManifestFileEntry( - 'test', 0, {"X-UNKNOWN": ""})))), + str(ManifestNoSupportedHashes("", ManifestFileEntry( + "", 0, {"X-UNKNOWN": ""}))).split("", 1)[1]), ]) def test_cli_verify(layout_factory, caplog, layout, path, args, expected): tmp_path = layout_factory.create(layout, readonly=True) -- cgit v1.2.3