Skip to content

Commit 761a76d

Browse files
committed
Add test that signs multiple artifacts with rekor2
Signed-off-by: Jussi Kukkonen <[email protected]>
1 parent 9d6455e commit 761a76d

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

test/integration/cli/test_sign.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@ def get_cli_params(
2929
bundle_path: Optional[Path] = None,
3030
signature_path: Optional[Path] = None,
3131
certificate_path: Optional[Path] = None,
32+
trust_config_path: Optional[Path] = None,
3233
) -> list[str]:
33-
cli_params = ["--staging", "sign"]
34+
if trust_config_path is not None:
35+
cli_params = ["--trust-config", str(trust_config_path), "sign"]
36+
else:
37+
cli_params = ["--staging", "sign"]
38+
3439
if output_directory is not None:
3540
cli_params.extend(["--output-directory", str(output_directory)])
3641
if bundle_path is not None:
@@ -116,6 +121,47 @@ def test_sign_success_multiple_artifacts(capsys, sigstore, asset_integration):
116121
)
117122

118123

124+
@pytest.mark.staging
125+
@pytest.mark.ambient_oidc
126+
def test_sign_success_multiple_artifacts_rekor_v2(capsys, sigstore, asset_integration, asset):
127+
"""This is a copy of test_sign_success_multiple_artifacts that exists to ensure the
128+
multi-threaded signing works with rekor v2 as well: this test can be removed when v2
129+
is the default
130+
"""
131+
132+
artifacts = [
133+
asset_integration("a.txt"),
134+
asset_integration("b.txt"),
135+
asset_integration("c.txt"),
136+
]
137+
138+
sigstore(
139+
*get_cli_params(
140+
artifact_paths=artifacts,
141+
trust_config_path=asset("trust_config/staging-but-sign-with-rekor-v2.json")
142+
)
143+
)
144+
145+
captures = capsys.readouterr()
146+
147+
for artifact in artifacts:
148+
expected_output_bundle = Path(f"{artifact}.sigstore.json")
149+
150+
assert f"Sigstore bundle written to {expected_output_bundle}\n" in captures.out
151+
152+
assert expected_output_bundle.exists()
153+
verifier = Verifier.staging()
154+
with (
155+
open(expected_output_bundle, "r") as bundle_file,
156+
open(artifact, "rb") as input_file,
157+
):
158+
bundle = Bundle.from_json(bundle_file.read())
159+
expected_output_bundle.unlink()
160+
verifier.verify_artifact(
161+
input_=input_file.read(), bundle=bundle, policy=UnsafeNoOp()
162+
)
163+
164+
119165
@pytest.mark.staging
120166
@pytest.mark.ambient_oidc
121167
def test_sign_success_custom_outputs(capsys, sigstore, asset_integration, tmp_path):

0 commit comments

Comments
 (0)