Skip to content

Commit

Permalink
RepoSim: remove metadata version check
Browse files Browse the repository at this point in the history
Except for 'root' role, RepositorySimulator does not
keep previous metadata versions, it always serves the latest
one. The metadata version check during fetch serves mostly
for informative purposes and removing it allows generating test
metadata with mismatching version.

Signed-off-by: Teodora Sechkova <[email protected]>
  • Loading branch information
sechkova committed Nov 9, 2021
1 parent 8418d52 commit d66c3ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
2 changes: 0 additions & 2 deletions tests/repository_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,6 @@ def _fetch_metadata(

if md is None:
raise FetcherHTTPError(f"Unknown role {role}", 404)
if version is not None and version != md.signed.version:
raise FetcherHTTPError(f"Unknown {role} version {version}", 404)

md.signatures.clear()
for signer in self.signers[role].values():
Expand Down
35 changes: 15 additions & 20 deletions tests/test_updater_top_level_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,19 +347,15 @@ def test_new_snapshot_unsigned(self) -> None:

self._assert_files_exist(["root", "timestamp"])

# TODO: RepositorySimulator works always with consistent snapshot
# enabled which forces the client to look for the snapshot version
# written in timestamp (which leads to "Unknown snapshot version").
# This fails the test for a snapshot version mismatch.
def test_new_snapshot_version_mismatch(self):
# Check against timestamp role’s snapshot version

# def test_new_snapshot_version_mismatch(self):
# # Check against timestamp role’s snapshot version
# Increase snapshot version without updating timestamp
self.sim.snapshot.version += 1
with self.assertRaises(BadVersionNumberError):
self._run_refresh()

# # Increase snapshot version without updating
# # timestamp's snapshot version
# self.sim.snapshot.version += 1
# with self.assertRaises(BadVersionNumberError):
# self._run_refresh()
self._assert_files_exist(["root", "timestamp"])

def test_new_snapshot_version_rollback(self) -> None:
# Check for a rollback attack
Expand Down Expand Up @@ -416,16 +412,15 @@ def test_new_targets_unsigned(self) -> None:

self._assert_files_exist(["root", "timestamp", "snapshot"])

# TODO: RepositorySimulator works always with consistent snapshot
# enabled which forces the client to look for the targets version
# written in snapshot (which leads to "Unknown targets version").
# This fails the test for a targets version mismatch.
def test_new_targets_version_mismatch(self):
# Check against snapshot role’s targets version

# def test_new_targets_version_mismatch(self):
# # Check against snapshot role’s targets version
# self.sim.targets.version += 1
# with self.assertRaises(BadVersionNumberError):
# self._run_refresh()
# Increase targets version without updating snapshot
self.sim.targets.version += 1
with self.assertRaises(BadVersionNumberError):
self._run_refresh()

self._assert_files_exist(["root", "timestamp", "snapshot"])

def test_new_targets_expired(self) -> None:
# Check for a freeze attack.
Expand Down

0 comments on commit d66c3ba

Please sign in to comment.