From 5d3c2eb1441abc0f039dfd67607f5d9fb3c27284 Mon Sep 17 00:00:00 2001 From: Ramon Petgrave Date: Thu, 22 May 2025 18:10:43 +0000 Subject: [PATCH 1/3] use new signing generator in fixtures Signed-off-by: Ramon Petgrave --- test/unit/conftest.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/test/unit/conftest.py b/test/unit/conftest.py index 44adac27..768625cb 100644 --- a/test/unit/conftest.py +++ b/test/unit/conftest.py @@ -37,6 +37,7 @@ from sigstore._internal import tuf from sigstore._internal.rekor import _hashedrekord_from_parts from sigstore._internal.rekor.client import RekorClient +from sigstore._internal.trust import ClientTrustConfig from sigstore._utils import sha256_digest from sigstore.models import Bundle from sigstore.oidc import _DEFAULT_AUDIENCE, IdentityToken @@ -188,10 +189,20 @@ def sign_ctx_and_ident_for_env( pytestconfig, env: str, ) -> tuple[type[SigningContext], type[IdentityToken]]: + """ + Returns a SigningContext and IdentityToken for the given environment. + The SigningContext is behind a callable so that it may be lazily evaluated. + """ if env == "staging": - ctx_cls = SigningContext.staging + + def ctx_cls(): + return SigningContext.from_trust_config(ClientTrustConfig.staging()) + elif env == "production": - ctx_cls = SigningContext.production + + def ctx_cls(): + return SigningContext.from_trust_config(ClientTrustConfig.production()) + else: raise ValueError(f"Unknown env {env}") @@ -205,7 +216,14 @@ def sign_ctx_and_ident_for_env( @pytest.fixture def staging() -> tuple[type[SigningContext], type[Verifier], IdentityToken]: - signer = SigningContext.staging + """ + Returns a SigningContext, Verifier, and IdentityToken for the staging environment. + The SigningContext and Verifier are both behind callables so that they may be lazily evaluated. + """ + + def signer(): + return SigningContext.from_trust_config(ClientTrustConfig.staging()) + verifier = Verifier.staging # Detect env variable for local interactive tests. From 8eda412a4eb93766e4ae5112134cc51082c2bbb8 Mon Sep 17 00:00:00 2001 From: Ramon Petgrave Date: Thu, 22 May 2025 18:19:36 +0000 Subject: [PATCH 2/3] changelog Signed-off-by: Ramon Petgrave --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 485dc9e3..92c84857 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,10 @@ All versions prior to 0.9.0 are untracked. [sigstore/timestamp-authority](https://github.com/sigstore/timestamp-authority) [#1377](https://github.com/sigstore/sigstore-python/pull/1377) +* Tests: Update the `staging` and `sign_ctx_and_ident_for_env` fixtures to use the new methods + for generating a `SigningContext`. + [#1409](https://github.com/sigstore/sigstore-python/pull/1409) + ### Changed * API: From dac84b212d64508c421c80bbca410e8a1b7042ec Mon Sep 17 00:00:00 2001 From: Ramon Petgrave Date: Thu, 22 May 2025 18:20:10 +0000 Subject: [PATCH 3/3] changelog: past tense Signed-off-by: Ramon Petgrave --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92c84857..963af4a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,7 +36,7 @@ All versions prior to 0.9.0 are untracked. [sigstore/timestamp-authority](https://github.com/sigstore/timestamp-authority) [#1377](https://github.com/sigstore/sigstore-python/pull/1377) -* Tests: Update the `staging` and `sign_ctx_and_ident_for_env` fixtures to use the new methods +* Tests: Updated the `staging` and `sign_ctx_and_ident_for_env` fixtures to use the new methods for generating a `SigningContext`. [#1409](https://github.com/sigstore/sigstore-python/pull/1409)