aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives
diff options
context:
space:
mode:
authorDonald Stufft <donald@stufft.io>2013-11-17 10:52:33 -0800
committerDonald Stufft <donald@stufft.io>2013-11-17 10:52:33 -0800
commit4a28d323b1227860da118a933d5f4940acaef999 (patch)
treee354636fdb891044548a3bb7042a253bfa97a616 /tests/hazmat/primitives
parent83e0e1f00224c1f995298226c2e0837d555af67c (diff)
parent0a394df31c4165d0230843ebea2717b3cd3caafa (diff)
downloadcryptography-4a28d323b1227860da118a933d5f4940acaef999.tar.gz
cryptography-4a28d323b1227860da118a933d5f4940acaef999.tar.bz2
cryptography-4a28d323b1227860da118a933d5f4940acaef999.zip
Merge pull request #262 from dreid/cipher-algorithm-interfaces
Implement and document an interface for cipher algorithms
Diffstat (limited to 'tests/hazmat/primitives')
-rw-r--r--tests/hazmat/primitives/test_block.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/hazmat/primitives/test_block.py b/tests/hazmat/primitives/test_block.py
index 938cff36..963136b9 100644
--- a/tests/hazmat/primitives/test_block.py
+++ b/tests/hazmat/primitives/test_block.py
@@ -24,6 +24,11 @@ from cryptography.hazmat.primitives.ciphers import (
)
+@interfaces.register(interfaces.CipherAlgorithm)
+class DummyCipher(object):
+ pass
+
+
class TestCipher(object):
def test_instantiate_without_backend(self):
Cipher(
@@ -45,6 +50,11 @@ class TestCipher(object):
)
assert isinstance(cipher.decryptor(), interfaces.CipherContext)
+ def test_instantiate_with_non_algorithm(self):
+ algorithm = object()
+ with pytest.raises(TypeError):
+ Cipher(algorithm, mode=None)
+
class TestCipherContext(object):
def test_use_after_finalize(self, backend):
@@ -90,7 +100,7 @@ class TestCipherContext(object):
def test_nonexistent_cipher(self, backend):
cipher = Cipher(
- object(), object(), backend
+ DummyCipher(), object(), backend
)
with pytest.raises(UnsupportedAlgorithm):
cipher.encryptor()