Skip to content

Commit 832f87d

Browse files
reorganize fixtures
Signed-off-by: Ramon Petgrave <[email protected]>
1 parent 79f967c commit 832f87d

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

test/unit/internal/rekor/test_client_v2.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,33 @@ def sample_hashed_rekord_request_materials(
6969
return hashed_input, signature, cert
7070

7171

72+
@pytest.fixture()
73+
def sample_dsse_request_materials(sample_signer) -> tuple[dsse.Envelope, Certificate]:
74+
"""
75+
Creates materials needed for `RekorV2Client._build_dsse_create_entry_request`.
76+
"""
77+
cert = sample_signer._signing_cert()
78+
stmt = (
79+
dsse.StatementBuilder()
80+
.subjects(
81+
[
82+
dsse.Subject(
83+
name="null", digest={"sha256": hashlib.sha256(b"").hexdigest()}
84+
)
85+
]
86+
)
87+
.predicate_type("https://cosign.sigstore.dev/attestation/v1")
88+
.predicate(
89+
{
90+
"Data": "",
91+
"Timestamp": "2023-12-07T00:37:58Z",
92+
}
93+
)
94+
).build()
95+
envelope = dsse._sign(key=sample_signer._private_key, stmt=stmt)
96+
return envelope, cert
97+
98+
7299
@pytest.fixture()
73100
def sample_hashed_rekord_create_entry_request(
74101
sample_hashed_rekord_request_materials,
@@ -110,33 +137,6 @@ def sample_create_entry_request(request) -> v2.CreateEntryRequest:
110137
return request.getfixturevalue(request.param.__name__)
111138

112139

113-
@pytest.fixture()
114-
def sample_dsse_request_materials(sample_signer) -> tuple[dsse.Envelope, Certificate]:
115-
"""
116-
Creates materials needed for `RekorV2Client._build_dsse_create_entry_request`.
117-
"""
118-
cert = sample_signer._signing_cert()
119-
stmt = (
120-
dsse.StatementBuilder()
121-
.subjects(
122-
[
123-
dsse.Subject(
124-
name="null", digest={"sha256": hashlib.sha256(b"").hexdigest()}
125-
)
126-
]
127-
)
128-
.predicate_type("https://cosign.sigstore.dev/attestation/v1")
129-
.predicate(
130-
{
131-
"Data": "",
132-
"Timestamp": "2023-12-07T00:37:58Z",
133-
}
134-
)
135-
).build()
136-
envelope = dsse._sign(key=sample_signer._private_key, stmt=stmt)
137-
return envelope, cert
138-
139-
140140
@pytest.mark.ambient_oidc
141141
def test_build_hashed_rekord_create_entry_request(
142142
sample_hashed_rekord_request_materials,

0 commit comments

Comments
 (0)