From f1a3fc03dc7cecc7658620f342dfd7cf6bb98ba0 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sat, 2 Nov 2013 14:03:34 -0700 Subject: Document and implement the public API for when the backend doesn't support the requested algorithm --- tests/hazmat/primitives/test_block.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/hazmat/primitives/test_block.py b/tests/hazmat/primitives/test_block.py index e0ed6697..2c0be1b5 100644 --- a/tests/hazmat/primitives/test_block.py +++ b/tests/hazmat/primitives/test_block.py @@ -17,6 +17,7 @@ import binascii import pytest +from cryptography.exceptions import NoSuchAlgorithm from cryptography.hazmat.primitives import interfaces from cryptography.hazmat.primitives.block import BlockCipher, ciphers, modes @@ -84,3 +85,13 @@ class TestBlockCipherContext(object): assert len(pt) == 80 assert pt == b"a" * 80 decryptor.finalize() + + def test_nonexistant_cipher(self, backend): + cipher = BlockCipher( + object(), object(), backend + ) + with pytest.raises(NoSuchAlgorithm): + cipher.encryptor() + + with pytest.raises(NoSuchAlgorithm): + cipher.decryptor() -- cgit v1.2.3 From 3949f1171084c2e1cfe43f638857ea0e0f8f246d Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sat, 2 Nov 2013 16:57:10 -0700 Subject: Changed excpetion name based on feedback from dreid --- tests/hazmat/primitives/test_block.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/hazmat/primitives/test_block.py b/tests/hazmat/primitives/test_block.py index 2c0be1b5..dd9c54c9 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 NoSuchAlgorithm +from cryptography.exceptions import UnsupportedAlgorithm from cryptography.hazmat.primitives import interfaces from cryptography.hazmat.primitives.block import BlockCipher, ciphers, modes @@ -90,8 +90,8 @@ class TestBlockCipherContext(object): cipher = BlockCipher( object(), object(), backend ) - with pytest.raises(NoSuchAlgorithm): + with pytest.raises(UnsupportedAlgorithm): cipher.encryptor() - with pytest.raises(NoSuchAlgorithm): + with pytest.raises(UnsupportedAlgorithm): cipher.decryptor() -- cgit v1.2.3