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