Skip to content

Commit

Permalink
add test for expired root
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Korczynski <[email protected]>
  • Loading branch information
AdamKorcz committed Jul 24, 2024
1 parent d5c1fb5 commit 90b5ac1
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tuf_conformance/test_expiration.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,36 @@
Timestamp, Snapshot, Root, Targets, Metadata,
DelegatedRole
)
from tuf_conformance.metadata import RootTest, MetadataTest

def test_root_expired(client: ClientRunner,
server: SimulatorServer) -> None:
# Check for a freeze attack
name = "test_root_expired"

# initialize a simulator with repository content we need
repo = RepositorySimulator()
server.repos[name] = repo
init_data = server.get_client_init_data(name)
assert client.init_client(init_data) == 0
client.refresh(init_data)

repo.bump_root_by_one() # v2
client.refresh(init_data)

root = repo.load_metadata(Root.type)
root.signed.expires = utils.get_date_n_days_in_past(1)
repo.save_metadata(Root.type, root)
repo.bump_root_by_one() # v3
repo.bump_version_by_one(Timestamp.type) # v2

client.refresh(init_data)

# Clients should check for a freeze attack after persisting (5.3.10),
# so root should update, but no other MD should update
assert client._version(Root.type) == 3
assert client._version(Timestamp.type) == 1
assert client._version(Snapshot.type) == 1


def test_new_snapshot_expired(client: ClientRunner,
Expand Down

0 comments on commit 90b5ac1

Please sign in to comment.