diff options
author | Alex Stapleton <alexs@prol.etari.at> | 2013-12-21 15:16:57 +0000 |
---|---|---|
committer | Alex Stapleton <alexs@prol.etari.at> | 2013-12-21 17:12:05 +0000 |
commit | 1b1327cfe537b9e7bdc271239d1025c2479239c3 (patch) | |
tree | 8a27a12313c0ba6ab6b62757d1332e18bac2df9c /tests/hazmat/primitives/test_hashes.py | |
parent | 9b9318d79ba5927603b120411d13b607938cae56 (diff) | |
download | cryptography-1b1327cfe537b9e7bdc271239d1025c2479239c3.tar.gz cryptography-1b1327cfe537b9e7bdc271239d1025c2479239c3.tar.bz2 cryptography-1b1327cfe537b9e7bdc271239d1025c2479239c3.zip |
Raise UnsupportedAlgorithm when initing Hash()
Instead of just an AssertionError.
Diffstat (limited to 'tests/hazmat/primitives/test_hashes.py')
-rw-r--r-- | tests/hazmat/primitives/test_hashes.py | 14 |
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( |