Skip to content

Commit cdf6892

Browse files
use new SigningConfig generator in fixtures (#1409)
* use new signing generator in fixtures Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com> * changelog Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com> * changelog: past tense Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com> --------- Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
1 parent 916c2c5 commit cdf6892

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ All versions prior to 0.9.0 are untracked.
3636
[sigstore/timestamp-authority](https://github.com/sigstore/timestamp-authority)
3737
[#1377](https://github.com/sigstore/sigstore-python/pull/1377)
3838

39+
* Tests: Updated the `staging` and `sign_ctx_and_ident_for_env` fixtures to use the new methods
40+
for generating a `SigningContext`.
41+
[#1409](https://github.com/sigstore/sigstore-python/pull/1409)
42+
3943
### Changed
4044

4145
* API:

test/unit/conftest.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from sigstore._internal import tuf
3838
from sigstore._internal.rekor import _hashedrekord_from_parts
3939
from sigstore._internal.rekor.client import RekorClient
40+
from sigstore._internal.trust import ClientTrustConfig
4041
from sigstore._utils import sha256_digest
4142
from sigstore.models import Bundle
4243
from sigstore.oidc import _DEFAULT_AUDIENCE, IdentityToken
@@ -188,10 +189,20 @@ def sign_ctx_and_ident_for_env(
188189
pytestconfig,
189190
env: str,
190191
) -> tuple[type[SigningContext], type[IdentityToken]]:
192+
"""
193+
Returns a SigningContext and IdentityToken for the given environment.
194+
The SigningContext is behind a callable so that it may be lazily evaluated.
195+
"""
191196
if env == "staging":
192-
ctx_cls = SigningContext.staging
197+
198+
def ctx_cls():
199+
return SigningContext.from_trust_config(ClientTrustConfig.staging())
200+
193201
elif env == "production":
194-
ctx_cls = SigningContext.production
202+
203+
def ctx_cls():
204+
return SigningContext.from_trust_config(ClientTrustConfig.production())
205+
195206
else:
196207
raise ValueError(f"Unknown env {env}")
197208

@@ -205,7 +216,14 @@ def sign_ctx_and_ident_for_env(
205216

206217
@pytest.fixture
207218
def staging() -> tuple[type[SigningContext], type[Verifier], IdentityToken]:
208-
signer = SigningContext.staging
219+
"""
220+
Returns a SigningContext, Verifier, and IdentityToken for the staging environment.
221+
The SigningContext and Verifier are both behind callables so that they may be lazily evaluated.
222+
"""
223+
224+
def signer():
225+
return SigningContext.from_trust_config(ClientTrustConfig.staging())
226+
209227
verifier = Verifier.staging
210228

211229
# Detect env variable for local interactive tests.

0 commit comments

Comments
 (0)