aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Reid <dreid@dreid.org>2013-11-12 16:41:13 -0800
committerDavid Reid <dreid@dreid.org>2013-11-12 16:41:13 -0800
commit152d6bec8c34c52d75373dd8d99a3d159baa9550 (patch)
treec8bee3c932c0173f6fa025ac0eb5e990fdf8cc51 /tests
parent4faa094526f49c83a75d21a6e796546d4d539c6c (diff)
downloadcryptography-152d6bec8c34c52d75373dd8d99a3d159baa9550.tar.gz
cryptography-152d6bec8c34c52d75373dd8d99a3d159baa9550.tar.bz2
cryptography-152d6bec8c34c52d75373dd8d99a3d159baa9550.zip
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 6cdb0a07..a5c440b8 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 import exceptions
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(exceptions.AlreadyFinalized):
+ h.update(b"foo")
+
+ with pytest.raises(exceptions.AlreadyFinalized):
+ h.copy()
+
class TestSHA1(object):
test_SHA1 = generate_base_hash_test(