From b7ad98df1754d2aff66e1154467b4c0382ce528e Mon Sep 17 00:00:00 2001 From: Lukas Puehringer Date: Thu, 30 Mar 2023 17:35:46 +0200 Subject: [PATCH] test: check all Key.verify_sign fail gracefully Test SSlibKey and SigstoreKey in addition to already tested GPGKey. Signed-off-by: Lukas Puehringer --- tests/check_public_interfaces.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/check_public_interfaces.py b/tests/check_public_interfaces.py index 57f6f9645..312c53c60 100644 --- a/tests/check_public_interfaces.py +++ b/tests/check_public_interfaces.py @@ -43,7 +43,8 @@ UnsupportedLibraryError, VerificationError, ) -from securesystemslib.signer import GPGKey, Key, Signature +from securesystemslib.signer import GPGKey, Key, Signature, SSlibKey +from securesystemslib.signer._sigstore_signer import SigstoreKey class TestPublicInterfaces( @@ -324,13 +325,26 @@ def test_signer_verify(self): keys = [ GPGKey(keyid, "rsa", "pgp+rsa-pkcsv1.5", {"public": "val"}), + SSlibKey(keyid, "rsa", "rsa-pkcs1v15-sha512", {"public": "val"}), + SigstoreKey( + keyid, + "sigstore-oidc", + "Fulcio", + {"identity": "val", "issuer": "val"}, + ), ] for key in keys: with self.assertRaises(VerificationError) as ctx: key.verify_signature(sig, b"data") - self.assertIsInstance( - ctx.exception.__cause__, UnsupportedLibraryError + + from_err = ctx.exception.__cause__ + self.assertTrue( + ( + isinstance(from_err, UnsupportedLibraryError) + or isinstance(from_err, ImportError), + f"unexpected {from_err}", + ) ) def test_signer_ed25519_fallback(self):