@@ -45,18 +45,25 @@ def client(request) -> RekorV2Client:
45
45
46
46
47
47
@pytest .fixture ()
48
- def sample_hashed_rekord_request_materials (
49
- staging ,
50
- ) -> tuple [Hashed , bytes , Certificate ]:
48
+ def sample_signer (staging ):
51
49
"""
52
- Creates materials needed for `RekorV2Client._build_hashed_rekord_create_entry_request `.
50
+ Returns a `Signer `.
53
51
"""
54
52
sign_ctx_cls , _ , id_token = staging
55
53
with sign_ctx_cls ().signer (id_token ) as signer :
56
- cert = signer . _signing_cert ()
54
+ return signer
57
55
56
+
57
+ @pytest .fixture ()
58
+ def sample_hashed_rekord_request_materials (
59
+ sample_signer ,
60
+ ) -> tuple [Hashed , bytes , Certificate ]:
61
+ """
62
+ Creates materials needed for `RekorV2Client._build_hashed_rekord_create_entry_request`.
63
+ """
64
+ cert = sample_signer ._signing_cert ()
58
65
hashed_input = sha256_digest (secrets .token_bytes (32 ))
59
- signature = signer ._private_key .sign (
66
+ signature = sample_signer ._private_key .sign (
60
67
hashed_input .digest , ec .ECDSA (hashed_input ._as_prehashed ())
61
68
)
62
69
return hashed_input , signature , cert
@@ -104,13 +111,11 @@ def sample_create_entry_request(request) -> v2.CreateEntryRequest:
104
111
105
112
106
113
@pytest .fixture ()
107
- def sample_dsse_request_materials (staging ) -> tuple [dsse .Envelope , Certificate ]:
114
+ def sample_dsse_request_materials (sample_signer ) -> tuple [dsse .Envelope , Certificate ]:
108
115
"""
109
116
Creates materials needed for `RekorV2Client._build_dsse_create_entry_request`.
110
117
"""
111
- sign_ctx_cls , _ , id_token = staging
112
- with sign_ctx_cls ().signer (id_token ) as signer :
113
- cert = signer ._signing_cert ()
118
+ cert = sample_signer ._signing_cert ()
114
119
stmt = (
115
120
dsse .StatementBuilder ()
116
121
.subjects (
@@ -128,7 +133,7 @@ def sample_dsse_request_materials(staging) -> tuple[dsse.Envelope, Certificate]:
128
133
}
129
134
)
130
135
).build ()
131
- envelope = dsse ._sign (key = signer ._private_key , stmt = stmt )
136
+ envelope = dsse ._sign (key = sample_signer ._private_key , stmt = stmt )
132
137
return envelope , cert
133
138
134
139
0 commit comments