@@ -58,9 +58,7 @@ def test_sign_invalid_dist_filename(self, tmp_path: Path) -> None:
5858 ):
5959 impl .Attestation .sign (pretend .stub (), bad_dist )
6060
61- def test_sign_raises_attestation_exception (
62- self , id_token : IdentityToken , tmp_path : Path
63- ) -> None :
61+ def test_sign_raises_attestation_exception (self , tmp_path : Path ) -> None :
6462 non_existing_file = tmp_path / "invalid-name.tar.gz"
6563 with pytest .raises (impl .AttestationError , match = "No such file" ):
6664 impl .Attestation .sign (pretend .stub (), non_existing_file )
@@ -77,9 +75,7 @@ def test_sign_raises_attestation_exception(
7775 with pytest .raises (impl .AttestationError , match = "Invalid sdist filename" ):
7876 impl .Attestation .sign (pretend .stub (), bad_sdist_filename )
7977
80- def test_wrong_predicate_raises_exception (
81- self , id_token : IdentityToken , monkeypatch : pytest .MonkeyPatch
82- ) -> None :
78+ def test_wrong_predicate_raises_exception (self , monkeypatch : pytest .MonkeyPatch ) -> None :
8379 def dummy_predicate (self_ : _StatementBuilder , _ : str ) -> _StatementBuilder :
8480 # wrong type here to have a validation error
8581 self_ ._predicate_type = False
@@ -89,6 +85,7 @@ def dummy_predicate(self_: _StatementBuilder, _: str) -> _StatementBuilder:
8985 with pytest .raises (impl .AttestationError , match = "invalid statement" ):
9086 impl .Attestation .sign (pretend .stub (), artifact_path )
9187
88+ @online
9289 def test_expired_certificate (
9390 self , id_token : IdentityToken , monkeypatch : pytest .MonkeyPatch
9491 ) -> None :
@@ -102,6 +99,7 @@ def in_validity_period(_: IdentityToken) -> bool:
10299 with pytest .raises (impl .AttestationError ):
103100 impl .Attestation .sign (signer , artifact_path )
104101
102+ @online
105103 def test_multiple_signatures (
106104 self , id_token : IdentityToken , monkeypatch : pytest .MonkeyPatch
107105 ) -> None :
@@ -312,6 +310,43 @@ def test_verify_subject_invalid_name(self) -> None:
312310 with pytest .raises (impl .VerificationError , match = "invalid subject: Invalid wheel filename" ):
313311 attestation .verify (verifier , pol , artifact_path )
314312
313+ def test_verify_unknown_attestation_type (self ) -> None :
314+ statement = (
315+ _StatementBuilder () # noqa: SLF001
316+ .subjects (
317+ [
318+ _Subject (
319+ name = "rfc8785-0.1.2-py3-none-any.whl" ,
320+ digest = _DigestSet (
321+ root = {
322+ "sha256" : (
323+ "c4e92e9ecc828bef2aa7dba1de8ac983511f7532a0df11c770d39099a25cf201"
324+ ),
325+ }
326+ ),
327+ ),
328+ ]
329+ )
330+ .predicate_type ("foo" )
331+ .build ()
332+ ._inner .model_dump_json ()
333+ )
334+
335+ verifier = pretend .stub (
336+ verify_dsse = pretend .call_recorder (
337+ lambda bundle , policy : (
338+ "application/vnd.in-toto+json" ,
339+ statement .encode (),
340+ )
341+ )
342+ )
343+ pol = pretend .stub ()
344+
345+ attestation = impl .Attestation .model_validate_json (attestation_path .read_text ())
346+
347+ with pytest .raises (impl .VerificationError , match = "unknown attestation type: foo" ):
348+ attestation .verify (verifier , pol , artifact_path )
349+
315350
316351def test_from_bundle_missing_signatures () -> None :
317352 bundle = Bundle .from_json (bundle_path .read_bytes ())
0 commit comments