From 2cce618311c892aa5a1be2ef899e8ff7a08ae5ef Mon Sep 17 00:00:00 2001 From: David Reid Date: Wed, 13 Nov 2013 13:49:41 -0800 Subject: Make HMAC methods raise AlreadyFinalized. --- tests/hazmat/primitives/test_hmac.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/hazmat/primitives/test_hmac.py') diff --git a/tests/hazmat/primitives/test_hmac.py b/tests/hazmat/primitives/test_hmac.py index 4186967a..d17049e3 100644 --- a/tests/hazmat/primitives/test_hmac.py +++ b/tests/hazmat/primitives/test_hmac.py @@ -19,6 +19,7 @@ import pytest import six +from cryptography.exceptions import AlreadyFinalized from cryptography.hazmat.primitives import hashes, hmac from .utils import generate_base_hmac_test @@ -49,3 +50,16 @@ class TestHMAC(object): def test_hmac_algorithm_instance(self): with pytest.raises(TypeError): hmac.HMAC(b"key", hashes.SHA1) + + def test_raises_after_finalize(self): + h = hmac.HMAC(b"key", hashes.SHA1()) + h.finalize() + + with pytest.raises(AlreadyFinalized): + h.update(b"foo") + + with pytest.raises(AlreadyFinalized): + h.copy() + + with pytest.raises(AlreadyFinalized): + h.finalize() -- cgit v1.2.3