@@ -56,14 +56,16 @@ def get_cli_params(
56
56
57
57
@pytest .mark .staging
58
58
@pytest .mark .ambient_oidc
59
- def test_sign_success_default_output_bundle (capsys , sigstore , asset_integration ):
59
+ def test_sign_success_default_output_bundle (
60
+ capsys , sigstore , asset_integration , tmp_path
61
+ ):
60
62
artifact = asset_integration ("a.txt" )
61
- expected_output_bundle = artifact . with_name ( "a.txt.sigstore.json" )
63
+ expected_output_bundle = tmp_path / "a.txt.sigstore.json"
62
64
63
- assert not expected_output_bundle .exists ()
64
65
sigstore (
65
66
* get_cli_params (
66
67
artifact_paths = [artifact ],
68
+ output_directory = tmp_path ,
67
69
)
68
70
)
69
71
@@ -78,8 +80,6 @@ def test_sign_success_default_output_bundle(capsys, sigstore, asset_integration)
78
80
input_ = input_file .read (), bundle = bundle , policy = UnsafeNoOp ()
79
81
)
80
82
81
- expected_output_bundle .unlink ()
82
-
83
83
captures = capsys .readouterr ()
84
84
assert captures .out .endswith (
85
85
f"Sigstore bundle written to { expected_output_bundle } \n "
@@ -88,8 +88,8 @@ def test_sign_success_default_output_bundle(capsys, sigstore, asset_integration)
88
88
89
89
@pytest .mark .staging
90
90
@pytest .mark .ambient_oidc
91
- def test_sign_success_multiple_artifacts (capsys , sigstore , asset_integration ):
92
- artifacts = [
91
+ def test_sign_success_multiple_artifacts (capsys , sigstore , asset_integration , tmp_path ):
92
+ artifacts : list [ Path ] = [
93
93
asset_integration ("a.txt" ),
94
94
asset_integration ("b.txt" ),
95
95
asset_integration ("c.txt" ),
@@ -98,13 +98,14 @@ def test_sign_success_multiple_artifacts(capsys, sigstore, asset_integration):
98
98
sigstore (
99
99
* get_cli_params (
100
100
artifact_paths = artifacts ,
101
+ output_directory = tmp_path ,
101
102
)
102
103
)
103
104
104
105
captures = capsys .readouterr ()
105
106
106
107
for artifact in artifacts :
107
- expected_output_bundle = Path ( f"{ artifact } .sigstore.json" )
108
+ expected_output_bundle = tmp_path / f"{ artifact . name } .sigstore.json"
108
109
109
110
assert f"Sigstore bundle written to { expected_output_bundle } \n " in captures .out
110
111
@@ -115,7 +116,6 @@ def test_sign_success_multiple_artifacts(capsys, sigstore, asset_integration):
115
116
open (artifact , "rb" ) as input_file ,
116
117
):
117
118
bundle = Bundle .from_json (bundle_file .read ())
118
- expected_output_bundle .unlink ()
119
119
verifier .verify_artifact (
120
120
input_ = input_file .read (), bundle = bundle , policy = UnsafeNoOp ()
121
121
)
@@ -124,14 +124,14 @@ def test_sign_success_multiple_artifacts(capsys, sigstore, asset_integration):
124
124
@pytest .mark .staging
125
125
@pytest .mark .ambient_oidc
126
126
def test_sign_success_multiple_artifacts_rekor_v2 (
127
- capsys , sigstore , asset_integration , asset
127
+ capsys , sigstore , asset_integration , asset , tmp_path
128
128
):
129
129
"""This is a copy of test_sign_success_multiple_artifacts that exists to ensure the
130
130
multi-threaded signing works with rekor v2 as well: this test can be removed when v2
131
131
is the default
132
132
"""
133
133
134
- artifacts = [
134
+ artifacts : list [ Path ] = [
135
135
asset_integration ("a.txt" ),
136
136
asset_integration ("b.txt" ),
137
137
asset_integration ("c.txt" ),
@@ -141,13 +141,14 @@ def test_sign_success_multiple_artifacts_rekor_v2(
141
141
* get_cli_params (
142
142
artifact_paths = artifacts ,
143
143
trust_config_path = asset ("trust_config/staging-but-sign-with-rekor-v2.json" ),
144
+ output_directory = tmp_path ,
144
145
)
145
146
)
146
147
147
148
captures = capsys .readouterr ()
148
149
149
150
for artifact in artifacts :
150
- expected_output_bundle = Path ( f"{ artifact } .sigstore.json" )
151
+ expected_output_bundle = tmp_path / f"{ artifact . name } .sigstore.json"
151
152
152
153
assert f"Sigstore bundle written to { expected_output_bundle } \n " in captures .out
153
154
@@ -158,7 +159,6 @@ def test_sign_success_multiple_artifacts_rekor_v2(
158
159
open (artifact , "rb" ) as input_file ,
159
160
):
160
161
bundle = Bundle .from_json (bundle_file .read ())
161
- expected_output_bundle .unlink ()
162
162
verifier .verify_artifact (
163
163
input_ = input_file .read (), bundle = bundle , policy = UnsafeNoOp ()
164
164
)
@@ -240,14 +240,14 @@ def test_sign_success_no_default_files(capsys, sigstore, asset_integration, tmp_
240
240
241
241
@pytest .mark .staging
242
242
@pytest .mark .ambient_oidc
243
- def test_sign_overwrite_existing_bundle (capsys , sigstore , asset_integration ):
243
+ def test_sign_overwrite_existing_bundle (capsys , sigstore , asset_integration , tmp_path ):
244
244
artifact = asset_integration ("a.txt" )
245
- expected_output_bundle = artifact . with_name ( "a.txt.sigstore.json" )
245
+ expected_output_bundle = tmp_path / "a.txt.sigstore.json"
246
246
247
- assert not expected_output_bundle .exists ()
248
247
sigstore (
249
248
* get_cli_params (
250
249
artifact_paths = [artifact ],
250
+ output_directory = tmp_path ,
251
251
)
252
252
)
253
253
@@ -256,6 +256,7 @@ def test_sign_overwrite_existing_bundle(capsys, sigstore, asset_integration):
256
256
sigstore (
257
257
* get_cli_params (
258
258
artifact_paths = [artifact ],
259
+ output_directory = tmp_path ,
259
260
overwrite = True ,
260
261
)
261
262
)
@@ -265,6 +266,7 @@ def test_sign_overwrite_existing_bundle(capsys, sigstore, asset_integration):
265
266
sigstore (
266
267
* get_cli_params (
267
268
artifact_paths = [artifact ],
269
+ output_directory = tmp_path ,
268
270
overwrite = False ,
269
271
)
270
272
)
@@ -275,8 +277,6 @@ def test_sign_overwrite_existing_bundle(capsys, sigstore, asset_integration):
275
277
f"Refusing to overwrite outputs without --overwrite: { expected_output_bundle } \n "
276
278
)
277
279
278
- expected_output_bundle .unlink ()
279
-
280
280
281
281
def test_sign_fails_with_default_files_and_bundle_options (
282
282
capsys , sigstore , asset_integration
0 commit comments