diff options
author | Donald Stufft <donald@stufft.io> | 2013-10-03 11:26:42 -0700 |
---|---|---|
committer | Donald Stufft <donald@stufft.io> | 2013-10-03 11:26:42 -0700 |
commit | 0f96716946c80fbaa2bab7813746baaba017f08d (patch) | |
tree | 9ebbf38b4779b64effec121a6d562c543b613e8b /tests/primitives/test_block.py | |
parent | 14fdcd186c9f6c7ccc1e6388347cd584822bc041 (diff) | |
parent | 81a5287984cd31080f7a5a1b249caf626ac8f6bf (diff) | |
download | cryptography-0f96716946c80fbaa2bab7813746baaba017f08d.tar.gz cryptography-0f96716946c80fbaa2bab7813746baaba017f08d.tar.bz2 cryptography-0f96716946c80fbaa2bab7813746baaba017f08d.zip |
Merge pull request #85 from alex/explicit-api
Explicitly pass around the API, and run all tests under all available AP...
Diffstat (limited to 'tests/primitives/test_block.py')
-rw-r--r-- | tests/primitives/test_block.py | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/tests/primitives/test_block.py b/tests/primitives/test_block.py index 774409ca..774885fa 100644 --- a/tests/primitives/test_block.py +++ b/tests/primitives/test_block.py @@ -23,18 +23,27 @@ from cryptography.primitives.block.base import _Operation class TestBlockCipher(object): - def test_cipher_name(self): + def test_cipher_name(self, api): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(b"0" * 32)), - modes.CBC(binascii.unhexlify(b"0" * 32)) + modes.CBC(binascii.unhexlify(b"0" * 32)), + api ) assert cipher.name == "AES-128-CBC" - def test_use_after_finalize(self): + def test_instantiate_without_api(self): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(b"0" * 32)), modes.CBC(binascii.unhexlify(b"0" * 32)) ) + assert cipher.name == "AES-128-CBC" + + def test_use_after_finalize(self, api): + cipher = BlockCipher( + ciphers.AES(binascii.unhexlify(b"0" * 32)), + modes.CBC(binascii.unhexlify(b"0" * 32)), + api + ) cipher.encrypt(b"a" * 16) cipher.finalize() with pytest.raises(ValueError): @@ -42,20 +51,22 @@ class TestBlockCipher(object): with pytest.raises(ValueError): cipher.finalize() - def test_encrypt_with_invalid_operation(self): + def test_encrypt_with_invalid_operation(self, api): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(b"0" * 32)), - modes.CBC(binascii.unhexlify(b"0" * 32)) + modes.CBC(binascii.unhexlify(b"0" * 32)), + api ) cipher._operation = _Operation.decrypt with pytest.raises(ValueError): cipher.encrypt(b"b" * 16) - def test_finalize_with_invalid_operation(self): + def test_finalize_with_invalid_operation(self, api): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(b"0" * 32)), - modes.CBC(binascii.unhexlify(b"0" * 32)) + modes.CBC(binascii.unhexlify(b"0" * 32)), + api ) cipher._operation = pretend.stub(name="wat") |