@@ -156,7 +156,7 @@ def test_verify_from_gitlab_publisher(self) -> None:
156156 workflow_filepath = ".gitlab-ci.yml" ,
157157 )
158158
159- attestation = impl .Attestation .model_validate_json (gl_attestation_path .read_text ())
159+ attestation = impl .Attestation .model_validate_json (gl_attestation_path .read_bytes ())
160160 predicate_type , predicate = attestation .verify (publisher , gl_signed_dist )
161161 assert predicate_type == "https://docs.pypi.org/attestations/publish/v1"
162162 assert predicate is None
@@ -179,7 +179,7 @@ def test_verify_from_gitlab_publisher_wrong(self) -> None:
179179 workflow_filepath = "wrong.yml" ,
180180 )
181181
182- attestation = impl .Attestation .model_validate_json (gl_attestation_path .read_text ())
182+ attestation = impl .Attestation .model_validate_json (gl_attestation_path .read_bytes ())
183183 with pytest .raises (impl .VerificationError , match = r"Build Config URI .+ does not match" ):
184184 attestation .verify (publisher , gl_signed_dist )
185185
@@ -189,7 +189,7 @@ def test_verify(self) -> None:
189189 identity = "william@yossarian.net" , issuer = "https://github.com/login/oauth"
190190 )
191191
192- attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_text ())
192+ attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_bytes ())
193193 predicate_type , predicate = attestation .verify (pol , dist , staging = True )
194194
195195 assert attestation .statement ["_type" ] == "https://in-toto.io/Statement/v1"
@@ -210,7 +210,7 @@ def test_verify_digest_mismatch(self, tmp_path: Path) -> None:
210210 identity = "william@yossarian.net" , issuer = "https://github.com/login/oauth"
211211 )
212212
213- attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_text ())
213+ attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_bytes ())
214214
215215 modified_dist_path = tmp_path / dist_path .name
216216 modified_dist_path .write_bytes (b"nothing" )
@@ -229,7 +229,7 @@ def test_verify_filename_mismatch(self, tmp_path: Path) -> None:
229229 identity = "william@yossarian.net" , issuer = "https://github.com/login/oauth"
230230 )
231231
232- attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_text ())
232+ attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_bytes ())
233233
234234 modified_dist_path = tmp_path / "wrong_name-0.1.2-py3-none-any.whl"
235235 modified_dist_path .write_bytes (dist_path .read_bytes ())
@@ -246,7 +246,7 @@ def test_verify_policy_mismatch(self) -> None:
246246 # Wrong identity.
247247 pol = policy .Identity (identity = "fake@example.com" , issuer = "https://github.com/login/oauth" )
248248
249- attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_text ())
249+ attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_bytes ())
250250
251251 with pytest .raises (impl .VerificationError , match = r"Certificate's SANs do not match" ):
252252 attestation .verify (pol , dist , staging = True )
@@ -260,7 +260,7 @@ def test_verify_wrong_envelope(self, monkeypatch: pytest.MonkeyPatch) -> None:
260260 monkeypatch .setattr (impl .Verifier , "staging" , staging )
261261 pol = pretend .stub ()
262262
263- attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_text ())
263+ attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_bytes ())
264264
265265 with pytest .raises (impl .VerificationError , match = "expected JSON envelope, got fake-type" ):
266266 attestation .verify (pol , dist , staging = True )
@@ -276,7 +276,7 @@ def test_verify_bad_payload(self, monkeypatch: pytest.MonkeyPatch) -> None:
276276 monkeypatch .setattr (impl .Verifier , "staging" , staging )
277277 pol = pretend .stub ()
278278
279- attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_text ())
279+ attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_bytes ())
280280
281281 with pytest .raises (impl .VerificationError , match = "invalid statement" ):
282282 attestation .verify (pol , dist , staging = True )
@@ -308,7 +308,7 @@ def test_verify_too_many_subjects(self, monkeypatch: pytest.MonkeyPatch) -> None
308308 monkeypatch .setattr (impl .Verifier , "staging" , staging )
309309 pol = pretend .stub ()
310310
311- attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_text ())
311+ attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_bytes ())
312312
313313 with pytest .raises (impl .VerificationError , match = "too many subjects in statement" ):
314314 attestation .verify (pol , dist , staging = True )
@@ -339,7 +339,7 @@ def test_verify_subject_missing_name(self, monkeypatch: pytest.MonkeyPatch) -> N
339339 monkeypatch .setattr (impl .Verifier , "staging" , staging )
340340 pol = pretend .stub ()
341341
342- attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_text ())
342+ attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_bytes ())
343343
344344 with pytest .raises (impl .VerificationError , match = "invalid subject: missing name" ):
345345 attestation .verify (pol , dist , staging = True )
@@ -373,7 +373,7 @@ def test_verify_subject_invalid_name(self, monkeypatch: pytest.MonkeyPatch) -> N
373373 monkeypatch .setattr (impl .Verifier , "staging" , staging )
374374 pol = pretend .stub ()
375375
376- attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_text ())
376+ attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_bytes ())
377377
378378 with pytest .raises (impl .VerificationError , match = "invalid subject: Invalid wheel filename" ):
379379 attestation .verify (pol , dist , staging = True )
@@ -413,14 +413,14 @@ def test_verify_unknown_attestation_type(self, monkeypatch: pytest.MonkeyPatch)
413413 monkeypatch .setattr (impl .Verifier , "staging" , staging )
414414 pol = pretend .stub ()
415415
416- attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_text ())
416+ attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_bytes ())
417417
418418 with pytest .raises (impl .VerificationError , match = "unknown attestation type: foo" ):
419419 attestation .verify (pol , dist , staging = True )
420420
421421 def test_certificate_claims (self ) -> None :
422422 attestation = impl .Attestation .model_validate_json (
423- pypi_attestations_attestation .read_text ()
423+ pypi_attestations_attestation .read_bytes ()
424424 )
425425
426426 results = {
0 commit comments