Skip to content

use new SigningConfig generator in fixtures #1409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
24 changes: 21 additions & 3 deletions test/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}")

Expand All @@ -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.
Expand Down