aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-10-21 21:42:00 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2013-10-21 21:42:00 -0700
commit7b3c1b96d0fb37aaedf93d226a16389b78612f8c (patch)
treee63609d0d2b75c0e26d5b8cac539bff5c53f79d6 /tests
parentf988a9ebc594bf1e5c996164befe69f1225dd564 (diff)
parente524d73d76d63c6399a55cd80cec53cf39c98659 (diff)
downloadcryptography-7b3c1b96d0fb37aaedf93d226a16389b78612f8c.tar.gz
cryptography-7b3c1b96d0fb37aaedf93d226a16389b78612f8c.tar.bz2
cryptography-7b3c1b96d0fb37aaedf93d226a16389b78612f8c.zip
Merge branch 'master' into triple-des
Diffstat (limited to 'tests')
-rw-r--r--tests/primitives/test_hashes.py11
-rw-r--r--tests/primitives/test_utils.py5
-rw-r--r--tests/primitives/utils.py4
-rw-r--r--tests/test_utils.py10
4 files changed, 23 insertions, 7 deletions
diff --git a/tests/primitives/test_hashes.py b/tests/primitives/test_hashes.py
index 901ddabb..805d992b 100644
--- a/tests/primitives/test_hashes.py
+++ b/tests/primitives/test_hashes.py
@@ -13,11 +13,22 @@
from __future__ import absolute_import, division, print_function
+import pytest
+
+import six
+
from cryptography.primitives import hashes
from .utils import generate_base_hash_test
+class TestBaseHash(object):
+ def test_base_hash_reject_unicode(self, api):
+ m = hashes.SHA1(api=api)
+ with pytest.raises(TypeError):
+ m.update(six.u("\u00FC"))
+
+
class TestSHA1(object):
test_SHA1 = generate_base_hash_test(
hashes.SHA1,
diff --git a/tests/primitives/test_utils.py b/tests/primitives/test_utils.py
index 9888309e..6e197923 100644
--- a/tests/primitives/test_utils.py
+++ b/tests/primitives/test_utils.py
@@ -1,7 +1,8 @@
import pytest
-from .utils import (base_hash_test, encrypt_test, hash_test,
- long_string_hash_test)
+from .utils import (
+ base_hash_test, encrypt_test, hash_test, long_string_hash_test
+)
class TestEncryptTest(object):
diff --git a/tests/primitives/utils.py b/tests/primitives/utils.py
index a3759b03..a15e773c 100644
--- a/tests/primitives/utils.py
+++ b/tests/primitives/utils.py
@@ -67,6 +67,8 @@ def hash_test(api, hash_cls, params, only_if, skip_message):
m = hash_cls(api=api)
m.update(binascii.unhexlify(msg))
assert m.hexdigest() == md.replace(" ", "").lower()
+ digest = hash_cls(api=api, data=binascii.unhexlify(msg)).hexdigest()
+ assert digest == md.replace(" ", "").lower()
def generate_base_hash_test(hash_cls, digest_size, block_size,
@@ -115,6 +117,6 @@ def generate_long_string_hash_test(hash_factory, md, only_if=None,
def long_string_hash_test(api, hash_factory, md, only_if, skip_message):
if only_if is not None and not only_if(api):
pytest.skip(skip_message)
- m = hash_factory(api)
+ m = hash_factory(api=api)
m.update(b"a" * 1000000)
assert m.hexdigest() == md.lower()
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 3fe9e570..f96cf004 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -15,10 +15,12 @@ import textwrap
import pytest
-from .utils import (load_nist_vectors, load_nist_vectors_from_file,
- load_cryptrec_vectors, load_cryptrec_vectors_from_file,
- load_openssl_vectors, load_openssl_vectors_from_file, load_hash_vectors,
- load_hash_vectors_from_file)
+from .utils import (
+ load_nist_vectors, load_nist_vectors_from_file, load_cryptrec_vectors,
+ load_cryptrec_vectors_from_file, load_openssl_vectors,
+ load_openssl_vectors_from_file, load_hash_vectors,
+ load_hash_vectors_from_file
+)
def test_load_nist_vectors_encrypt():