@@ -40,11 +40,11 @@ def test_roundtrip(self, id_token: IdentityToken) -> None:
4040 attestation .verify (verifier , policy .UnsafeNoOp (), artifact_path )
4141
4242 # converting to a bundle and verifying as a bundle also works
43- bundle = impl . pypi_to_sigstore ( attestation )
43+ bundle = attestation . to_bundle ( )
4444 verifier .verify_dsse (bundle , policy .UnsafeNoOp ())
4545
4646 # converting back also works
47- roundtripped_attestation = impl .sigstore_to_pypi (bundle )
47+ roundtripped_attestation = impl .Attestation . from_bundle (bundle )
4848 roundtripped_attestation .verify (verifier , policy .UnsafeNoOp (), artifact_path )
4949
5050 def test_sign_invalid_dist_filename (self , tmp_path : Path ) -> None :
@@ -69,7 +69,7 @@ def test_verify_github_attested(self) -> None:
6969 )
7070
7171 bundle = Bundle .from_json (gh_signed_bundle_path .read_bytes ())
72- attestation = impl .sigstore_to_pypi (bundle )
72+ attestation = impl .Attestation . from_bundle (bundle )
7373
7474 predicate_type , predicate = attestation .verify (verifier , pol , gh_signed_artifact_path )
7575 assert predicate_type == "https://docs.pypi.org/attestations/publish/v1"
@@ -89,7 +89,7 @@ def test_verify(self) -> None:
8989 assert predicate is None
9090
9191 # convert the attestation to a bundle and verify it that way too
92- bundle = impl . pypi_to_sigstore ( attestation )
92+ bundle = attestation . to_bundle ( )
9393 verifier .verify_dsse (bundle , policy .UnsafeNoOp ())
9494
9595 def test_verify_digest_mismatch (self , tmp_path : Path ) -> None :
@@ -178,7 +178,10 @@ def test_verify_too_many_subjects(self) -> None:
178178
179179 verifier = pretend .stub (
180180 verify_dsse = pretend .call_recorder (
181- lambda bundle , policy : ("application/vnd.in-toto+json" , statement .encode ())
181+ lambda bundle , policy : (
182+ "application/vnd.in-toto+json" ,
183+ statement .encode (),
184+ )
182185 )
183186 )
184187 pol = pretend .stub ()
@@ -203,7 +206,10 @@ def test_verify_subject_missing_name(self) -> None:
203206
204207 verifier = pretend .stub (
205208 verify_dsse = pretend .call_recorder (
206- lambda bundle , policy : ("application/vnd.in-toto+json" , statement .encode ())
209+ lambda bundle , policy : (
210+ "application/vnd.in-toto+json" ,
211+ statement .encode (),
212+ )
207213 )
208214 )
209215 pol = pretend .stub ()
@@ -219,7 +225,8 @@ def test_verify_subject_invalid_name(self) -> None:
219225 .subjects (
220226 [
221227 _Subject (
222- name = "foo-bar-invalid-wheel.whl" , digest = _DigestSet (root = {"sha256" : "abcd" })
228+ name = "foo-bar-invalid-wheel.whl" ,
229+ digest = _DigestSet (root = {"sha256" : "abcd" }),
223230 ),
224231 ]
225232 )
@@ -230,7 +237,10 @@ def test_verify_subject_invalid_name(self) -> None:
230237
231238 verifier = pretend .stub (
232239 verify_dsse = pretend .call_recorder (
233- lambda bundle , policy : ("application/vnd.in-toto+json" , statement .encode ())
240+ lambda bundle , policy : (
241+ "application/vnd.in-toto+json" ,
242+ statement .encode (),
243+ )
234244 )
235245 )
236246 pol = pretend .stub ()
@@ -241,28 +251,28 @@ def test_verify_subject_invalid_name(self) -> None:
241251 attestation .verify (verifier , pol , artifact_path )
242252
243253
244- def test_sigstore_to_pypi_missing_signatures () -> None :
254+ def test_from_bundle_missing_signatures () -> None :
245255 bundle = Bundle .from_json (bundle_path .read_bytes ())
246256 bundle ._inner .dsse_envelope .signatures = [] # noqa: SLF001
247257
248258 with pytest .raises (impl .ConversionError , match = "expected exactly one signature, got 0" ):
249- impl .sigstore_to_pypi (bundle )
259+ impl .Attestation . from_bundle (bundle )
250260
251261
252- def test_pypi_to_sigstore_invalid_cert () -> None :
262+ def test_to_bundle_invalid_cert () -> None :
253263 attestation = impl .Attestation .model_validate_json (attestation_path .read_bytes ())
254264 attestation .verification_material .certificate = b"foo"
255265
256266 with pytest .raises (impl .ConversionError , match = "invalid X.509 certificate" ):
257- impl . pypi_to_sigstore ( attestation )
267+ attestation . to_bundle ( )
258268
259269
260- def test_pypi_to_sigstore_invalid_tlog_entry () -> None :
270+ def test_to_bundle_invalid_tlog_entry () -> None :
261271 attestation = impl .Attestation .model_validate_json (attestation_path .read_bytes ())
262272 attestation .verification_material .transparency_entries [0 ].clear ()
263273
264274 with pytest .raises (impl .ConversionError , match = "invalid transparency log entry" ):
265- impl . pypi_to_sigstore ( attestation )
275+ attestation . to_bundle ( )
266276
267277
268278class TestPackaging :
@@ -295,7 +305,10 @@ def test_exception_types(self) -> None:
295305 ("foo-1.0-1whatever-py3-none-any.whl" , "foo-1.0-1whatever-py3-none-any.whl" ),
296306 # wheel: compressed tag sets are sorted, even when conflicting or nonsense
297307 ("foo-1.0-py3.py2-none-any.whl" , "foo-1.0-py2.py3-none-any.whl" ),
298- ("foo-1.0-py3.py2-none.abi3.cp37-any.whl" , "foo-1.0-py2.py3-abi3.cp37.none-any.whl" ),
308+ (
309+ "foo-1.0-py3.py2-none.abi3.cp37-any.whl" ,
310+ "foo-1.0-py2.py3-abi3.cp37.none-any.whl" ,
311+ ),
299312 (
300313 "foo-1.0-py3.py2-none.abi3.cp37-linux_x86_64.any.whl" ,
301314 "foo-1.0-py2.py3-abi3.cp37.none-any.linux_x86_64.whl" ,
0 commit comments