diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2013-10-22 20:22:34 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2013-10-22 20:22:34 -0500 |
commit | 360e2d53190fa612eccd3ae43c7cd3c240282a7a (patch) | |
tree | 60f69803f3921406b173afe3d307eafcdb50c896 /tests/primitives/test_hashes.py | |
parent | 2c4873f6255c70257a5a35efbad84e24fc2be63f (diff) | |
parent | 68e5de708d623a03ea4cbd4d3a4297b5722950eb (diff) | |
download | cryptography-360e2d53190fa612eccd3ae43c7cd3c240282a7a.tar.gz cryptography-360e2d53190fa612eccd3ae43c7cd3c240282a7a.tar.bz2 cryptography-360e2d53190fa612eccd3ae43c7cd3c240282a7a.zip |
Merge branch 'master' into api-to-backend-in-one-easy-step
* master:
Make use of currentmodule to maybe reduce redundant module definitions and also get source links.
Enable the new read the docs theme, it's pretty.
use is for identical object comparison
add gcm constants and EVP_CIPHER_CTX_ctrl macro
md5 is 128-bit. The person responsible for this mistake has been shot
add test to verify api is being copied in hash
When copying a hash, pass the api through to the new object
Diffstat (limited to 'tests/primitives/test_hashes.py')
-rw-r--r-- | tests/primitives/test_hashes.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/primitives/test_hashes.py b/tests/primitives/test_hashes.py index 505f6c8a..7ddd1859 100644 --- a/tests/primitives/test_hashes.py +++ b/tests/primitives/test_hashes.py @@ -13,10 +13,14 @@ from __future__ import absolute_import, division, print_function +import pretend + import pytest import six +from cryptography.bindings import _default_api + from cryptography.primitives import hashes from .utils import generate_base_hash_test @@ -33,6 +37,24 @@ class TestBaseHash(object): assert isinstance(m.hexdigest(), str) +class TestCopyHash(object): + def test_copy_api_object(self): + pretend_api = pretend.stub(copy_hash_context=lambda a: "copiedctx") + pretend_ctx = pretend.stub() + h = hashes.SHA1(api=pretend_api, ctx=pretend_ctx) + assert h._api is pretend_api + assert h.copy()._api is h._api + + +class TestDefaultAPISHA1(object): + def test_default_api_creation(self): + """ + This test assumes the presence of SHA1 in the default API. + """ + h = hashes.SHA1() + assert h._api is _default_api + + class TestSHA1(object): test_SHA1 = generate_base_hash_test( hashes.SHA1, |