Skip to content

Commit 672df74

Browse files
committed
Remove test_updater_with_simulator.py
Move the remaining test_snapshot_rollback_with_local_snapshot_hash_mismatch to test_updater_top_level_update.py and remove the file. Signed-off-by: Teodora Sechkova <[email protected]>
1 parent aadc6fd commit 672df74

File tree

2 files changed

+30
-102
lines changed

2 files changed

+30
-102
lines changed

tests/test_updater_top_level_update.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,36 @@ def test_not_loading_targets_twice(self, wrapped_open: MagicMock) -> None:
530530
updater.get_targetinfo("somepath")
531531
wrapped_open.assert_not_called()
532532

533+
def test_snapshot_rollback_with_local_snapshot_hash_mismatch(self) -> None:
534+
# Test triggering snapshot rollback check on a newly downloaded snapshot
535+
# when the local snapshot is loaded even when there is a hash mismatch
536+
# with timestamp.snapshot_meta.
537+
538+
# By raising this flag on timestamp update the simulator would:
539+
# 1) compute the hash of the new modified version of snapshot
540+
# 2) assign the hash to timestamp.snapshot_meta
541+
# The purpose is to create a hash mismatch between timestamp.meta and
542+
# the local snapshot, but to have hash match between timestamp.meta and
543+
# the next snapshot version.
544+
self.sim.compute_metafile_hashes_length = True
545+
546+
# Initialize all metadata and assign targets version higher than 1.
547+
self.sim.targets.version = 2
548+
self.sim.update_snapshot()
549+
self._run_refresh()
550+
551+
# The new targets must have a lower version than the local trusted one.
552+
self.sim.targets.version = 1
553+
self.sim.update_snapshot()
554+
555+
# During the snapshot update, the local snapshot will be loaded even if
556+
# there is a hash mismatch with timestamp.snapshot_meta, because it will
557+
# be considered as trusted.
558+
# Should fail as a new version of snapshot will be fetched which lowers
559+
# the snapshot.meta["targets.json"] version by 1 and throws an error.
560+
with self.assertRaises(BadVersionNumberError):
561+
self._run_refresh()
562+
533563

534564
if __name__ == "__main__":
535565
if "--dump" in sys.argv:

tests/test_updater_with_simulator.py

Lines changed: 0 additions & 102 deletions
This file was deleted.

0 commit comments

Comments
 (0)