diff --git a/CHANGELOG.md b/CHANGELOG.md index 485dc9e3..963af4a0 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: 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) + ### Changed * API: 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.