@@ -80,20 +80,6 @@ def hashes_length_modifier(timestamp: Timestamp) -> None:
80
80
def setUp (self ) -> None :
81
81
self .trusted_set = TrustedMetadataSet (self .metadata ["root" ])
82
82
83
- def _root_updated_and_update_timestamp (
84
- self , timestamp_bytes : Optional [bytes ] = None
85
- ) -> None :
86
- """Finsh root update and update timestamp with passed timestamp_bytes.
87
-
88
- Args:
89
- timestamp_bytes:
90
- Bytes used when calling trusted_set.update_timestamp().
91
- Default self.metadata["timestamp"].
92
-
93
- """
94
- timestamp_bytes = timestamp_bytes or self .metadata ["timestamp" ]
95
- self .trusted_set .update_timestamp (timestamp_bytes )
96
-
97
83
98
84
def _update_all_besides_targets (
99
85
self ,
@@ -111,7 +97,9 @@ def _update_all_besides_targets(
111
97
Default self.metadata["snapshot"].
112
98
113
99
"""
114
- self ._root_updated_and_update_timestamp (timestamp_bytes )
100
+
101
+ timestamp_bytes = timestamp_bytes or self .metadata ["timestamp" ]
102
+ self .trusted_set .update_timestamp (timestamp_bytes )
115
103
snapshot_bytes = snapshot_bytes or self .metadata ["snapshot" ]
116
104
self .trusted_set .update_snapshot (snapshot_bytes )
117
105
@@ -247,7 +235,7 @@ def version_modifier(timestamp: Timestamp) -> None:
247
235
timestamp .version = 3
248
236
249
237
timestamp = self .modify_metadata ("timestamp" , version_modifier )
250
- self ._root_updated_and_update_timestamp (timestamp )
238
+ self .trusted_set . update_timestamp (timestamp )
251
239
with self .assertRaises (exceptions .ReplayedMetadataError ):
252
240
self .trusted_set .update_timestamp (self .metadata ["timestamp" ])
253
241
@@ -257,7 +245,7 @@ def bump_snapshot_version(timestamp: Timestamp) -> None:
257
245
258
246
# set current known snapshot.json version to 2
259
247
timestamp = self .modify_metadata ("timestamp" , bump_snapshot_version )
260
- self ._root_updated_and_update_timestamp (timestamp )
248
+ self .trusted_set . update_timestamp (timestamp )
261
249
262
250
# newtimestamp.meta["snapshot.json"].version < trusted_timestamp.meta["snapshot.json"].version
263
251
with self .assertRaises (exceptions .ReplayedMetadataError ):
@@ -282,13 +270,13 @@ def modify_snapshot_length(timestamp: Timestamp) -> None:
282
270
283
271
# set known snapshot.json length to 1
284
272
timestamp = self .modify_metadata ("timestamp" , modify_snapshot_length )
285
- self ._root_updated_and_update_timestamp (timestamp )
273
+ self .trusted_set . update_timestamp (timestamp )
286
274
287
275
with self .assertRaises (exceptions .RepositoryError ):
288
276
self .trusted_set .update_snapshot (self .metadata ["snapshot" ])
289
277
290
278
def test_update_snapshot_cannot_verify_snapshot_with_threshold (self ):
291
- self ._root_updated_and_update_timestamp (self .metadata ["timestamp" ])
279
+ self .trusted_set . update_timestamp (self .metadata ["timestamp" ])
292
280
snapshot = Metadata .from_bytes (self .metadata ["snapshot" ])
293
281
snapshot .signatures .clear ()
294
282
with self .assertRaises (exceptions .UnsignedMetadataError ):
@@ -299,7 +287,7 @@ def timestamp_version_modifier(timestamp: Timestamp) -> None:
299
287
timestamp .meta ["snapshot.json" ].version = 2
300
288
301
289
timestamp = self .modify_metadata ("timestamp" , timestamp_version_modifier )
302
- self ._root_updated_and_update_timestamp (timestamp )
290
+ self .trusted_set . update_timestamp (timestamp )
303
291
304
292
#intermediate snapshot is allowed to not match meta version
305
293
self .trusted_set .update_snapshot (self .metadata ["snapshot" ])
@@ -320,7 +308,7 @@ def remove_file_from_meta(snapshot: Snapshot) -> None:
320
308
self .trusted_set .update_snapshot (snapshot )
321
309
322
310
def test_update_snapshot_meta_version_decreases (self ):
323
- self ._root_updated_and_update_timestamp (self .metadata ["timestamp" ])
311
+ self .trusted_set . update_timestamp (self .metadata ["timestamp" ])
324
312
325
313
def version_meta_modifier (snapshot : Snapshot ) -> None :
326
314
snapshot .meta ["targets.json" ].version += 1
@@ -332,7 +320,7 @@ def version_meta_modifier(snapshot: Snapshot) -> None:
332
320
self .trusted_set .update_snapshot (self .metadata ["snapshot" ])
333
321
334
322
def test_update_snapshot_expired_new_snapshot (self ):
335
- self ._root_updated_and_update_timestamp (self .metadata ["timestamp" ])
323
+ self .trusted_set . update_timestamp (self .metadata ["timestamp" ])
336
324
def snapshot_expired_modifier (snapshot : Snapshot ) -> None :
337
325
snapshot .expires = datetime (1970 , 1 , 1 )
338
326
0 commit comments