Skip to content

Commit

Permalink
Update tests to guard against missing cryptography
Browse files Browse the repository at this point in the history
  • Loading branch information
jpadilla committed Dec 27, 2019
1 parent 1f12a9b commit bf42e33
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tests/test_api_jwk.py
Original file line number Diff line number Diff line change
@@ -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(
has_crypto, reason="Scenario requires cryptography to not be installed"
)
def test_should_load_key_from_jwk_data_dict(self):
algo = RSAAlgorithm(RSAAlgorithm.SHA256)

Expand All @@ -27,6 +37,9 @@ def test_should_load_key_from_jwk_data_dict(self):
assert jwk.key_id == "keyid-abc123"
assert jwk.public_key_use == "sig"

@pytest.mark.skipif(
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)

Expand All @@ -49,6 +62,9 @@ def test_should_load_key_from_jwk_data_json_string(self):


class TestPyJWKSet:
@pytest.mark.skipif(
has_crypto, reason="Scenario requires cryptography to not be installed"
)
def test_should_load_keys_from_jwk_data_dict(self):
algo = RSAAlgorithm(RSAAlgorithm.SHA256)

Expand All @@ -70,6 +86,9 @@ def test_should_load_keys_from_jwk_data_dict(self):
assert jwk.key_id == "keyid-abc123"
assert jwk.public_key_use == "sig"

@pytest.mark.skipif(
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)

Expand Down

0 comments on commit bf42e33

Please sign in to comment.