Skip to content

Commit 7a9e45d

Browse files
committed
add --upgrade-version integration test
Signed-off-by: William Woodruff <william@trailofbits.com>
1 parent c818b76 commit 7a9e45d

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

test/integration/cli/test_plumbing.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,50 @@ def test_fix_bundle_fixes_missing_checkpoint(capsys, sigstore, asset):
4040
# The bundle now loads correctly.
4141
bundle = Bundle.from_json(captures.out)
4242

43-
# ...and can now be used to verify the `Python-3.12.5.tgz` release.
43+
# We didn't pass `--upgrade-version` so the version is still v0.1.
44+
assert bundle._inner.media_type == Bundle.BundleType.BUNDLE_0_1
45+
46+
# ...and the fixed bundle can now be used to verify the `Python-3.12.5.tgz`
47+
# release.
48+
verifier = Verifier.production()
49+
verifier.verify_artifact(
50+
Hashed(
51+
algorithm=HashAlgorithm.SHA2_256,
52+
digest=bytes.fromhex(
53+
"38dc4e2c261d49c661196066edbfb70fdb16be4a79cc8220c224dfeb5636d405"
54+
),
55+
),
56+
bundle,
57+
policy.AllOf(
58+
[
59+
policy.Identity(
60+
identity="thomas@python.org", issuer="https://accounts.google.com"
61+
)
62+
]
63+
),
64+
)
65+
66+
67+
def test_fix_bundle_upgrades_bundle(capsys, sigstore, asset):
68+
invalid_bundle = asset("Python-3.12.5.tgz.sigstore")
69+
70+
# Running `sigstore plumbing fix-bundle --upgrade-version`
71+
# emits a fixed bundle.
72+
sigstore(
73+
"plumbing", "fix-bundle", "--upgrade-version", "--bundle", str(invalid_bundle)
74+
)
75+
76+
captures = capsys.readouterr()
77+
78+
# The bundle now loads correctly.
79+
bundle = Bundle.from_json(captures.out)
80+
81+
# The bundle is now the latest version (v0.3).
82+
assert bundle._inner.media_type == Bundle.BundleType.BUNDLE_0_3
83+
84+
# ...and the upgraded (and fixed) bundle can still verify
85+
# the release.
86+
# ...and the fixed can now be used to verify the `Python-3.12.5.tgz` release.
4487
verifier = Verifier.production()
4588
verifier.verify_artifact(
4689
Hashed(

0 commit comments

Comments
 (0)