@@ -219,7 +219,11 @@ def verifier(self, asset) -> Verifier:
219
219
verifier ._trusted_root ._inner .timestamp_authorities = [authority ._inner ]
220
220
return verifier
221
221
222
- def test_verifier_verify_timestamp (self , verifier , asset , null_policy ):
222
+ def test_verifier_verify_timestamp (self , verifier , asset , null_policy , monkeypatch ):
223
+ # asset is a rekor v1 bundle: set threshold to 2 so both integrated time and the
224
+ # TSA timestamp are required
225
+ monkeypatch .setattr ("sigstore.verify.verifier.VERIFY_TIMESTAMP_THRESHOLD" , 2 )
226
+
223
227
verifier .verify_artifact (
224
228
asset ("tsa/bundle.txt" ).read_bytes (),
225
229
Bundle .from_json (asset ("tsa/bundle.txt.sigstore" ).read_bytes ()),
@@ -296,15 +300,19 @@ def test_verifier_duplicate_timestamp(self, verifier, asset, null_policy):
296
300
)
297
301
298
302
def test_verifier_outside_validity_range (
299
- self , caplog , verifier , asset , null_policy
303
+ self , caplog , verifier , asset , null_policy , monkeypatch
300
304
):
305
+ # asset is a rekor v1 bundle: set threshold to 2 so both integrated time and the
306
+ # TSA timestamp are required
307
+ monkeypatch .setattr ("sigstore.verify.verifier.VERIFY_TIMESTAMP_THRESHOLD" , 2 )
308
+
301
309
# Set a date before the timestamp range
302
310
verifier ._trusted_root .get_timestamp_authorities ()[
303
311
0
304
312
]._inner .valid_for .end = datetime (2024 , 10 , 31 , tzinfo = timezone .utc )
305
313
306
314
with caplog .at_level (logging .DEBUG , logger = "sigstore.verify.verifier" ):
307
- with pytest .raises (VerificationError , match = "not enough timestamps " ):
315
+ with pytest .raises (VerificationError , match = "not enough sources of verified time " ):
308
316
verifier .verify_artifact (
309
317
asset ("tsa/bundle.txt" ).read_bytes (),
310
318
Bundle .from_json (asset ("tsa/bundle.txt.sigstore" ).read_bytes ()),
@@ -319,13 +327,17 @@ def test_verifier_outside_validity_range(
319
327
def test_verifier_rfc3161_error (
320
328
self , verifier , asset , null_policy , caplog , monkeypatch
321
329
):
330
+ # asset is a rekor v1 bundle: set threshold to 2 so both integrated time and the
331
+ # TSA timestamp are required
332
+ monkeypatch .setattr ("sigstore.verify.verifier.VERIFY_TIMESTAMP_THRESHOLD" , 2 )
333
+
322
334
def verify_function (* args ):
323
335
raise rfc3161_client .VerificationError ()
324
336
325
337
monkeypatch .setattr (rfc3161_client .verify ._Verifier , "verify" , verify_function )
326
338
327
339
with caplog .at_level (logging .DEBUG , logger = "sigstore.verify.verifier" ):
328
- with pytest .raises (VerificationError , match = "not enough timestamps " ):
340
+ with pytest .raises (VerificationError , match = "not enough sources of verified time " ):
329
341
verifier .verify_artifact (
330
342
asset ("tsa/bundle.txt" ).read_bytes (),
331
343
Bundle .from_json (asset ("tsa/bundle.txt.sigstore" ).read_bytes ()),
@@ -345,15 +357,19 @@ def test_verifier_no_authorities(self, asset, null_policy):
345
357
null_policy ,
346
358
)
347
359
348
- def test_late_timestamp (self , caplog , verifier , asset , null_policy ):
360
+ def test_late_timestamp (self , caplog , verifier , asset , null_policy , monkeypatch ):
349
361
"""
350
362
Ensures that verifying the signing certificate fails because the timestamp
351
363
is outside the certificate's validity window. The sample bundle
352
364
"tsa/bundle.txt.late_timestamp.sigstore" was generated by adding `time.sleep(12*60)`
353
365
into `sigstore.sign.Signer._finalize_sign()`, just after the entry is posted to Rekor
354
366
but before the timestamp is requested.
355
367
"""
356
- with pytest .raises (VerificationError , match = "not enough timestamps" ):
368
+ # asset is a rekor v1 bundle: set threshold to 2 so both integrated time and the
369
+ # TSA timestamp are required
370
+ monkeypatch .setattr ("sigstore.verify.verifier.VERIFY_TIMESTAMP_THRESHOLD" , 2 )
371
+
372
+ with pytest .raises (VerificationError , match = "not enough sources of verified time" ):
357
373
verifier .verify_artifact (
358
374
asset ("tsa/bundle.txt" ).read_bytes (),
359
375
Bundle .from_json (
@@ -370,8 +386,10 @@ def test_late_timestamp(self, caplog, verifier, asset, null_policy):
370
386
def test_verifier_not_enough_timestamp (
371
387
self , verifier , asset , null_policy , monkeypatch
372
388
):
373
- monkeypatch .setattr ("sigstore.verify.verifier.VERIFY_TIMESTAMP_THRESHOLD" , 2 )
374
- with pytest .raises (VerificationError , match = "not enough timestamps" ):
389
+ # asset is a rekor v1 bundle: set threshold to 3 so integrated time and one
390
+ # TSA timestamp are not enough
391
+ monkeypatch .setattr ("sigstore.verify.verifier.VERIFY_TIMESTAMP_THRESHOLD" , 3 )
392
+ with pytest .raises (VerificationError , match = "not enough sources of verified time" ):
375
393
verifier .verify_artifact (
376
394
asset ("tsa/bundle.txt" ).read_bytes (),
377
395
Bundle .from_json (asset ("tsa/bundle.txt.sigstore" ).read_bytes ()),
0 commit comments