@@ -181,6 +181,11 @@ def test_sign_verify(self):
181
181
with self .assertRaises (exceptions .UnsignedMetadataError ):
182
182
snapshot_key .verify_signature (metadata_obj )
183
183
184
+ # Test verifying with explicitly set serializer
185
+ targets_key .verify_signature (metadata_obj , CanonicalJSONSerializer ())
186
+ with self .assertRaises (exceptions .UnsignedMetadataError ):
187
+ targets_key .verify_signature (metadata_obj , JSONSerializer ())
188
+
184
189
sslib_signer = SSlibSigner (self .keystore ['snapshot' ])
185
190
# Append a new signature with the unrelated key and assert that ...
186
191
metadata_obj .sign (sslib_signer , append = True )
@@ -200,6 +205,32 @@ def test_sign_verify(self):
200
205
with self .assertRaises (exceptions .UnsignedMetadataError ):
201
206
targets_key .verify_signature (metadata_obj )
202
207
208
+ # Test failure on unknown scheme (securesystemslib UnsupportedAlgorithmError)
209
+ scheme = timestamp_key .scheme
210
+ timestamp_key .scheme = "foo"
211
+ with self .assertRaises (exceptions .UnsignedMetadataError ):
212
+ timestamp_key .verify_signature (metadata_obj )
213
+ timestamp_key .scheme = scheme
214
+
215
+ # Test failure on broken public key data (securesystemslib CryptoError)
216
+ public = timestamp_key .keyval ["public" ]
217
+ timestamp_key .keyval ["public" ] = "ffff"
218
+ with self .assertRaises (exceptions .UnsignedMetadataError ):
219
+ timestamp_key .verify_signature (metadata_obj )
220
+ timestamp_key .keyval ["public" ] = public
221
+
222
+ # Test failure with invalid signature (securesystemslib FormatError)
223
+ sig = metadata_obj .signatures [timestamp_keyid ]
224
+ correct_sig = sig .signature
225
+ sig .signature = "foo"
226
+ with self .assertRaises (exceptions .UnsignedMetadataError ):
227
+ timestamp_key .verify_signature (metadata_obj )
228
+
229
+ # Test failure with valid but incorrect signature
230
+ sig .signature = "ff" * 64
231
+ with self .assertRaises (exceptions .UnsignedMetadataError ):
232
+ timestamp_key .verify_signature (metadata_obj )
233
+ sig .signature = correct_sig
203
234
204
235
def test_metadata_base (self ):
205
236
# Use of Snapshot is arbitrary, we're just testing the base class features
0 commit comments