aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat
diff options
context:
space:
mode:
authorAlex Stapleton <alexs@prol.etari.at>2013-12-21 21:26:55 +0000
committerAlex Stapleton <alexs@prol.etari.at>2013-12-21 21:32:02 +0000
commit447d64fb69e19c0059e3ba18ef3b1317a716a7c4 (patch)
tree39debf1be2daed29df51e240164f4f229caf9c64 /tests/hazmat
parent9b9318d79ba5927603b120411d13b607938cae56 (diff)
downloadcryptography-447d64fb69e19c0059e3ba18ef3b1317a716a7c4.tar.gz
cryptography-447d64fb69e19c0059e3ba18ef3b1317a716a7c4.tar.bz2
cryptography-447d64fb69e19c0059e3ba18ef3b1317a716a7c4.zip
Raise UnsupportedAlgorithm when initing HMACs
Diffstat (limited to 'tests/hazmat')
-rw-r--r--tests/hazmat/primitives/test_hmac.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/hazmat/primitives/test_hmac.py b/tests/hazmat/primitives/test_hmac.py
index 992bcb1a..124c4377 100644
--- a/tests/hazmat/primitives/test_hmac.py
+++ b/tests/hazmat/primitives/test_hmac.py
@@ -19,12 +19,18 @@ import pytest
import six
-from cryptography.exceptions import AlreadyFinalized
-from cryptography.hazmat.primitives import hashes, hmac
+from cryptography import utils
+from cryptography.exceptions import AlreadyFinalized, UnsupportedAlgorithm
+from cryptography.hazmat.primitives import hashes, hmac, interfaces
from .utils import generate_base_hmac_test
+@utils.register_interface(interfaces.HashAlgorithm)
+class UnsupportedDummyHash(object):
+ name = "unsupported-dummy-hash"
+
+
class TestHMAC(object):
test_copy = generate_base_hmac_test(
hashes.MD5(),
@@ -63,3 +69,7 @@ class TestHMAC(object):
with pytest.raises(AlreadyFinalized):
h.finalize()
+
+ def test_unsupported_hash(self, backend):
+ with pytest.raises(UnsupportedAlgorithm):
+ hmac.HMAC(b"key", UnsupportedDummyHash(), backend)