aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/twofactor/test_totp.py
diff options
context:
space:
mode:
authorAyrx <terrycwk1994@gmail.com>2014-03-15 21:51:04 +0800
committerAyrx <terrycwk1994@gmail.com>2014-03-15 21:51:04 +0800
commit30e574e8f0759a747f77e0e45fa5dbefeb44f3f0 (patch)
treea32b6765ba4ff5862c35b2b181443b2b181c6617 /tests/hazmat/primitives/twofactor/test_totp.py
parentb8a9c9e6243716b353b0786dae1e6e7d94f474a8 (diff)
downloadcryptography-30e574e8f0759a747f77e0e45fa5dbefeb44f3f0.tar.gz
cryptography-30e574e8f0759a747f77e0e45fa5dbefeb44f3f0.tar.bz2
cryptography-30e574e8f0759a747f77e0e45fa5dbefeb44f3f0.zip
Added backend check to twofactor primitives
Diffstat (limited to 'tests/hazmat/primitives/twofactor/test_totp.py')
-rw-r--r--tests/hazmat/primitives/twofactor/test_totp.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/hazmat/primitives/twofactor/test_totp.py b/tests/hazmat/primitives/twofactor/test_totp.py
index f3bddb88..776a9f2a 100644
--- a/tests/hazmat/primitives/twofactor/test_totp.py
+++ b/tests/hazmat/primitives/twofactor/test_totp.py
@@ -13,9 +13,11 @@
from __future__ import absolute_import, division, print_function
+import pretend
+
import pytest
-from cryptography.exceptions import InvalidToken
+from cryptography.exceptions import InvalidToken, UnsupportedInterface
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.twofactor.totp import TOTP
from tests.utils import load_vectors_from_file, load_nist_vectors
@@ -129,3 +131,12 @@ class TestTOTP(object):
totp = TOTP(secret, 8, hashes.SHA1(), 30, backend)
assert totp.generate(time) == b"94287082"
+
+
+def test_invalid_backend():
+ secret = b"12345678901234567890"
+
+ pretend_backend = pretend.stub()
+
+ with pytest.raises(UnsupportedInterface):
+ TOTP(secret, 8, hashes.SHA1(), 30, pretend_backend)