summaryrefslogtreecommitdiff
path: root/tests/test_api_jwk.py
diff options
context:
space:
mode:
authorViicos <65306057+Viicos@users.noreply.github.com>2023-01-26 15:28:51 +0100
committerGitHub <noreply@github.com>2023-01-26 20:28:51 +0600
commitb407c63b17f16e78c13c36d784d6e1822fee1147 (patch)
treeff4639286079fd1c7aa221891664ae3872244eb9 /tests/test_api_jwk.py
parent0a99cc2427c751275ea0002acca9ba0c07c25834 (diff)
downloadpyjwt-b407c63b17f16e78c13c36d784d6e1822fee1147.tar.gz
Improve error messages when cryptography isn't installed (#846)
* Improve error messages when cryptography isn't installed * Add test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Diffstat (limited to 'tests/test_api_jwk.py')
-rw-r--r--tests/test_api_jwk.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/test_api_jwk.py b/tests/test_api_jwk.py
index 3f40fc5..f04f575 100644
--- a/tests/test_api_jwk.py
+++ b/tests/test_api_jwk.py
@@ -6,7 +6,7 @@ from jwt.algorithms import has_crypto
from jwt.api_jwk import PyJWK, PyJWKSet
from jwt.exceptions import InvalidKeyError, PyJWKError, PyJWKSetError
-from .utils import crypto_required, key_path
+from .utils import crypto_required, key_path, no_crypto_required
if has_crypto:
from jwt.algorithms import ECAlgorithm, HMACAlgorithm, OKPAlgorithm, RSAAlgorithm
@@ -207,6 +207,12 @@ class TestPyJWK:
with pytest.raises(InvalidKeyError):
PyJWK.from_dict(v)
+ @no_crypto_required
+ def test_missing_crypto_library_good_error_message(self):
+ with pytest.raises(PyJWKError) as exc:
+ PyJWK({"kty": "dummy"}, algorithm="RS256")
+ assert "cryptography" in str(exc.value)
+
@crypto_required
class TestPyJWKSet: