Skip to content

Commit 1b06625

Browse files
committed
Add test to verify that faketime actually works
It does not work with golang. Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
1 parent 0df5b56 commit 1b06625

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

clients/go-tuf/go-tuf.xfails

+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
# RSA-PSS is not yet supported (https://github.com/theupdateframework/go-tuf/pull/625)
22
test_keytype_and_scheme[rsa/rsassa-pss-sha256]
3+
4+
# golang is not compatible with faketime (https://github.com/theupdateframework/tuf-conformance/issues/263)
5+
# This means faketime-using tests cannot be trusted for go-tuf
6+
test_faketime

tuf_conformance/test_basic.py

+20
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from datetime import UTC, datetime, timedelta
12
import json
23
import os
34

@@ -414,3 +415,22 @@ def test_incorrect_metadata_type(client: ClientRunner, server: SimulatorServer)
414415
# Client should refuse timestamp that has incorrect type field
415416
assert client.refresh(init_data) == 1
416417
assert client.trusted_roles() == [(Root.type, 2)]
418+
419+
420+
def test_faketime(client: ClientRunner, server: SimulatorServer) -> None:
421+
"""Ensures that client supports the faketime setup in this test suite"""
422+
init_data, repo = server.new_test(client.test_name)
423+
424+
assert client.init_client(init_data) == 0
425+
426+
# root v2 expires in 7 days
427+
now = datetime.now(UTC)
428+
repo.root.expires = now + timedelta(days=7)
429+
repo.publish([Root.type])
430+
431+
# Refresh
432+
assert client.refresh(init_data) == 0
433+
434+
# Mock time so that root has expired. If client unexpectedly succeeds here,
435+
# it likely does not work with faketime
436+
assert client.refresh(init_data, now + timedelta(days=8)) == 1

0 commit comments

Comments
 (0)