forked from mpdavis/python-jose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_backends.py
59 lines (47 loc) · 1.53 KB
/
test_backends.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""Test the default import handling."""
try:
from jose.backends.rsa_backend import RSAKey as PurePythonRSAKey
except ImportError:
PurePythonRSAKey = None
try:
from jose.backends.cryptography_backend import CryptographyECKey, CryptographyRSAKey
except ImportError:
CryptographyRSAKey = CryptographyECKey = None
try:
from jose.backends.ecdsa_backend import ECDSAECKey as PurePythonECDSAKey
except ImportError:
PurePythonRSAKey = None
try:
from jose.backends.cryptography_backend import CryptographyAESKey
except ImportError:
CryptographyAESKey = None
try:
from jose.backends.cryptography_backend import CryptographyHMACKey
except ImportError:
CryptographyHMACKey = None
from jose.backends import ECKey, HMACKey, RSAKey
from jose.backends.native import HMACKey as NativeHMACKey
try:
from jose.backends import AESKey
except ImportError:
AESKey = None
def test_default_ec_backend():
if CryptographyECKey is not None:
assert ECKey is CryptographyECKey
else:
assert ECKey is PurePythonECDSAKey
def test_default_rsa_backend():
if CryptographyRSAKey is not None:
assert RSAKey is CryptographyRSAKey
else:
assert RSAKey is PurePythonRSAKey
def test_default_aes_backend():
if CryptographyAESKey is not None:
assert AESKey is CryptographyAESKey
else:
assert AESKey is None
def test_default_hmac_backend():
if CryptographyHMACKey is not None:
assert HMACKey is CryptographyHMACKey
else:
assert HMACKey is NativeHMACKey