aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2014-10-28 08:30:16 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2014-10-28 08:30:16 -0700
commit4583ffda28b816359f4351cfe7918b2353cf947e (patch)
tree69394e196b8688d8b3ca5bbe142f433461bb332a
parentc63c31e1138e8f0900dd7c5d38320e31532c99b5 (diff)
downloadcryptography-4583ffda28b816359f4351cfe7918b2353cf947e.tar.gz
cryptography-4583ffda28b816359f4351cfe7918b2353cf947e.tar.bz2
cryptography-4583ffda28b816359f4351cfe7918b2353cf947e.zip
sanitize the tests
-rw-r--r--tests/hazmat/primitives/test_cmac.py6
-rw-r--r--tests/hazmat/primitives/test_hashes.py8
-rw-r--r--tests/hazmat/primitives/test_hmac.py14
3 files changed, 11 insertions, 17 deletions
diff --git a/tests/hazmat/primitives/test_cmac.py b/tests/hazmat/primitives/test_cmac.py
index d9619daa..c778ebee 100644
--- a/tests/hazmat/primitives/test_cmac.py
+++ b/tests/hazmat/primitives/test_cmac.py
@@ -24,14 +24,14 @@ import six
from cryptography.exceptions import (
AlreadyFinalized, InvalidSignature, _Reasons
)
-from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.backends.interfaces import CMACBackend
from cryptography.hazmat.primitives.ciphers.algorithms import (
AES, ARC4, TripleDES
)
from cryptography.hazmat.primitives.cmac import CMAC
-from tests.utils import (
+from ..backends.test_multibackend import DummyCMACBackend
+from ...utils import (
load_nist_vectors, load_vectors_from_file, raises_unsupported_algorithm
)
@@ -195,7 +195,7 @@ class TestCMAC(object):
def test_copy():
- backend = default_backend()
+ backend = DummyCMACBackend([AES])
copied_ctx = pretend.stub()
pretend_ctx = pretend.stub(copy=lambda: copied_ctx)
key = b"2b7e151628aed2a6abf7158809cf4f3c"
diff --git a/tests/hazmat/primitives/test_hashes.py b/tests/hazmat/primitives/test_hashes.py
index 4345a7f4..053a1a46 100644
--- a/tests/hazmat/primitives/test_hashes.py
+++ b/tests/hazmat/primitives/test_hashes.py
@@ -20,14 +20,12 @@ import pytest
import six
from cryptography import utils
-from cryptography.exceptions import (
- AlreadyFinalized, _Reasons
-)
-from cryptography.hazmat.backends import default_backend
+from cryptography.exceptions import AlreadyFinalized, _Reasons
from cryptography.hazmat.backends.interfaces import HashBackend
from cryptography.hazmat.primitives import hashes, interfaces
from .utils import generate_base_hash_test
+from ..backends.test_multibackend import DummyHashBackend
from ...utils import raises_unsupported_algorithm
@@ -46,7 +44,7 @@ class TestHashContext(object):
m.update(six.u("\u00FC"))
def test_copy_backend_object(self):
- backend = default_backend()
+ backend = DummyHashBackend([hashes.SHA1])
copied_ctx = pretend.stub()
pretend_ctx = pretend.stub(copy=lambda: copied_ctx)
h = hashes.Hash(hashes.SHA1(), backend=backend, ctx=pretend_ctx)
diff --git a/tests/hazmat/primitives/test_hmac.py b/tests/hazmat/primitives/test_hmac.py
index 3553632c..497b37e1 100644
--- a/tests/hazmat/primitives/test_hmac.py
+++ b/tests/hazmat/primitives/test_hmac.py
@@ -27,6 +27,7 @@ from cryptography.hazmat.backends.interfaces import HMACBackend
from cryptography.hazmat.primitives import hashes, hmac, interfaces
from .utils import generate_base_hmac_test
+from ..backends.test_multibackend import DummyHMACBackend
from ...utils import raises_unsupported_algorithm
@@ -56,17 +57,12 @@ class TestHMAC(object):
h.update(six.u("\u00FC"))
def test_copy_backend_object(self):
- @utils.register_interface(HMACBackend)
- class PretendBackend(object):
- pass
-
- pretend_backend = PretendBackend()
+ backend = DummyHMACBackend([hashes.SHA1])
copied_ctx = pretend.stub()
pretend_ctx = pretend.stub(copy=lambda: copied_ctx)
- h = hmac.HMAC(b"key", hashes.SHA1(), backend=pretend_backend,
- ctx=pretend_ctx)
- assert h._backend is pretend_backend
- assert h.copy()._backend is pretend_backend
+ h = hmac.HMAC(b"key", hashes.SHA1(), backend=backend, ctx=pretend_ctx)
+ assert h._backend is backend
+ assert h.copy()._backend is backend
def test_hmac_algorithm_instance(self, backend):
with pytest.raises(TypeError):