aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-12-21 10:38:58 -0800
committerAlex Gaynor <alex.gaynor@gmail.com>2013-12-21 10:38:58 -0800
commit4447e5a72c6c5d4f3f8fc27711e094540d66ef67 (patch)
treee83aaec9dac1c1cdcf8a0798d1eeac5f78f1e875 /tests/hazmat
parent72d3b80eeb5c31fb487f56f38f283b6416301ad9 (diff)
parent1b1327cfe537b9e7bdc271239d1025c2479239c3 (diff)
downloadcryptography-4447e5a72c6c5d4f3f8fc27711e094540d66ef67.tar.gz
cryptography-4447e5a72c6c5d4f3f8fc27711e094540d66ef67.tar.bz2
cryptography-4447e5a72c6c5d4f3f8fc27711e094540d66ef67.zip
Merge pull request #324 from public/unsupported-hash
Raise UnsupportedAlgorithm when initing Hash()
Diffstat (limited to 'tests/hazmat')
-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(