@@ -219,7 +219,11 @@ def verifier(self, asset) -> Verifier:
219219 verifier ._trusted_root ._inner .timestamp_authorities = [authority ._inner ]
220220 return verifier
221221
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+
223227 verifier .verify_artifact (
224228 asset ("tsa/bundle.txt" ).read_bytes (),
225229 Bundle .from_json (asset ("tsa/bundle.txt.sigstore" ).read_bytes ()),
@@ -297,15 +301,21 @@ def test_verifier_duplicate_timestamp(self, verifier, asset, null_policy):
297301 )
298302
299303 def test_verifier_outside_validity_range (
300- self , caplog , verifier , asset , null_policy
304+ self , caplog , verifier , asset , null_policy , monkeypatch
301305 ):
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+
302310 # Set a date before the timestamp range
303311 verifier ._trusted_root .get_timestamp_authorities ()[
304312 0
305313 ]._inner .valid_for .end = datetime (2024 , 10 , 31 , tzinfo = timezone .utc )
306314
307315 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+ ):
309319 verifier .verify_artifact (
310320 asset ("tsa/bundle.txt" ).read_bytes (),
311321 Bundle .from_json (asset ("tsa/bundle.txt.sigstore" ).read_bytes ()),
@@ -320,13 +330,19 @@ def test_verifier_outside_validity_range(
320330 def test_verifier_rfc3161_error (
321331 self , verifier , asset , null_policy , caplog , monkeypatch
322332 ):
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+
323337 def verify_function (* args ):
324338 raise rfc3161_client .VerificationError ()
325339
326340 monkeypatch .setattr (rfc3161_client .verify ._Verifier , "verify" , verify_function )
327341
328342 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+ ):
330346 verifier .verify_artifact (
331347 asset ("tsa/bundle.txt" ).read_bytes (),
332348 Bundle .from_json (asset ("tsa/bundle.txt.sigstore" ).read_bytes ()),
@@ -346,15 +362,21 @@ def test_verifier_no_authorities(self, asset, null_policy):
346362 null_policy ,
347363 )
348364
349- def test_late_timestamp (self , caplog , verifier , asset , null_policy ):
365+ def test_late_timestamp (self , caplog , verifier , asset , null_policy , monkeypatch ):
350366 """
351367 Ensures that verifying the signing certificate fails because the timestamp
352368 is outside the certificate's validity window. The sample bundle
353369 "tsa/bundle.txt.late_timestamp.sigstore" was generated by adding `time.sleep(12*60)`
354370 into `sigstore.sign.Signer._finalize_sign()`, just after the entry is posted to Rekor
355371 but before the timestamp is requested.
356372 """
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+ ):
358380 verifier .verify_artifact (
359381 asset ("tsa/bundle.txt" ).read_bytes (),
360382 Bundle .from_json (
@@ -371,8 +393,12 @@ def test_late_timestamp(self, caplog, verifier, asset, null_policy):
371393 def test_verifier_not_enough_timestamp (
372394 self , verifier , asset , null_policy , monkeypatch
373395 ):
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+ ):
376402 verifier .verify_artifact (
377403 asset ("tsa/bundle.txt" ).read_bytes (),
378404 Bundle .from_json (asset ("tsa/bundle.txt.sigstore" ).read_bytes ()),
0 commit comments