aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/test_hashes.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/hazmat/primitives/test_hashes.py')
-rw-r--r--tests/hazmat/primitives/test_hashes.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/hazmat/primitives/test_hashes.py b/tests/hazmat/primitives/test_hashes.py
index ff42e8f4..72bc3e27 100644
--- a/tests/hazmat/primitives/test_hashes.py
+++ b/tests/hazmat/primitives/test_hashes.py
@@ -19,12 +19,18 @@ import pytest
import six
-from cryptography.exceptions import AlreadyFinalized
-from cryptography.hazmat.primitives import hashes
+from cryptography import utils
+from cryptography.exceptions import AlreadyFinalized, UnsupportedAlgorithm
+from cryptography.hazmat.primitives import hashes, interfaces
from .utils import generate_base_hash_test
+@utils.register_interface(interfaces.HashAlgorithm)
+class UnsupportedDummyHash(object):
+ name = "unsupported-dummy-hash"
+
+
class TestHashContext(object):
def test_hash_reject_unicode(self, backend):
m = hashes.Hash(hashes.SHA1(), backend=backend)
@@ -57,6 +63,10 @@ class TestHashContext(object):
with pytest.raises(AlreadyFinalized):
h.finalize()
+ def test_unsupported_hash(self, backend):
+ with pytest.raises(UnsupportedAlgorithm):
+ hashes.Hash(UnsupportedDummyHash(), backend)
+
class TestSHA1(object):
test_SHA1 = generate_base_hash_test(