Verify changing WebDAV hash metadata without rejecting unchanged files

This commit is contained in:
admin committed 2026-10-26 12:27:01 +01:00
1 parent 7e94915442
commit 8245571f15
4 files changed
+43 -5

No files matched your search

+16
View File
@@ -159,6 +159,22 @@ class BackupTests(unittest.TestCase):
with self.assertRaisesRegex(m.BackupError, 'hash mismatch'):
self.runner.verify_local_hashes(manifest)
def test_disappearing_hash_requires_download_comparison(self):
before = {'file': {'size': 10, 'mtime': 'now', 'hashes': {'SHA-1': 'abc'}}}
after = {'file': {'size': 10, 'mtime': 'now', 'hashes': {}}}
with patch.object(self.runner, 'verify_local_hashes') as local, \
patch.object(self.runner, 'cloud') as cloud:
self.runner.validate_final_inventory(before, after)
local.assert_called_once_with(after)
self.assertIn('--download', cloud.call_args.args)
def test_new_hash_with_wrong_contents_is_rejected(self):
before = {'file': {'size': 10, 'mtime': 'now', 'hashes': {}}}
after = {'file': {'size': 10, 'mtime': 'now', 'hashes': {'SHA-1': 'abc'}}}
with patch.object(self.runner, 'verify_local_hashes', side_effect=m.BackupError('hash mismatch')):
with self.assertRaises(m.BackupError):
self.runner.validate_final_inventory(before, after)
def test_pending_maintenance_survives_interrupted_attempt_record(self):
import time
self.runner.success = {'completed_at': time.time(), 'maintenance_pending': True}