@@ -156,7 +156,7 @@ def test_verify_from_gitlab_publisher(self) -> None:
156
156
workflow_filepath = ".gitlab-ci.yml" ,
157
157
)
158
158
159
- attestation = impl .Attestation .model_validate_json (gl_attestation_path .read_text ())
159
+ attestation = impl .Attestation .model_validate_json (gl_attestation_path .read_bytes ())
160
160
predicate_type , predicate = attestation .verify (publisher , gl_signed_dist )
161
161
assert predicate_type == "https://docs.pypi.org/attestations/publish/v1"
162
162
assert predicate is None
@@ -179,7 +179,7 @@ def test_verify_from_gitlab_publisher_wrong(self) -> None:
179
179
workflow_filepath = "wrong.yml" ,
180
180
)
181
181
182
- attestation = impl .Attestation .model_validate_json (gl_attestation_path .read_text ())
182
+ attestation = impl .Attestation .model_validate_json (gl_attestation_path .read_bytes ())
183
183
with pytest .raises (impl .VerificationError , match = r"Build Config URI .+ does not match" ):
184
184
attestation .verify (publisher , gl_signed_dist )
185
185
@@ -189,7 +189,7 @@ def test_verify(self) -> None:
189
189
identity = "[email protected] " ,
issuer = "https://github.com/login/oauth"
190
190
)
191
191
192
- attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_text ())
192
+ attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_bytes ())
193
193
predicate_type , predicate = attestation .verify (pol , dist , staging = True )
194
194
195
195
assert attestation .statement ["_type" ] == "https://in-toto.io/Statement/v1"
@@ -210,7 +210,7 @@ def test_verify_digest_mismatch(self, tmp_path: Path) -> None:
210
210
identity = "[email protected] " ,
issuer = "https://github.com/login/oauth"
211
211
)
212
212
213
- attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_text ())
213
+ attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_bytes ())
214
214
215
215
modified_dist_path = tmp_path / dist_path .name
216
216
modified_dist_path .write_bytes (b"nothing" )
@@ -229,7 +229,7 @@ def test_verify_filename_mismatch(self, tmp_path: Path) -> None:
229
229
identity = "[email protected] " ,
issuer = "https://github.com/login/oauth"
230
230
)
231
231
232
- attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_text ())
232
+ attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_bytes ())
233
233
234
234
modified_dist_path = tmp_path / "wrong_name-0.1.2-py3-none-any.whl"
235
235
modified_dist_path .write_bytes (dist_path .read_bytes ())
@@ -246,7 +246,7 @@ def test_verify_policy_mismatch(self) -> None:
246
246
# Wrong identity.
247
247
pol = policy .
Identity (
identity = "[email protected] " ,
issuer = "https://github.com/login/oauth" )
248
248
249
- attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_text ())
249
+ attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_bytes ())
250
250
251
251
with pytest .raises (impl .VerificationError , match = r"Certificate's SANs do not match" ):
252
252
attestation .verify (pol , dist , staging = True )
@@ -260,7 +260,7 @@ def test_verify_wrong_envelope(self, monkeypatch: pytest.MonkeyPatch) -> None:
260
260
monkeypatch .setattr (impl .Verifier , "staging" , staging )
261
261
pol = pretend .stub ()
262
262
263
- attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_text ())
263
+ attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_bytes ())
264
264
265
265
with pytest .raises (impl .VerificationError , match = "expected JSON envelope, got fake-type" ):
266
266
attestation .verify (pol , dist , staging = True )
@@ -276,7 +276,7 @@ def test_verify_bad_payload(self, monkeypatch: pytest.MonkeyPatch) -> None:
276
276
monkeypatch .setattr (impl .Verifier , "staging" , staging )
277
277
pol = pretend .stub ()
278
278
279
- attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_text ())
279
+ attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_bytes ())
280
280
281
281
with pytest .raises (impl .VerificationError , match = "invalid statement" ):
282
282
attestation .verify (pol , dist , staging = True )
@@ -308,7 +308,7 @@ def test_verify_too_many_subjects(self, monkeypatch: pytest.MonkeyPatch) -> None
308
308
monkeypatch .setattr (impl .Verifier , "staging" , staging )
309
309
pol = pretend .stub ()
310
310
311
- attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_text ())
311
+ attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_bytes ())
312
312
313
313
with pytest .raises (impl .VerificationError , match = "too many subjects in statement" ):
314
314
attestation .verify (pol , dist , staging = True )
@@ -339,7 +339,7 @@ def test_verify_subject_missing_name(self, monkeypatch: pytest.MonkeyPatch) -> N
339
339
monkeypatch .setattr (impl .Verifier , "staging" , staging )
340
340
pol = pretend .stub ()
341
341
342
- attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_text ())
342
+ attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_bytes ())
343
343
344
344
with pytest .raises (impl .VerificationError , match = "invalid subject: missing name" ):
345
345
attestation .verify (pol , dist , staging = True )
@@ -373,7 +373,7 @@ def test_verify_subject_invalid_name(self, monkeypatch: pytest.MonkeyPatch) -> N
373
373
monkeypatch .setattr (impl .Verifier , "staging" , staging )
374
374
pol = pretend .stub ()
375
375
376
- attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_text ())
376
+ attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_bytes ())
377
377
378
378
with pytest .raises (impl .VerificationError , match = "invalid subject: Invalid wheel filename" ):
379
379
attestation .verify (pol , dist , staging = True )
@@ -413,14 +413,14 @@ def test_verify_unknown_attestation_type(self, monkeypatch: pytest.MonkeyPatch)
413
413
monkeypatch .setattr (impl .Verifier , "staging" , staging )
414
414
pol = pretend .stub ()
415
415
416
- attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_text ())
416
+ attestation = impl .Attestation .model_validate_json (dist_attestation_path .read_bytes ())
417
417
418
418
with pytest .raises (impl .VerificationError , match = "unknown attestation type: foo" ):
419
419
attestation .verify (pol , dist , staging = True )
420
420
421
421
def test_certificate_claims (self ) -> None :
422
422
attestation = impl .Attestation .model_validate_json (
423
- pypi_attestations_attestation .read_text ()
423
+ pypi_attestations_attestation .read_bytes ()
424
424
)
425
425
426
426
results = {
0 commit comments