Skip to content

Commit f47ef16

Browse files
test with missing inclusion promise
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
1 parent c3d70e9 commit f47ef16

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

test/unit/verify/test_verifier.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from sigstore._internal.trust import CertificateAuthority
2525
from sigstore.dsse import StatementBuilder, Subject
2626
from sigstore.errors import VerificationError
27-
from sigstore.models import Bundle
27+
from sigstore.models import Bundle, LogEntry
2828
from sigstore.verify import policy
2929
from sigstore.verify.verifier import Verifier
3030

@@ -222,6 +222,35 @@ def test_verifier_no_validity_end(self, verifier, asset, null_policy):
222222
null_policy,
223223
)
224224

225+
@pytest.mark.parametrize(
226+
"fields_to_delete",
227+
(
228+
[],
229+
["inclusionPromise"],
230+
# integratedTime is required to verify the inclusionPromise.
231+
pytest.param(["integratedTime"], marks=pytest.mark.xfail),
232+
["inclusionPromise", "integratedTime"],
233+
),
234+
)
235+
def test_vierifier_verify_no_inclusion_promise_and_integrated_time(
236+
self, verifier, asset, null_policy, fields_to_delete
237+
):
238+
"""
239+
Ensure that we can still verify a Bundle with a rfc3161 timestamp if the SET can't be verified or isn't present.
240+
There is one exception: When inclusionPromise is present, but integratedTime is not, then we expect a failure
241+
because the integratedTime is required to verify the inclusionPromise.
242+
"""
243+
bundle = Bundle.from_json(asset("tsa/bundle.txt.sigstore").read_bytes())
244+
_dict = bundle.log_entry._to_rekor().to_dict()
245+
for field in fields_to_delete:
246+
del _dict[field]
247+
bundle._log_entry = LogEntry._from_dict_rekor(_dict)
248+
verifier.verify_artifact(
249+
asset("tsa/bundle.txt").read_bytes(),
250+
bundle,
251+
null_policy,
252+
)
253+
225254
def test_verifier_without_timestamp(
226255
self, verifier, asset, null_policy, monkeypatch
227256
):

0 commit comments

Comments
 (0)