diff options
author | Michał Górny <mgorny@gentoo.org> | 2022-09-17 18:43:12 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2022-09-17 18:43:12 +0200 |
commit | 0828357e19e55e5090b6d6e13d3ff568dc6cfa29 (patch) | |
tree | 7a3012fd94e00a8b0951a97e46edf21e6fdaf8f5 | |
parent | 3c251c8d655011ec2ee4ec02933e8e02163b4620 (diff) | |
download | gemato-0828357e19e55e5090b6d6e13d3ff568dc6cfa29.tar.gz |
Include full path in ManifestNoSupportedHashes exception
Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r-- | gemato/exceptions.py | 5 | ||||
-rw-r--r-- | gemato/verify.py | 2 | ||||
-rw-r--r-- | 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('<path>')).split('<path>', 1)[1]), (SymlinkLoopIgnoreLayout, '', '', None), (UnknownHashOnlyLayout, '', '', - str(ManifestNoSupportedHashes(ManifestFileEntry( - 'test', 0, {"X-UNKNOWN": ""})))), + str(ManifestNoSupportedHashes("<path>", ManifestFileEntry( + "", 0, {"X-UNKNOWN": ""}))).split("<path>", 1)[1]), ]) def test_cli_verify(layout_factory, caplog, layout, path, args, expected): tmp_path = layout_factory.create(layout, readonly=True) |