aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/test_hmac.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2014-10-28 09:16:13 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2014-10-28 09:16:13 -0700
commit6f386b9019f2d6ca8e6ff01a3d0433c9a371732f (patch)
treec21fb7d95b53f2e5c1bf0ed4218565b3aad9c2b8 /tests/hazmat/primitives/test_hmac.py
parent4365b12f01b3f5f501ca4f86c59999e78980790c (diff)
downloadcryptography-6f386b9019f2d6ca8e6ff01a3d0433c9a371732f.tar.gz
cryptography-6f386b9019f2d6ca8e6ff01a3d0433c9a371732f.tar.bz2
cryptography-6f386b9019f2d6ca8e6ff01a3d0433c9a371732f.zip
When using a test double for backends, always use one which really implements the interface
Diffstat (limited to 'tests/hazmat/primitives/test_hmac.py')
-rw-r--r--tests/hazmat/primitives/test_hmac.py14
1 files changed, 5 insertions, 9 deletions
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):