summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Padilla <jpadilla@webapplicate.com>2019-12-27 10:43:59 -0500
committerJosé Padilla <jpadilla@webapplicate.com>2020-04-06 09:32:04 -0400
commite781e96e7851235bb53b12ae59c656008419f1b6 (patch)
tree298b51e8b05c476a2a8cfc4a45c44733e9d71d23
parent1f4b8c6c3aed0d975232ce6e1b0f797d356a856b (diff)
downloadpyjwt-e781e96e7851235bb53b12ae59c656008419f1b6.tar.gz
Update tests to guard against missing cryptography
-rw-r--r--tests/test_api_jwk.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/test_api_jwk.py b/tests/test_api_jwk.py
index a0b9d66..6a7f78a 100644
--- a/tests/test_api_jwk.py
+++ b/tests/test_api_jwk.py
@@ -1,12 +1,22 @@
import json
+import pytest
-from jwt.algorithms import RSAAlgorithm
from jwt.api_jwk import PyJWK, PyJWKSet
from .utils import key_path
+try:
+ from jwt.algorithms import RSAAlgorithm
+
+ has_crypto = True
+except ImportError:
+ has_crypto = False
+
class TestPyJWK:
+ @pytest.mark.skipif(
+ not has_crypto, reason="Scenario requires cryptography to not be installed"
+ )
def test_should_load_key_from_jwk_data_dict(self):
algo = RSAAlgorithm(RSAAlgorithm.SHA256)
@@ -27,6 +37,9 @@ class TestPyJWK:
assert jwk.key_id == "keyid-abc123"
assert jwk.public_key_use == "sig"
+ @pytest.mark.skipif(
+ not has_crypto, reason="Scenario requires cryptography to not be installed"
+ )
def test_should_load_key_from_jwk_data_json_string(self):
algo = RSAAlgorithm(RSAAlgorithm.SHA256)
@@ -49,6 +62,9 @@ class TestPyJWK:
class TestPyJWKSet:
+ @pytest.mark.skipif(
+ not has_crypto, reason="Scenario requires cryptography to not be installed"
+ )
def test_should_load_keys_from_jwk_data_dict(self):
algo = RSAAlgorithm(RSAAlgorithm.SHA256)
@@ -70,6 +86,9 @@ class TestPyJWKSet:
assert jwk.key_id == "keyid-abc123"
assert jwk.public_key_use == "sig"
+ @pytest.mark.skipif(
+ not has_crypto, reason="Scenario requires cryptography to not be installed"
+ )
def test_should_load_keys_from_jwk_data_json_string(self):
algo = RSAAlgorithm(RSAAlgorithm.SHA256)