aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-11-13 13:26:24 -0800
committerAlex Gaynor <alex.gaynor@gmail.com>2013-11-13 13:26:24 -0800
commitc2cddd2b1f0bd935ed53ee49446e268d9bf874e7 (patch)
tree5ab21f260a23d74145662ece1c5c1b3917e28d63 /tests
parente0c1fe9991cb1e428d5179994940726baae899a0 (diff)
parent00fb12ae9d453e1c6db6a046ebf1f68000b44377 (diff)
downloadcryptography-c2cddd2b1f0bd935ed53ee49446e268d9bf874e7.tar.gz
cryptography-c2cddd2b1f0bd935ed53ee49446e268d9bf874e7.tar.bz2
cryptography-c2cddd2b1f0bd935ed53ee49446e268d9bf874e7.zip
Merge pull request #253 from dreid/hash-raise-after-finalize
raise an exception if you try to use a HashContext after finalize is called.
Diffstat (limited to 'tests')
-rw-r--r--tests/hazmat/primitives/test_hashes.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_hashes.py b/tests/hazmat/primitives/test_hashes.py
index c022f537..991caf15 100644
--- a/tests/hazmat/primitives/test_hashes.py
+++ b/tests/hazmat/primitives/test_hashes.py
@@ -19,6 +19,7 @@ import pytest
import six
+from cryptography.exceptions import AlreadyFinalized
from cryptography.hazmat.bindings import _default_backend
from cryptography.hazmat.primitives import hashes
@@ -51,6 +52,16 @@ class TestHashContext(object):
with pytest.raises(TypeError):
hashes.Hash(hashes.SHA1)
+ def test_raises_after_finalize(self):
+ h = hashes.Hash(hashes.SHA1())
+ h.finalize()
+
+ with pytest.raises(AlreadyFinalized):
+ h.update(b"foo")
+
+ with pytest.raises(AlreadyFinalized):
+ h.copy()
+
class TestSHA1(object):
test_SHA1 = generate_base_hash_test(