21
21
from cryptography .x509 import load_pem_x509_certificate
22
22
from sigstore_protobuf_specs .dev .sigstore .common .v1 import TimeRange
23
23
24
- from sigstore ._internal .trustroot import CustomTrustedRoot , _is_timerange_valid
24
+ from sigstore ._internal .trustroot import TrustedRoot , _is_timerange_valid
25
25
from sigstore ._utils import load_der_public_key , load_pem_public_key
26
26
from sigstore .errors import RootError
27
27
@@ -30,10 +30,10 @@ def test_trust_root_tuf_caches_and_requests(mock_staging_tuf, tuf_dirs):
30
30
# start with empty target cache, empty local metadata dir
31
31
data_dir , cache_dir = tuf_dirs
32
32
33
- # keep track of requests the TrustUpdater in CustomTrustedRoot makes
33
+ # keep track of requests the TrustUpdater invoked by TrustedRoot makes
34
34
reqs , fail_reqs = mock_staging_tuf
35
35
36
- trust_root = CustomTrustedRoot .staging ()
36
+ trust_root = TrustedRoot .staging ()
37
37
# metadata was "downloaded" from staging
38
38
expected = ["root.json" , "snapshot.json" , "targets.json" , "timestamp.json" ]
39
39
assert sorted (os .listdir (data_dir )) == expected
@@ -58,7 +58,7 @@ def test_trust_root_tuf_caches_and_requests(mock_staging_tuf, tuf_dirs):
58
58
assert fail_reqs == expected_fail_reqs
59
59
60
60
# New trust root (and TrustUpdater instance), same cache dirs
61
- trust_root = CustomTrustedRoot .staging ()
61
+ trust_root = TrustedRoot .staging ()
62
62
63
63
# Expect new timestamp and root requests
64
64
expected_requests ["timestamp.json" ] += 1
@@ -77,10 +77,10 @@ def test_trust_root_tuf_offline(mock_staging_tuf, tuf_dirs):
77
77
# start with empty target cache, empty local metadata dir
78
78
data_dir , cache_dir = tuf_dirs
79
79
80
- # keep track of requests the TrustUpdater in CustomTrustedRoot makes
80
+ # keep track of requests the TrustUpdater invoked by TrustedRoot makes
81
81
reqs , fail_reqs = mock_staging_tuf
82
82
83
- trust_root = CustomTrustedRoot .staging (offline = True )
83
+ trust_root = TrustedRoot .staging (offline = True )
84
84
85
85
# Only the embedded root is in local TUF metadata, nothing is downloaded
86
86
expected = ["root.json" ]
@@ -161,39 +161,39 @@ def _pem_keys(keys):
161
161
]
162
162
163
163
# Assert that trust root from TUF contains the expected keys/certs
164
- trust_root = CustomTrustedRoot .staging ()
164
+ trust_root = TrustedRoot .staging ()
165
165
assert _der_keys (trust_root .get_ctfe_keys ()) == ctfe_keys
166
166
assert _der_keys (trust_root .get_rekor_keys ()) == rekor_keys
167
167
assert trust_root .get_fulcio_certs () == fulcio_certs
168
168
169
169
# Assert that trust root from offline TUF contains the expected keys/certs
170
- trust_root = CustomTrustedRoot .staging (offline = True )
170
+ trust_root = TrustedRoot .staging (offline = True )
171
171
assert _der_keys (trust_root .get_ctfe_keys ()) == ctfe_keys
172
172
assert _der_keys (trust_root .get_rekor_keys ()) == rekor_keys
173
173
assert trust_root .get_fulcio_certs () == fulcio_certs
174
174
175
175
# Assert that trust root from file contains the expected keys/certs
176
176
path = tuf_asset .target_path ("trusted_root.json" )
177
- trust_root = CustomTrustedRoot .from_file (path )
177
+ trust_root = TrustedRoot .from_file (path )
178
178
assert _der_keys (trust_root .get_ctfe_keys ()) == ctfe_keys
179
179
assert _der_keys (trust_root .get_rekor_keys ()) == rekor_keys
180
180
assert trust_root .get_fulcio_certs () == fulcio_certs
181
181
182
182
183
183
def test_trust_root_tuf_instance_error ():
184
184
with pytest .raises (RootError ):
185
- CustomTrustedRoot .from_tuf ("foo.bar" )
185
+ TrustedRoot .from_tuf ("foo.bar" )
186
186
187
187
188
188
def test_trust_root_tuf_ctfe_keys_error (monkeypatch ):
189
- trust_root = CustomTrustedRoot .staging (offline = True )
189
+ trust_root = TrustedRoot .staging (offline = True )
190
190
monkeypatch .setattr (trust_root , "ctlogs" , [])
191
191
with pytest .raises (Exception , match = "Active CTFE keys not found in trusted root" ):
192
192
trust_root .get_ctfe_keys ()
193
193
194
194
195
195
def test_trust_root_fulcio_certs_error (tuf_asset , monkeypatch ):
196
- trust_root = CustomTrustedRoot .staging (offline = True )
196
+ trust_root = TrustedRoot .staging (offline = True )
197
197
monkeypatch .setattr (trust_root , "certificate_authorities" , [])
198
198
with pytest .raises (
199
199
Exception , match = "Fulcio certificates not found in trusted root"
0 commit comments