Skip to content

Commit

Permalink
test: check all Key.verify_sign fail gracefully
Browse files Browse the repository at this point in the history
Test SSlibKey and SigstoreKey in addition to already tested GPGKey.

Signed-off-by: Lukas Puehringer <[email protected]>
  • Loading branch information
lukpueh committed Mar 30, 2023
1 parent e6529cd commit b7ad98d
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions tests/check_public_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit b7ad98d

Please sign in to comment.