File tree Expand file tree Collapse file tree 3 files changed +39
-3
lines changed
Expand file tree Collapse file tree 3 files changed +39
-3
lines changed Original file line number Diff line number Diff line change 11
22try :
3- from jose .backends .pycrypto_backend import RSAKey # noqa: F401
3+ from jose .backends .cryptography_backend import CryptographyRSAKey as RSAKey # noqa: F401
44except ImportError :
55 try :
6- from jose .backends .cryptography_backend import CryptographyRSAKey as RSAKey # noqa: F401
6+ from jose .backends .pycrypto_backend import RSAKey # noqa: F401
77 except ImportError :
88 from jose .backends .rsa_backend import RSAKey # noqa: F401
99
Original file line number Diff line number Diff line change @@ -345,8 +345,9 @@ def test_pycrypto_RSA_key_instance():
345345@pytest .mark .pycrypto
346346@pytest .mark .pycryptodome
347347@pytest .mark .parametrize ("private_key" , PRIVATE_KEYS )
348+ @pytest .mark .skipif (None in (PyCryptoRSA , PyCryptoRSAKey ), reason = "Pycrypto/dome backend not available" )
348349def test_pycrypto_unencoded_cleartext (private_key ):
349- key = RSAKey (private_key , ALGORITHMS .RS256 )
350+ key = PyCryptoRSAKey (private_key , ALGORITHMS .RS256 )
350351 msg = b'test'
351352 signature = key .sign (msg )
352353 public_key = key .public_key ()
Original file line number Diff line number Diff line change 1+ """Test the default import handling."""
2+ try :
3+ from jose .backends .rsa_backend import RSAKey as PurePythonRSAKey
4+ except ImportError :
5+ PurePythonRSAKey = None
6+ try :
7+ from jose .backends .cryptography_backend import CryptographyRSAKey , CryptographyECKey
8+ except ImportError :
9+ CryptographyRSAKey = CryptographyECKey = None
10+ try :
11+ from jose .backends .pycrypto_backend import RSAKey as PyCryptoRSAKey
12+ except ImportError :
13+ PyCryptoRSAKey = None
14+ try :
15+ from jose .backends .ecdsa_backend import ECDSAECKey as PurePythonECDSAKey
16+ except ImportError :
17+ PurePythonRSAKey = None
18+
19+ from jose .backends import ECKey , RSAKey
20+
21+
22+ def test_default_ec_backend ():
23+ if CryptographyECKey is not None :
24+ assert ECKey is CryptographyECKey
25+ else :
26+ assert ECKey is PurePythonECDSAKey
27+
28+
29+ def test_default_rsa_backend ():
30+ if CryptographyRSAKey is not None :
31+ assert RSAKey is CryptographyRSAKey
32+ elif PyCryptoRSAKey is not None :
33+ assert RSAKey is PyCryptoRSAKey
34+ else :
35+ assert RSAKey is PurePythonRSAKey
You can’t perform that action at this time.
0 commit comments