From 34511c697f6f17915b5fe5a58214bb38d779f4a8 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Wed, 13 Nov 2013 13:30:30 -0800 Subject: Use AlreadyFinalized for symmetric ciphers --- tests/hazmat/primitives/test_block.py | 10 +++++----- tests/hazmat/primitives/test_hashes.py | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/hazmat/primitives/test_block.py b/tests/hazmat/primitives/test_block.py index 28f34478..938cff36 100644 --- a/tests/hazmat/primitives/test_block.py +++ b/tests/hazmat/primitives/test_block.py @@ -17,7 +17,7 @@ import binascii import pytest -from cryptography.exceptions import UnsupportedAlgorithm +from cryptography.exceptions import UnsupportedAlgorithm, AlreadyFinalized from cryptography.hazmat.primitives import interfaces from cryptography.hazmat.primitives.ciphers import ( Cipher, algorithms, modes @@ -56,16 +56,16 @@ class TestCipherContext(object): encryptor = cipher.encryptor() encryptor.update(b"a" * 16) encryptor.finalize() - with pytest.raises(ValueError): + with pytest.raises(AlreadyFinalized): encryptor.update(b"b" * 16) - with pytest.raises(ValueError): + with pytest.raises(AlreadyFinalized): encryptor.finalize() decryptor = cipher.decryptor() decryptor.update(b"a" * 16) decryptor.finalize() - with pytest.raises(ValueError): + with pytest.raises(AlreadyFinalized): decryptor.update(b"b" * 16) - with pytest.raises(ValueError): + with pytest.raises(AlreadyFinalized): decryptor.finalize() def test_unaligned_block_encryption(self, backend): diff --git a/tests/hazmat/primitives/test_hashes.py b/tests/hazmat/primitives/test_hashes.py index 991caf15..367e764f 100644 --- a/tests/hazmat/primitives/test_hashes.py +++ b/tests/hazmat/primitives/test_hashes.py @@ -62,6 +62,9 @@ class TestHashContext(object): with pytest.raises(AlreadyFinalized): h.copy() + with pytest.raises(AlreadyFinalized): + h.finalize() + class TestSHA1(object): test_SHA1 = generate_base_hash_test( -- cgit v1.2.3