@@ -205,7 +205,11 @@ def verifier(self, asset) -> Verifier:
205
205
verifier ._trusted_root ._inner .timestamp_authorities = [authority ._inner ]
206
206
return verifier
207
207
208
- def test_verifier_verify_timestamp (self , verifier , asset , null_policy ):
208
+ def test_verifier_verify_timestamp (self , verifier , asset , null_policy , monkeypatch ):
209
+ # asset is a rekor v1 bundle: set threshold to 2 so both integrated time and the
210
+ # TSA timestamp are required
211
+ monkeypatch .setattr ("sigstore.verify.verifier.VERIFIED_TIME_THRESHOLD" , 2 )
212
+
209
213
verifier .verify_artifact (
210
214
asset ("tsa/bundle.txt" ).read_bytes (),
211
215
Bundle .from_json (asset ("tsa/bundle.txt.sigstore" ).read_bytes ()),
@@ -241,13 +245,21 @@ def test_verifier_duplicate_timestamp(self, verifier, asset, null_policy):
241
245
null_policy ,
242
246
)
243
247
244
- def test_verifier_no_validity (self , caplog , verifier , asset , null_policy ):
248
+ def test_verifier_no_validity (
249
+ self , caplog , verifier , asset , null_policy , monkeypatch
250
+ ):
251
+ # asset is a rekor v1 bundle: set threshold to 2 so both integrated time and the
252
+ # TSA timestamp are required
253
+ monkeypatch .setattr ("sigstore.verify.verifier.VERIFIED_TIME_THRESHOLD" , 2 )
254
+
245
255
verifier ._trusted_root .get_timestamp_authorities ()[
246
256
0
247
257
]._inner .valid_for .end = None
248
258
249
259
with caplog .at_level (logging .DEBUG , logger = "sigstore.verify.verifier" ):
250
- with pytest .raises (VerificationError , match = "not enough timestamps" ):
260
+ with pytest .raises (
261
+ VerificationError , match = "not enough sources of verified time"
262
+ ):
251
263
verifier .verify_artifact (
252
264
asset ("tsa/bundle.txt" ).read_bytes (),
253
265
Bundle .from_json (asset ("tsa/bundle.txt.sigstore" ).read_bytes ()),
@@ -260,15 +272,21 @@ def test_verifier_no_validity(self, caplog, verifier, asset, null_policy):
260
272
)
261
273
262
274
def test_verifier_outside_validity_range (
263
- self , caplog , verifier , asset , null_policy
275
+ self , caplog , verifier , asset , null_policy , monkeypatch
264
276
):
277
+ # asset is a rekor v1 bundle: set threshold to 2 so both integrated time and the
278
+ # TSA timestamp are required
279
+ monkeypatch .setattr ("sigstore.verify.verifier.VERIFIED_TIME_THRESHOLD" , 2 )
280
+
265
281
# Set a date before the timestamp range
266
282
verifier ._trusted_root .get_timestamp_authorities ()[
267
283
0
268
284
]._inner .valid_for .end = datetime (2024 , 10 , 31 , tzinfo = timezone .utc )
269
285
270
286
with caplog .at_level (logging .DEBUG , logger = "sigstore.verify.verifier" ):
271
- with pytest .raises (VerificationError , match = "not enough timestamps" ):
287
+ with pytest .raises (
288
+ VerificationError , match = "not enough sources of verified time"
289
+ ):
272
290
verifier .verify_artifact (
273
291
asset ("tsa/bundle.txt" ).read_bytes (),
274
292
Bundle .from_json (asset ("tsa/bundle.txt.sigstore" ).read_bytes ()),
@@ -283,13 +301,19 @@ def test_verifier_outside_validity_range(
283
301
def test_verifier_rfc3161_error (
284
302
self , verifier , asset , null_policy , caplog , monkeypatch
285
303
):
304
+ # asset is a rekor v1 bundle: set threshold to 2 so both integrated time and the
305
+ # TSA timestamp are required
306
+ monkeypatch .setattr ("sigstore.verify.verifier.VERIFIED_TIME_THRESHOLD" , 2 )
307
+
286
308
def verify_function (* args ):
287
309
raise rfc3161_client .VerificationError ()
288
310
289
311
monkeypatch .setattr (rfc3161_client .verify ._Verifier , "verify" , verify_function )
290
312
291
313
with caplog .at_level (logging .DEBUG , logger = "sigstore.verify.verifier" ):
292
- with pytest .raises (VerificationError , match = "not enough timestamps" ):
314
+ with pytest .raises (
315
+ VerificationError , match = "not enough sources of verified time"
316
+ ):
293
317
verifier .verify_artifact (
294
318
asset ("tsa/bundle.txt" ).read_bytes (),
295
319
Bundle .from_json (asset ("tsa/bundle.txt.sigstore" ).read_bytes ()),
@@ -309,15 +333,21 @@ def test_verifier_no_authorities(self, asset, null_policy):
309
333
null_policy ,
310
334
)
311
335
312
- def test_late_timestamp (self , caplog , verifier , asset , null_policy ):
336
+ def test_late_timestamp (self , caplog , verifier , asset , null_policy , monkeypatch ):
313
337
"""
314
338
Ensures that verifying the signing certificate fails because the timestamp
315
339
is outside the certificate's validity window. The sample bundle
316
340
"tsa/bundle.txt.late_timestamp.sigstore" was generated by adding `time.sleep(12*60)`
317
341
into `sigstore.sign.Signer._finalize_sign()`, just after the entry is posted to Rekor
318
342
but before the timestamp is requested.
319
343
"""
320
- with pytest .raises (VerificationError , match = "not enough timestamps" ):
344
+ # asset is a rekor v1 bundle: set threshold to 2 so both integrated time and the
345
+ # TSA timestamp are required
346
+ monkeypatch .setattr ("sigstore.verify.verifier.VERIFIED_TIME_THRESHOLD" , 2 )
347
+
348
+ with pytest .raises (
349
+ VerificationError , match = "not enough sources of verified time"
350
+ ):
321
351
verifier .verify_artifact (
322
352
asset ("tsa/bundle.txt" ).read_bytes (),
323
353
Bundle .from_json (
@@ -334,8 +364,12 @@ def test_late_timestamp(self, caplog, verifier, asset, null_policy):
334
364
def test_verifier_not_enough_timestamp (
335
365
self , verifier , asset , null_policy , monkeypatch
336
366
):
337
- monkeypatch .setattr ("sigstore.verify.verifier.VERIFY_TIMESTAMP_THRESHOLD" , 2 )
338
- with pytest .raises (VerificationError , match = "not enough timestamps" ):
367
+ # asset is a rekor v1 bundle: set threshold to 3 so integrated time and one
368
+ # TSA timestamp are not enough
369
+ monkeypatch .setattr ("sigstore.verify.verifier.VERIFIED_TIME_THRESHOLD" , 3 )
370
+ with pytest .raises (
371
+ VerificationError , match = "not enough sources of verified time"
372
+ ):
339
373
verifier .verify_artifact (
340
374
asset ("tsa/bundle.txt" ).read_bytes (),
341
375
Bundle .from_json (asset ("tsa/bundle.txt.sigstore" ).read_bytes ()),
0 commit comments